Redis配置文件:redis.conf學習

Redis配置文件:redis.conf學習

單位

# 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.

子文件

################################## INCLUDES ###################################

# 嵌套其他子配置文件
# include .\path\to\local.conf
# include c:\path\to\other.conf

配置IP和端口號

# Examples:
# 配置IP地址
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1

# 設置保護模式
protected-mode yes

# If port 0 is specified Redis will not listen on a TCP socket.
# 配置端口號
port 6379

通用配置

################################# GENERAL #####################################

# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# 以守護進程的方式運行(避免你退出後,進程結束),默認是no,yes開啓
# NOT SUPPORTED ON WINDOWS daemonize no

# 用於管理守護進程,默認是NO,一般不用動
# NOT SUPPORTED ON WINDOWS supervised no

# nothing bad happens, the server will start and run normally.
# 如果以後臺方式(守護進程)運行,就需要個一個PID文件
# NOT SUPPORTED ON WINDOWS pidfile /var/run/redis.pid

# Specify the server verbosity level.
# This can be one of:
# 用於開發和測試
# debug (a lot of information, useful for development/testing)
# 類似於debug
# 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

# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output.
# 日誌的文件日誌名
logfile ""

# dbid is a number between 0 and 'databases'-1
# 16個數據庫
databases 16

快照

#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
# 在規定的時間內,執行了多少次操作,則會持久化到文件.rdb .aof
#   save ""

save 900 1
save 300 10
save 60 10000

# permissions, and so forth.
# 持久化失敗後,是否繼續工作
stop-writes-on-bgsave-error yes

# the dataset will likely be bigger if you have compressible values or keys.
# 壓縮rdb文件,需要消耗一些資源(CPU),如果CPU過高可以關掉
rdbcompression yes

# tell the loading code to skip the check.
# 保存rdb文件的時候,進行檢查,校驗錯誤
rdbchecksum yes

# The filename where to dump the DB
# rdb的文件名
dbfilename dump.rdb

# Note that you must specify a directory here, not a file name.
# rdb文件保存的路徑
dir ./


安全

# use a very strong password otherwise it will be very easy to break.
# 設置redis的密碼
# requirepass 123123
# requirepass foobared

# an error 'max number of clients reached'.
# 限制最大連接客戶端
# maxclients 10000

# reported by the INFO command.
# redis配置的最大內存容量
# maxmemory <bytes>


# volatile-lru -> remove the key with an expire set using an LRU algorithm 只對設置了過期時間的key進行LRU
# allkeys-lru -> remove any key according to the LRU algorithm 刪除LRU算法的key
# volatile-random -> remove a random key with an expire set 隨即刪除即將過期KEY
# allkeys-random -> remove a random key, any key 隨即刪除
# volatile-ttl -> remove the key with the nearest expire time (minor TTL) 刪除即將過期的
# noeviction -> don't expire at all, just return an error on write operations 永不過期,返回錯誤
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
#
#       At the date of writing these commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
# 內存達到上限後的處理策略
# maxmemory-policy noeviction

APPEND ONLY模式 aof配置

# 默認是不開啓aof模式的,默認是RDB持久化,大部分情況下,rdb夠用
appendonly no

# The name of the append only file (default: "appendonly.aof")
# aof持久化的文件名
appendfilename "appendonly.aof"

# If unsure, use "everysec".

#每次持久化都會sync,消耗性能
# appendfsync always
#每秒執行sync,可能會丟失這一秒的數據
appendfsync everysec
# 永不sync,這個時候操作系統自己去執行同步,速度最快!
# appendfsync no
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章