Redis系列三(redis配置文件分析)

  在第一篇文章中有提到过redis.conf这个文件,这个文件就是redis-server的具体配置了。要使用好redis,一定要搞清楚redis的配置文件,这样才能最大的发挥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.

#是否已守护进程的方式运行,默认是否
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写入/var/run/redis.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-server监听的端口号,默认是6379端口
port 6379

 

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

#如果只想监听指定的ip,可以设置bind ip
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1

 

# Close the connection after a client is idle for N seconds (0 to disable)

# 客户端闲置后多少时间内断开连接,默认是0秒
timeout 0

 

# Specify the server verbosity level.
# This 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)

#日志的4个等级
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

#日志的名称
logfile ""

 

# 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内置分区数据库的数量 默认是16
databases 16

 

#
# Save the DB on disk:
#
# save <seconds> <changes>
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
#
# Note: you can disable saving at all commenting all the "save" lines.
#
# 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:
#
# save ""

#设置保存数据到磁盘上的策略默认是

# 900s 内有一个key改变/300s内有10个keys改变/60s内有10000个keys改变

save 900 1
save 300 10
save 60 10000

 

# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.

#rdb开启压缩
rdbcompression yes

 

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes

# The filename where to dump the DB

#rdb 默认名称dump.rdb
dbfilename "dump.rdb"

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.

#rdb文件路径
dir "/usr/redis"

 

################################# REPLICATION #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
#

#这个是主从复制功能,这里可以配置多个从redis数据库
# slaveof <masterip> <masterport>

 

If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
#

#设置连接到主redis的密码
# masterauth <master-password>

 

# When a slave loses its connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
#
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
# still reply to client requests, possibly with out of date data, or the
# data set may just be empty if this is the first synchronization.
#
# 2) if slave-serve-stale-data is set to 'no' the slave will reply with
# an error "SYNC with master in progress" to all the kind of commands
# but to INFO and SLAVEOF.
#

#当主从中间连接断开时的策略,如果设置为yes,从redis继续相应客户端请求。
slave-serve-stale-data yes

 

# You can configure a slave instance to accept writes or not. Writing against
# a slave instance may be useful to store some ephemeral data (because data
# written on a slave will be easily deleted after resync with the master) but
# may also cause problems if clients are writing to it because of a
# misconfiguration.
#
# Since Redis 2.6 by default slaves are read-only.
#
# Note: read only slaves are not designed to be exposed to untrusted clients
# on the internet. It's just a protection layer against misuse of the instance.
# Still a read only slave exports by default all the administrative commands
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
# security of read only slaves using 'rename-command' to shadow all the
# administrative / dangerous commands.

#2.6之后从redis只能是只读的
slave-read-only yes

 

# Slaves send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_slave_period option. The default value is 10
# seconds.
#

#从redis发送ping命令到主redis的时间间隔,默认是10秒
# repl-ping-slave-period 10

# The slave priority is an integer number published by Redis in the INFO output.
# It is used by Redis Sentinel in order to select a slave to promote into a
# master if the master is no longer working correctly.
#
# A slave with a low priority number is considered better for promotion, so
# for instance if there are three slaves with priority 10, 100, 25 Sentinel will
# pick the one with priority 10, that is the lowest.
#
# However a special priority of 0 marks the slave as not able to perform the
# role of master, so a slave with priority of 0 will never be selected by
# Redis Sentinel for promotion.
#
# By default the priority is 100.

#如果主redis挂掉,将从新推选出一个主,这个权重高的当选.
slave-priority 100

 

# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# Please check http://redis.io/topics/persistence for more information.

#AOF 模式 ,redis默认采用的是RDB模式

#http://redis.readthedocs.org/en/latest/topic/persistence.html两种持久化的比较

appendonly no

 

# The name of the append only file (default: "appendonly.aof")
# appendfilename appendonly.aof

 

posted @ 2015-04-08 14:54  gogo_baby  阅读(349)  评论(0编辑  收藏  举报