Redis配置 - 版本4.0.10

这里主要是解释一下redis的redis.conf文件中的配置信息。自己翻译+总结出来的,会不断更新的。

配置的顺序是按照redis.conf中的顺序。加粗高亮的是redis默认配置。

配置文件的说明



# Redis configuration file example. # # Note that in order to read the configuration file
, Redis must be # started with the file path as first argument: # [请注意,为了读取配置文件,Redis必须是以文件路径作为第一个参数开始:] # ./redis-server /path/to/redis.conf # 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 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”将不会被来自管理员或者Redis哨兵的“CONFIG REWRITE”所覆盖。 因为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] # include /path/to/local.conf # include /path/to/other.conf

 MODULES


# Load modules at startup. If the server is not able to load modules
# it will abort. It is possible to use multiple loadmodule directives.
# [在启动时加载模块。如果服务器无法加载模块,它将终止。可以使用多个loadmodule指令]
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so

NETWORK


 

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
# [默认情况下,如果没有配置“bind”指令,Redis会监听在服务器上来自所有可用网络接口的连接。
# 可以使用“bind”配置指令只监听一个或者多个选定的接口,然后是一个或者多个IP地址]
# Examples:
#    [例如:]
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
# [~~~ 警告 ~~~如果运行Redis的电脑直接暴露在互联网上,绑定所有的接口是危险的,
# 并且会将这个实例暴露给因特网上的所有人。因此,默认情况下,我们取消注释下面的bind指令,
# 这将强制Redis仅侦听IPv4回溯接口地址(这就意味着Redis将只能接受来自本机的客户端的连接)。]
# 
#    IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# 
# [如果你确定你想要你的实例监听所有的接口,只需要注释掉下面这一行]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#    [保护模式是一层安全保护,以避免在Internet上打开的Redis实例被访问和利用。]
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
# [当保护模式已经打开了,并且:
# 1) 服务器没有使用“bind”指令显示绑定到一组地址上。
# 2) 没有配置密码。]
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
# [服务器就只会接受来自IPv4和IPv6环回地址127.0.0.1和::1以及Unix域套接字的客户端连接。]
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
# [默认情况下,保护模式是开启的。你应该仅在下列情况下禁用它:
# 你确定希望来自其他主机的客户端连接到Redis,
# 即使未配置任何身份验证,也没有使用“bind”指令明确列出一组特定的接口]
protected-mode yes

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
# [接受指定端口上的连接,默认为6379.]
# [如果指定了端口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以避免缓慢的客户端连接问题。
# 注意,Linux内核会默认将其缩短至/proc/sys/net/core/somaxconn的值,
# 因此请确保同时提高somaxconn和tcp_max_syn_backlog的值以获得所需的效果。]
tcp-backlog 511

# Unix socket.
#
# 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.
# [指定将用于侦听传入连接的Unix套接字的路径。 
# 没有默认值,因此Redis在未指定时不会侦听unix套接字。]
# 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.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 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.
#
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
tcp-keepalive 300

 

posted on 2018-08-22 16:21  江城歌吹风流  阅读(230)  评论(0编辑  收藏  举报

导航