Redis的配置文件

本文介绍了Redis配置文件的位置及查看、编辑方法,通过cat、vi或vim命令操作redis.conf,欢迎大家指正。
摘要由CSDN通过智能技术生成

Redis的配置在redis的安装目录下的redis.conf中,如下所示

使用命令cat redis.conf 进行查看,vi redis.conf 或者vim redis.conf进行编辑

文件内容如下:

# Redis configuration file example.
# Redis配置
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first arguiment:
# 为了读取这个配置文件,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”不会被来自admin或redis sentinel的命令“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 /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 loopback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
# 如果运行redis的计算机直接暴露在Internet上,绑定到所有接口是危险的,并且会将实例暴露给Internet
# 上的每个人。因此,默认情况下,我们取消对以下绑定指令的注释,这将强制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.
#
# 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.
#
# 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.
#
# 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.
# 保护模式是一个为了避免在Internet上打开的Redis实例被访问和利用的安全保护。
# 当保护模式打开时,如果:
# 1)服务器没有使用“bind”指令显式绑定到一组地址。
# 2)未配置密码。
# 服务器只接受来自从IPv4和IPv6环回地址127.0.0.1和::1连接的客户端以及来自Unix域套接字的连接。
# 默认情况下启用保护模式。只有当您确定希望来自其他主机的客户机连接到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(IANA 815344)。如果指定了端口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.
# 在每秒高请求数的环境中,为了避免客户机连接速度慢的问题,您需要大量积压工作。请注意,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.
# 如果非零,则使用so-keepalive在没有通信的情况下向客户机发送TCP ACK。这有两个原因:
# 1)检测死点。
# 2)从中间网络设备的角度,将连接激活。
# 在Linux上,指定的值(以秒为单位)是用于发送ACK的周期。请注意,要关闭连接,需要双倍的时间。对于
# 其他内核,周期取决于内核配置。
# 此选项的合理值为300秒,这个新的Redis默认值是从Redis 3.2.1开始的。
tcp-keepalive 300

################################# 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不作为守护进程运行。如果需要,请设置“yes”。注意,redis会在后台监控时
# 在/var/run/redis.pid中写入一个pid文件。
daemonize no

# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
#   supervised no      - no supervision interaction
#   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
#   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
#   supervised auto    - detect upstart or systemd method based on
#                        UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
#       They do not enable continuous liveness pings back to your supervisor.
# 可以通过upstart和systemd管理Redis守护进程选项:
#  supervised no - 没有监督互动
#  supervised upstart - 通过将Redis置于SIGSTOP模式来启动信号
#  supervised systemd - signal systemd将READY = 1写入$ NOTIFY_SOCKET
#  supervised auto - 检测upstart或systemd方法基于 UPSTART_JOB或NOTIFY_SOCKET环境变量
# 注意:这些监督方法只会发出“过程准备就绪”的信号。它们不能持续向监督者发送心跳。
supervised no

# If a pid file is specified, Redis writes it where specified at startup
# and removes it at exit.
# 如果指定了PID文件,redis会将其写入启动时指定的位置,并在退出时将其删除
#
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
# is used even if not specified, defaulting to "/var/run/redis.pid".
# 当服务器运行非守护进程时,如果配置中未指定任何PID文件,则不会创建任何PID文件。当服务器被监控
# 时,即使没有指定PID文件,也会使用它,默认为“/var/run/redis.pid”。
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
# 创建一个pid文件是最好的。如果redis不创建它,在没有坏事发生的情况下,服务器也能够正常启动和运
# 行。
pidfile /var/run/redis_6379.pid

# 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

# By default Redis shows an ASCII art logo only when started to log to the
# standard output and if the standard output is a TTY. Basically this means
# that normally a logo is displayed only in interactive sessions.
# 默认情况下,仅在开始记录到标准输出以及标准输出是TTY时,redis显示一个ascii art的标识。基本上意味
# 着一个标识通常只在交互式会话中显示。
#
# However it is possible to force the pre-4.0 behavior and always show a
# ASCII art logo in startup logs by setting the following option to yes.
# 但是,通过将以下选项设置为“yes”,可以强制4.0之前的行为并始终在启动日志中显示ASCII ART标识。
always-show-logo yes

################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
# 
#   save <seconds> <changes>
# 将数据库保存到磁盘使用save命令, 格式为save 秒数 改变数
#
#   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
#   在下面的示例中,行为将保存:
#   900秒(15分钟)后,如果至少更改了一个键
#   300秒(5分钟)后,如果至少更改了10个键
#   60秒后,如果至少10000个键发生了变化
#
#   Note: you can disable saving completely by commenting out all "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指令来删除以前配置的所有保存点,如下例所示:
#
#   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.
# 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.
# 默认情况下,如果启用了RDB快照(至少一个保存点),当最新的后台保存失败时,Redis将停止接受写操
# 作。这将(以一种强硬的方式)使用户意识到数据没有正确地保存在磁盘上,否则很可能没有人会注意到,
# 进而发生一些灾难。
#
# 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.
# 在转储.rdb数据库时使用lzf压缩字符串对象?默认设置为“yes”,因为这几乎总是正确的。如果要在保存子
# 级中保存一些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的版本5,CRC64校验和被放置在文件的末尾。这使得格式更容易被破坏,但是在保存和加载RDB文件
# 时,性能会受到影响(大约10%),因此您可以禁用它以获得最佳性能。
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
# 禁用校验和创建的RDB文件的校验和为零,它将告诉加载代码跳过检查.
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.
# 数据库将使用上面指定的文件名,使用'db filename'配置指令写入此目录。
#
# The Append Only File will also be created inside this directory.
# 追加的文件也将在此目录中创建。
#
# Note that you must specify a directory here, not a file name.
# 请注意,必须在此处指定目录,而不是文件名。
dir ./

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

# Master-Replica replication. Use replicaof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replication.
#
#   +------------------+      +---------------+
#   |      Master      | ---> |    Replica    |
#   | (receive writes) |      |  (exact copy) |
#   +------------------+      +---------------+
#
# 1) Redis replication is asynchronous, but you can configure a master to
#    stop accepting writes if it appears to be not connected with at least
#    a given number of replicas.
# 2) Redis replicas are able to perform a partial resynchronization with the
#    master if the replication link is lost for a relatively small amount of
#    time. You may want to configure the replication backlog size (see the next
#    sections of this file) with a sensible value depending on your needs.
# 3) Replication is automatic and does not need user intervention. After a
#    network partition replicas automatically try to reconnect to masters
#    and resynchronize with them.
#
# 主从复制。使用replicoaf将redis实例制作为另一个redis服务器的从机。关于redis复制的一些需要尽
# 快理解的事情。
# 1)redis复制是异步的,但是您可以配置一个主机,使其在看起来至少与给定数量的从机没有连接时停止接
# 受写操作。
# 2)如果复制链路丢失的时间相对较短,Redis从机可以与主机进行部分再同步。根据需要,您可能需要使用
# 合理的值配置复制积压工作的大小(请参阅此文件的下一节)。
# 3)复制是自动的,不需要用户干预。从机会自动尝试重新连接到主机,并与主机重新同步之后,在网络分区
# 复制。
# replicaof <masterip> <masterport>

# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the replica to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the replica request.
# 如果主机受密码保护(使用下面的“RequirePass”配置指令),则可以在启动复制同步过程之前通知从机进
# 行身份验证,否则主机将拒绝从机请求。
#
# masterauth <master-password>

# When a replica loses its connection with the master, or when the replication
# is still in progress, the replica can act in two different ways:
# 当从机失去与主机的连接或复制仍在进行时,从机可以以两种不同的方式进行操作:
#
# 1) if replica-serve-stale-data is set to 'yes' (the default) the replica 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.
# 1)如果replica-serve-stale-data设置为“yes”(默认值),则从机仍将答复客户端请求,可能数据
# 已过期,或者如果这是第一次同步,则数据集可能为空。
#
# 2) if replica-serve-stale-data is set to 'no' the replica will reply with
#    an error "SYNC with master in progress" to all the kind o
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值