Redis --redis.conf详解

redis.conf详解redis

# 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不会在后台一直运行。若是你须要它一直运行,修改以下参数为 'yes'
#注意:'yes'状况下,redis会写一个pid(进程标识符)文件到 /var/run/redis.pid下面。
daemonize no

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
#你能够指定一个自定义的pid文件在这里
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.
#redis默认的监听端口是6379,咱们能够自定义监听端口
#若是设置监听端口为0,则redis再也不监听TCP链接
port 6379

# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#若是你绑定了IP,则redis监听该IP的链接;若是你不绑定,则它监听全部的链接
# 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.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755
# Close the connection after a client is idle for N seconds (0 to disable)
#设置客户端链接超时的时间,单位为秒,即 当客户端空闲的时间超过N秒后关闭链接
#0表示不指定超时时间
timeout 0

# Set server verbosity to 'debug'
# it 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)
#指定日志级别
#它是以下选项中的一个
#debug(记录不少信息,适用于开发/测试阶段)
#verbose(记录有用的信息,不像debug那样产生不少信息)
#notice(记录的信息比verbose少点,尽量输出你想要的信息,适用于上线运行阶段)
#warning(仅仅是很是重要的/紧急的信息被记录)
loglevel verbose

# Specify the log file name. Also 'stdout' 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
#指定log文件的地址,'stdout'常常被使用
#redis会执行标准的输出,当后台进程一直运行时,redis将输出 /dev/null
logfile stdout

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
#当以下参数设置成yse的时候,redis会记录系统日志,你也能够修改系统日志参数来知足你的须要
# syslog-enabled no

# Specify the syslog identity.
#指定日志标识符
# syslog-ident redis

# Specify the syslog facility.  Must be USER or between LOCAL0-LOCAL7.
#指定系统设备,必须是USER或是LOCAL0-LOCAL7之间的值
# 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
#设置数据库的个数
#默认是数据库是DB0,你能够在每个链接上使用 select<dbid>来选择一个不一样的数据库
#可是dbid的数字位于 0 ~ databased-1 之间
databases 16

###########快照###########
保存数据到磁盘  
格式:save<间隔时间(S)> <写入次数>  
根据给定的时间间隔和写入操做次数将数据保存到磁盘  
示例:  
900秒后至少有1个key值发生变化,则保存  
300秒后至少有10个key值发生变化,则保存  
60秒后至少有1000个key值发生变化,则保存  
save 900 1  
save 300 10  
save 60 10000  
备注:若是注释掉,则不作内存数据持久化;若是是将redis做为cache使用,则不须要开启持久化功能。  

在进行镜像备份时,是否使用LZF压缩  
rdbcompression yes  

镜像备份文件的文件名  
dbfilename dump.rdb  

数据镜像备份文件存放的路径,数据将写入到这个目录,使用上述defilename名字。固然依赖文件也将被建立在这个目录。注意这里你是指定一个目录路径,而不是一个文件名称。  
dir ./  

#############主从复制############  
主从复制。使用从服务去产生一个实例,该实例是redis服务的复制版本。使用从服务通常是保存数据或是监听端口等。  
#设置该数据库为其它主数据库的从
# slaveof <masterip> <masterport>  

#指定与主数据库链接时须要的密码验证  
# masterauth <master-password>  

当slave失去与master的链接,或slave一直与master进行复制工做时,  
slave有以下两种方式响应客户端请求:  
1>slave-serve-stale-data yes 时(默认状况),从数据库将一直响应客户端请求,可能数据过时了或者数据为空。  
2>slave-serve-stale-data no时,从数据库将响应错误信息指令 SYNC with master in progress,info和slaveof指令除外。  
#slave-serve-stale-data yes  

当slave与master失联时,它每隔 10s(默认是10S,咱们能够指定其它时间) ping master。  
# repl-ping-slave-period 10  

设置超时时间,这个时间必须大于repl-ping-slave-period值  
# repl-timeout 60  

###########安全#############  
#设置链接主数据库的 密码  
# requirepass foobared  

############ 限制 ###########
相关文章
相关标签/搜索