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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章