日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

3 Redis 配置文件

發布時間:2025/3/19 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 3 Redis 配置文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

    • 1 Redis 全局配置
      • 1.1 redis.conf啟動配置
      • 1.2 units單位
    • 2 NETWORK
      • 2.1 bind 綁定ip
      • 2.2 port端口
      • 2.3 tcp-backlog
      • 2.4 timeout 超時時間
      • 2.5 tcp-keepalive 心跳監測周期
    • 3 GENERAL 通用配置
      • 3.1 daemonize 開啟守護進程,后臺啟動
      • 3.2 pidfile 進程號文件
      • 3.3 loglevel 日志級別
      • 3.4 logfile 日志輸出路徑
      • 3.5 databases 數據庫大小
    • 4 SECURITY 安全
      • 4.1 requirepass 密碼
    • 5 CLIENTS 客戶端連接
      • 5.1 maxclients

1 Redis 全局配置

1.1 redis.conf啟動配置

redis啟動必須的配置文件redis.conf

./redis-server /path/to/redis.conf

1.2 units單位

不區分大小寫,大小寫不敏感,需要指定單位

# 1k => 1000 bytes # 1kb => 1024 bytes # 1m => 1000000 bytes # 1mb => 1024*1024 bytes # 1g => 1000000000 bytes # 1gb => 1024*1024*1024 bytes # # units are case insensitive so 1GB 1Gb 1gB are all the same.

2 NETWORK

2.1 bind 綁定ip

注釋掉bind 表示關閉本地訪問,開啟遠程訪問
protected-mode 由yes改為no 配合上面注釋關閉保護模式,開啟遠程訪問

# bind 127.0.0.1 -::1 protected-mode no

2.2 port端口

默認端口號 6379

# Accept connections on the specified port, default is 6379 (IANA #815344). # If port 0 is specified Redis will not listen on a TCP socket. port 6379

2.3 tcp-backlog

設置tcp的tcp-backlog,backlog其實是一個連接隊列,backlog隊列總和 = 未完成三次握手隊列 + 已完成三次握手隊列

在高并發環境下你需要一個高backlog值來避免慢客戶端連接問題

注意linux 內核會將這個值減小到/proc/sys/net/core/somaxconn的值(128),所以需要確認增大/proc/sys/net/core/somaxconn和/proc/sys/ipv4/tcp_max_syn_backlog(128) 兩個值來達到想要的效果

2.4 timeout 超時時間

配置客戶端連接超時時間,以秒為單位,為0表示永不超時。

# Close the connection after a client is idle for N seconds (0 to disable) timeout 0

2.5 tcp-keepalive 心跳監測周期

tcp-keepalive 300

3 GENERAL 通用配置

3.1 daemonize 開啟守護進程,后臺啟動

daemonize yes

3.2 pidfile 進程號文件

記錄配置redis運行時進程號

# Note that on modern Linux systems "/run/redis.pid" is more conforming # and should be used instead. pidfile /var/run/redis_6379.pid

3.3 loglevel 日志級別

共分為四個日志級別
debug
verbose
notice (默認級別)
warning

# Specify the server verbosity level. # This can be one of: # debug (a lot of information, useful for development/testing) # verbose (many rarely useful info, but not a mess like the debug level) # notice (moderately verbose, what you want in production probably) # warning (only very important / critical messages are logged) loglevel notice

3.4 logfile 日志輸出路徑

logfile ""

3.5 databases 數據庫大小

默認使用0號庫 SELECT 可以切換數據庫

databases 16

4 SECURITY 安全

4.1 requirepass 密碼

默認沒有密碼,是被注釋了

# requirepass foobared

5 CLIENTS 客戶端連接

5.1 maxclients

設置redis 同時可以與多少個客戶端進行連接。

默認情況下為10000個客戶端

如果達到了此限制,redis 則會拒絕新的連接請求,并且向這些連接請求方發出“max number of clients reached” 以作回應

# maxclients 10000

總結

以上是生活随笔為你收集整理的3 Redis 配置文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。