# Redis configuration file example
# redis配置文件模板
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
# 参数单位使用须知:在需要对内存大小进行配置时,其通常可能以1k 5GB 4M等类似的形式进行指定
#
# 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.
# 对内存大小进行配置时,其单位不区分大小写,例如1Gb 1GB 1gB所代表的都是相同的大小
################################## INCLUDES ###################################
# Include one or more other config files here. This is useful if you
# have a standard template that goes to all Redis server but also need
# to customize a few per-server settings. Include files can include
# other files, so use this wisely.
# 此处用于包含一个或者多个配置文件。假如你在配置多个Redis时,绝大多数的配置相同,但每个
# Redis的配置还是有个体差异,这时你就适合使用include标签;通过把相同的配置定义成一个外
# 部公共模板,用include标签进行引入,以此来降低配置难度
#
# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
# 请注意,对于同一个配置项,Redis总是选择最后一行的配置生效;因此,如果你希望配置文件的
# 优先级高于模板文件,那么请在配置文件的第一行使用include
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
# 反之,如果你希望模板配置的优先级更高,那么就在配置文件的最后一行使用include
#
# include /path/to/local.conf
# include /path/to/other.conf
################################ GENERAL #####################################
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# Redis默认为非后台运行。当daemonize值为yes时,Redis将会在后台运行,其进程信息将会写入
# /var/run/redis.pid文件中;当daemonize值为no时,Redis将不采用后台运行
daemonize yes
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
# 当redis以后台程序形式运行时,redis的进程id会默认写入到/var/run/redis.pid文件张宏;在
# 此处你可以自定义需要进程id写入的文件及其路径
pidfile /var/run/redis.pid
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
# 此处定义连接端口,默认为6379;如果端口为0,那么Redis不会监听对应的TCP连接
port 6379
# TCP listen() backlog.
# TCP连接缓冲池
#
# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
# 在高并发环境下,需要通过缓冲池来防止出现客户端连接缓慢的问题。需要注意的是,Linux的内
# 核会通过/proc/sys/net/core/somaxconn和tcp_max_syn_backlog来影响到缓冲池的具体效果。
# 因此为了获得理想的效果,请提高somaxconn和tcp_max_syn_backlog的值
tcp-backlog 511
# By default Redis listens for connections from all the network interfaces
# available on the server. It is possible to listen to just one or multiple
# interfaces using the "bind" configuration directive, followed by one or
# more IP addresses.
# 默认情况下,Redis监听来自服务器所有可行接口的连接;可以通过bind标签使Redis只监听一个
# 或多个指定的IP地址;bind标签后可接一个或多个IP地址
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1
# Specify the path for the Unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
# unixsocker的路径指向的文件用于定义监听的连接;此设置项没有默认值,因此在没有定义的情
# 况下,redis会默认监听所有
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755
# Close the connection after a client is idle for N seconds (0 to disable)
# 当一个客户端已经断开n秒后,自动断开该连接(超时机制)
timeout 0
# TCP keepalive.
# TCP长连接
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
# 如果该配置值非零,则在不存在通信的情况下使用SO_KEEPALIVE向客户端发送TCP ACKs,原因
# 如下:
#
# 1) Detect dead peers.
# 检测连接是否死亡
# 2) Take the connection alive from the point of view of network
# equipment in the middle.
# 通过中间网络设备的角度,使该连接长期处于存活状态
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
# 在Linux中,通过指定的值(通常以秒为单位)定期向客户端发送ACKs,类似于心跳检测;需要注意
# 的是,如果要关闭连接则需要消耗该值的两倍的时间;在其他的内核上具体的单位以内核配置为准
#
# A reasonable value for this option is 60 seconds.
# 建议值为60
tcp-keepalive 0
# 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)
# verbose(简化debug级别的日志信息,包含少量有用信息)
# notice (moderately verbose, what you want in production probably)
# notice(通常用于生产环境)
# warning (only very important / critical messages are logged)
# warning(只记录重要的警告信息)
# 日志级别
loglevel notice
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
# 指定日志文件路径和名称;当为空字符串时,Redis将以默认地址进行输出;注意:如果使用标准
# 输出且以后台进程形式运行,默认输出到/dev/null
logfile ""
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled为yes时,日志将被写入到系统日志中;同时可以根据自己的需要有选择性的更新
# 其他的syslog参数
# syslog-enabled no
# Specify the syslog identity.
# 指定日志在系统日志中的标识
# syslog-ident redis
# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# 指定系统日志的设备;必须为某个用户,或者介于LOCAL0-LOCAL17
# syslog-facility local0
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
# 设置Redis数据库的数量;默认使用第0个Redis数据库,你可以在连接中使用SELECT <dbid>来
# 指定每一个连接究竟使用哪一个数据库
databases 16