2 #
3 # Note that in order to read the configuration file, Redis must be
4 # started with the file path as first argument:
5 #
6 # ./redis-server /path/to/redis.conf
7
8 # Note on units: when memory size is needed, it is possible to specify
9 # it in the usual form of 1k 5GB 4M and so forth:
10 #
11 # 1k => 1000 bytes(只支持bytes,不支持bit)
12 # 1kb => 1024 bytes
13 # 1m => 1000000 bytes
14 # 1mb => 1024*1024 bytes
15 # 1g => 1000000000 bytes
16 # 1gb => 1024*1024*1024 bytes
17 #
18 # units are case insensitive so 1GB 1Gb 1gB are all the same.(大小写不敏感)
################################## INCLUDES ###################################
21
22 # Include one or more other config files here. This is useful if you
23 # have a standard template that goes to all Redis servers but also need
24 # to customize a few per-server settings. Include files can include
25 # other files, so use this wisely.
26 #
27 # Notice option "include" won't be rewritten by command "CONFIG REWRITE"
28 # from admin or Redis Sentinel. Since Redis always uses the last processed
29 # line as value of a configuration directive, you'd better put includes
30 # at the beginning of this file to avoid overwriting config change at runtime.
31 #
32 # If instead you are interested in using includes to override configuration
33 # options, it is better to use include as the last line.
34 #
35 # include /path/to/local.conf
36 # include /path/to/other.conf(可以包含其他配置文件)
################################## NETWORK #####################################
39
40 # By default, if no "bind" configuration directive is specified, Redis listens
41 # for connections from all the network interfaces available on the server.
42 # It is possible to listen to just one or multiple selected interfaces using
43 # the "bind" configuration directive, followed by one or more IP addresses.
44 #
45 # Examples:
46 #
47 # bind 192.168.1.100 10.0.0.1
48 # bind 127.0.0.1 ::1
49 #
50 # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
51 # internet, binding to all the interfaces is dangerous and will expose the
52 # instance to everybody on the internet. So by default we uncomment the
53 # following bind directive, that will force Redis to listen only into
54 # the IPv4 lookback interface address (this means Redis will be able to
55 # accept connections only from clients running into the same computer it
56 # is running).
57 #
58 # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
59 # JUST COMMENT THE FOLLOWING LINE.
60 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 bind 127.0.0.1
62
63 # Protected mode is a layer of security protection, in order to avoid that
64 # Redis instances left open on the internet are accessed and exploited.
65 #
66 # When protected mode is on and if:
67 #
68 # 1) The server is not binding explicitly to a set of addresses using the
69 # "bind" directive.
70 # 2) No password is configured.
71 #
72 # The server only accepts connections from clients connecting from the
73 # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
74 # sockets.
75 #
76 # By default protected mode is enabled. You should disable it only if
77 # you are sure you want clients from other hosts to connect to Redis
78 # even if no authentication is configured, nor a specific set of interfaces
79 # are explicitly listed using the "bind" directive.
80 protected-mode yes
81
82 # Accept connections on the specified port, default is 6379 (IANA #815344).
83 # If port 0 is specified Redis will not listen on a TCP socket.
84 port 6379
85
86 # TCP listen() backlog.
87 #
88 # In high requests-per-second environments you need an high backlog in order
89 # to avoid slow clients connections issues. Note that the Linux kernel
90 # will silently truncate it to the value of /proc/sys/net/core/somaxconn so
91 # make sure to raise both the value of somaxconn and tcp_max_syn_backlog
92 # in order to get the desired effect.
93 tcp-backlog 511(设置TCP的backlog,backlog 其实是一个连接队列)
94
95 # Unix socket.
96 #
97 # Specify the path for the Unix socket that will be used to listen for
98 # incoming connections. There is no default, so Redis will not listen
99 # on a unix socket when not specified.
100 #
101 # unixsocket /tmp/redis.sock
102 # unixsocketperm 700
103
104 # Close the connection after a client is idle for N seconds (0 to disable)
105 timeout 0(关闭连接时间,0时不关闭)
106
107 # TCP keepalive.
108 #
109 # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
110 # of communication. This is useful for two reasons:
111 #
112 # 1) Detect dead peers.
113 # 2) Take the connection alive from the point of view of network
114 # equipment in the middle.
115 #
116 # On Linux, the specified value (in seconds) is the period used to send ACKs.
117 # Note that to close the connection the double of the time is needed.
118 # On other kernels the period depends on the kernel configuration.
119 #
120 # A reasonable value for this option is 300 seconds, which is the new
121 # Redis default starting with Redis 3.2.1.
122 tcp-keepalive 300(检测tcp是否或者,单位为秒,如果设置为零,不进行检测,建议设置成60)
123
################################# GENERAL #####################################
125
126 # By default Redis does not run as a daemon. Use 'yes' if you need it.
127 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
128 daemonize yes(后台运行。默认是no)
129
130 # If you run Redis from upstart or systemd, Redis can interact with your
131 # supervision tree. Options:
132 # supervised no - no supervision interaction
133 # supervised upstart - signal upstart by putting Redis into SIGSTOP mode
134 # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
135 # supervised auto - detect upstart or systemd method based on
136 # UPSTART_JOB or NOTIFY_SOCKET environment variables
137 # Note: these supervision methods only signal "process is ready."
138 # They do not enable continuous liveness pings back to your supervisor.
139 supervised no
140
141 # If a pid file is specified, Redis writes it where specified at startup
142 # and removes it at exit.
143 #
144 # When the server runs non daemonized, no pid file is created if none is
145 # specified in the configuration. When the server is daemonized, the pid file
146 # is used even if not specified, defaulting to "/var/run/redis.pid".
147 #
148 # Creating a pid file is best effort: if Redis is not able to create it
149 # nothing bad happens, the server will start and run normally.
150 pidfile /var/run/redis_6379.pid
151
152 # Specify the server verbosity level.
153 # This can be one of:
154 # debug (a lot of information, useful for development/testing)
155 # verbose (many rarely useful info, but not a mess like the debug level)
156 # notice (moderately verbose, what you want in production probably)
157 # warning (only very important / critical messages are logged)
158 loglevel notice(日志级别)
159
160 # Specify the log file name. Also the empty string can be used to force
161 # Redis to log on the standard output. Note that if you use standard
162 # output for logging but daemonize, logs will be sent to /dev/null
163 logfile ""(日志文件的名字)
164
165 # To enable logging to the system logger, just set 'syslog-enabled' to yes,
166 # and optionally update the other syslog parameters to suit your needs.
167 # syslog-enabled no(系统日志)
168
169 # Specify the syslog identity.
170 # syslog-ident redis(日志标识)
171
172 # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
173 # syslog-facility local0(指定syslog设备)
174
175 # Set the number of databases. The default database is DB 0, you can select
176 # a different one on a per-connection basis using SELECT <dbid> where
177 # dbid is a number between 0 and 'databases'-1
178 databases 16(默认数据库个数,默认使用0号库)