redis配置参数作用和大概行数(长期记录)

长期记录使用redis过程中遇到的配置参数以及作用和大概位置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
################################## NETWORK #####################################
47
48 # By default, if no "bind" configuration directive is specified, Redis listens
49 # for connections from all the network interfaces available on the server.
50 # It is possible to listen to just one or multiple selected interfaces using
51 # the "bind" configuration directive, followed by one or more IP addresses.
52 #
53 # Examples:
54 #
55 # bind 192.168.1.100 10.0.0.1
56 # bind 127.0.0.1 ::1
57 #
58 # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
59 # internet, binding to all the interfaces is dangerous and will expose the
60 # instance to everybody on the internet. So by default we uncomment the
61 # following bind directive, that will force Redis to listen only into
62 # the IPv4 loopback interface address (this means Redis will be able to
63 # accept connections only from clients running into the same computer it
64 # is running).
65 #
66 # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
67 # JUST COMMENT THE FOLLOWING LINE.
68 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

69 bind 127.0.0.1 # 监听来自哪个IP的的连接,默认为127.0.0.1只监听本机进程的访问,注释掉之后可以监听所有IP的连接。
1
2
3
4
5
6
85 # By default protected mode is enabled. You should disable it only if
86 # you are sure you want clients from other hosts to connect to Redis
87 # even if no authentication is configured, nor a specific set of interfaces
88 # are explicitly listed using the "bind" directive.

89 protected-mode yes # 保护模式是否开启,默认为开启,开启之后不允许其他IP访问,设置为no可以让非本机IP访问该redis
1
2
3
4
91 # Accept connections on the specified port, default is 6379 (IANA #815344).
92 # If port 0 is specified Redis will not listen on a TCP socket.

93 port 6379 # 设置redis的端口号,默认为6379
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
################################ SNAPSHOTTING  ################################
198 #
199 # Save the DB on disk:
200 #
201 # save <seconds> <changes>
202 #
203 # Will save the DB if both the given number of seconds and the given
204 # number of write operations against the DB occurred.
205 #
206 # In the example below the behaviour will be to save:
207 # after 900 sec (15 min) if at least 1 key changed
208 # after 300 sec (5 min) if at least 10 keys changed
209 # after 60 sec if at least 10000 keys changed
210 #
211 # Note: you can disable saving completely by commenting out all "save" lines.
212 #
213 # It is also possible to remove all the previously configured save
214 # points by adding a save directive with a single empty string argument
215 # like in the following example:
216 #
217 # save ""
218 # 备份策略,可自定义
219 save 900 1 # 如果在900秒内至少进行了1次写操作,则进行RDB备份
220 save 300 10 # 如果在300秒内至少进行了10次写操作,则进行RDB备份
221 save 60 10000 # 如果在60秒内至少进行了一万次操作,则进行RDB备份
1
2
3
252 # The filename where to dump the DB

253 dbfilename dump.rdb # RDB备份文件的名字
1
2
3
4
5
6
7
8
9
10
255 # The working directory.
256 #
257 # The DB will be written inside this directory, with the filename specified
258 # above using the 'dbfilename' configuration directive.
259 #
260 # The Append Only File will also be created inside this directory.
261 #
262 # Note that you must specify a directory here, not a file name.

263 dir ./ # RDB备份存放的位置,默认为redis.conf下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
679 ############################## APPEND ONLY MODE ###############################
680
681 # By default Redis asynchronously dumps the dataset on disk. This mode is
682 # good enough in many applications, but an issue with the Redis process or
683 # a power outage may result into a few minutes of writes lost (depending on
684 # the configured save points).
685 #
686 # The Append Only File is an alternative persistence mode that provides
687 # much better durability. For instance using the default data fsync policy
688 # (see later in the config file) Redis can lose just one second of writes in a
689 # dramatic event like a server power outage, or a single write if something
690 # wrong with the Redis process itself happens, but the operating system is
691 # still running correctly.
692 #
693 # AOF and RDB persistence can be enabled at the same time without problems.
694 # If the AOF is enabled on startup Redis will load the AOF, that is the file
695 # with the better durability guarantees.
696 #
697 # Please check http://redis.io/topics/persistence for more information.
698
699 appendonly no # 是否开启AOF备份,默认不开启
1
2
3
701 # The name of the append only file (default: "appendonly.aof")
702
703 appendfilename "appendonly.aof" # 设置AOF备份的文件名
1
2
3
4
5
6
726 # If unsure, use "everysec".
727
# 同步策略
728 # appendfsync always # 一有写操作,就立即同步
729 appendfsync everysec # 每秒进行一次同步,默认策略
730 # appendfsync no # redis不处理同步,让OS来进行同步
1
2
3
4
5
767 # Specify a percentage of zero in order to disable the automatic AOF
768 # rewrite feature.
769
770 auto-aof-rewrite-percentage 100 # 当前文件大小超过上一次重写后文件大小的1倍时进行重写
771 auto-aof-rewrite-min-size 64mb # 当文件大小达到设定值时进行重写,第一次达到时执行,后续根据percentage策略执行
1
2
3
4
5
562 # In short... if you have replicas attached it is suggested that you set a lower
563 # limit for maxmemory so that there is some free RAM on the system for replica
564 # output buffers (but this is not needed if the policy is 'noeviction').
565 #
566 # maxmemory <bytes> # 设置redis缓存大小,默认为0,表示没有限制,如果内存已满,则不再缓存数据
1
2
3
595 # The default is:
596 #
597 # maxmemory-policy noeviction # 设置淘汰策略,当缓存不足时将进行根据设置的策略进行淘汰