【Redis】設定相關
# 只支持本地
bind 127.0.0.1 -::1
protected-mode yes
# 要支援遠端存取註解 bind 127.0.0.1 -::1
# protected-mode no
# bind 127.0.0.1 -::1
protected-mode no
# 未完成三向交握+已完成三向交握上限
tcp-backlog 511
# Close the connection after a client is idle for N seconds (0 to disable)
# 0: 永不過期
timeout 0
# 檢測連線存在的間隔時間
tcp-keepalive 300
# 使用daemon啟動
daemonize yes
# pid檔案位置
# 如果指定了pid文件,Redis在啟動時會將其寫入指定位置,並在退出時刪除它。
# 當服務器以非守護模式運行時,如果在配置中未指定pid文件,則不會創建pid文件。當服務器以守護模式運行時,即使未指定,也將使用pid文件,默認為 "/var/run/redis.pid"。
# 創建pid文件是盡力而為的:如果Redis無法創建它,不會發生任何壞事,服務器將正常啟動和運行。
# 請注意,在現代Linux系統上,應改用 "/run/redis.pid",因為這更符合規範。
pidfile /var/run/redis_6379.pid
# log 級別
# 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
# 設定db數量
databases 16
# 設置密碼
# requirepass {密碼}
requirepass foobared
# 使用命令臨時設定密碼(服務重啟失效)
127.0.0.1:6379>config set requirepass "123456"
# 登入
127.0.0.1:6379>auth 123456
# 最大連接數(預設無)
maxclients 10000
# 最大記憶體使用量(預設無)
maxmemory <bytes>
# 持久化(快照)(REB)
# 有可能最後一次資料丟失
# 寫入檔名
dbfilename dump.rdb
# 寫入目錄(啟動redis命令當前目錄)
dir ./
# 快照設定
# 3600秒內有1個key異動
# save 3600 1
# 300秒內有100個key異動
# save 300 100
# 60秒內有10000個key異動
# save 60 10000
# Redis 無法寫入檔案,關閉寫入操作
stop-writes-on-bgsave-error yes
# 文件進行壓縮
rdbcompression yes
# 文件檢查(影響10%效能)
rdbchecksum yes