Redis配置文件redis.conf详解

# 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 => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# 配置大小单位,只支持bytes,不支持bit。
# 对大小写不敏感,即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 servers but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
# 在此处包含一个或多个其他配置文件。如果你有一个标准的模板,它可以连接到所有的redis服务器,但也需要自定义每个服务器的一些设置。包含文件可以包括其他文件,所以要明智地使用它。
#
# 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.
# 注意选项“include”不会被命令“config rewrite”重写从admin或redis sentinel。因为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作为最后一行。
#
# 指定包含其它的配置文件,可以在同一主机上多个Redis实例之间使用同一份配置文件,而同时各个实例又拥有自己的特定配置文件
# 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.
# 默认情况下,redis不作为守护进程(即后台运行)启动。如果需要设置该项配合为yes
#
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# 若以守护进程启动,redis会在后台监控时在/var/run/redis.pid中写入一个pid文件。
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以守护进程启动时,默认会在/var/run/redis.pid路径下写入pid文件,可以通过该项设置pid文件位置
pidfile /var/run/redis.pid

# Accept connections on the specified port, default is 6379.
# 接收指定端口上的链接,默认端口是6379
#
# If port 0 is specified Redis will not listen on a TCP socket.
# 如果指定了端口0,Redis将不会在TCP套接字上侦听。
#
port 6379

# TCP listen() backlog.
#
# 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.
#
# backlog其实是一个连接队列,backlog队列总和=未完成三次握手队列 + 已经完成三次握手队列。在高并发环境下你需要一个高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”配置指令的接口,后跟一个或更多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.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 700

# Close the connection after a client is idle for N seconds (0 to disable)
# 客户端空闲n秒后关闭连接(0禁用),即一空闲就关闭 。
#
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 ACK发送到不存在的客户端沟通。这有两个原因:
#
# 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.
#  在Linux上,指定的值(以秒为单位)是用于发送ACK的周期。 
#
# Note that to close the connection the double of the time is needed.
# 请注意,要关闭连接,需要双倍的时间。
#
# On other kernels the period depends on the kernel configuration.
# 对于其他内核,周期取决于内核配置。 
#
# A reasonable value for this option is 60 seconds.
# 如果设置为0,则不会进行Keepalive检测,建议设置成60 
#
tcp-keepalive 60

# 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)
#  警告(只记录非常重要/关键的消息) 
#
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-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
# 设置数据库数。默认数据库是db 0,您可以选择使用select<dbid>在每个连接的基础上使用不同的连接,其中DBID是介于0和“databases”-1之间的数字
#
databases 16

################################ SNAPSHOTTING(快照)  ################################
#
# Save the DB on disk:
# 将数据库保存到磁盘上:
#
#   save <seconds> <changes>
#   语法:save 时间(s) 更改次数(get操作不计算在其中)
#
#   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
#	900秒(15分钟)后,如果至少更改了一个键
#
#   after 300 sec (5 min) if at least 10 keys changed
#	300秒(5分钟)后,如果至少更改了10个键 
#
#   after 60 sec if at least 10000 keys changed
#   3600秒(1小时)后,如果至少更改了10个键 
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#	注意:可以通过注释所有save配置来禁用快照
#
#   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指令来指向如下面的示例所示:
#
#   save ""

save 900 1
save 300 10
save 60 10000

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# 默认情况下,如果启用RDB快照,Redis将停止接受写操作(至少一个保存点)和最新的后台保存失败。
#
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
# 这将使用户(以硬方式)意识到数据没有持久化在磁盘上,否则很可能没有人会注意到灾难会发生。 
#
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
# 如果后台保存过程再次开始工作,Redis将自动允许再次写入。 
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
# 但是,如果您已经设置了对redis服务器的适当监视以及持久性,您可能希望禁用此功能,以便Redis即使磁盘有问题,也要照常工作。权限等等。
#
stop-writes-on-bgsave-error yes

# 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.
# 对于存储到磁盘中的快照,可以设置是否进行压缩存储。如果是的话,redis会采用LZF算法进行压缩。如果你不想消耗CPU来进行压缩的话,可以设置为no关闭此功能
#
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.
# 
#在存储快照后,还可以让redis使用CRC64算法来进行数据校验,但是这样做会增加大约10%的性能消耗,如果希望获取到最大的性能提升,可以设置为no关闭此功能
#
rdbchecksum yes

# The filename where to dump the DB
# 转储数据库的文件名
#
dbfilename dump.rdb


# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 数据库将写入此目录中,并指定文件名上面使用了“dbfilename”配置指令。
#
# The Append Only File will also be created inside this director
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值