Redis Configuration
The Redis configuration file is located in the Redis installation directory, named redis.conf
(Windows: redis.windows.conf
).
You can view or set configuration items using the CONFIG command.
Syntax
The Redis CONFIG command format is as follows:
redis 127.0.0.1:6379> CONFIG GET CONFIG_SETTING_NAME
Example
redis 127.0.0.1:6379> CONFIG GET loglevel
1) "loglevel"
2) "notice"
Use the asterisk (*) to get all configuration items:
Example
redis 127.0.0.1:6379> CONFIG GET *
1) "dbfilename"
2) "dump.rdb"
3) "requirepass"
4) ""
5) "masterauth"
6) ""
7) "unixsocket"
8) ""
9) "logfile"
10) ""
11) "pidfile"
12) "/var/run/redis.pid"
13) "maxmemory"
14) "0"
15) "maxmemory-samples"
16) "3"
17) "timeout"
18) "0"
19) "tcp-keepalive"
20) "0"
21) "auto-aof-rewrite-percentage"
22) "100"
23) "auto-aof-rewrite-min-size"
24) "67108864"
25) "hash-max-ziplist-entries"
26) "512"
27) "hash-max-ziplist-value"
28) "64"
29) "list-max-ziplist-entries"
30) "512"
31) "list-max-ziplist-value"
32) "64"
33) "set-max-intset-entries"
34) "512"
35) "zset-max-ziplist-entries"
36) "128"
37) "zset-max-ziplist-value"
38) "64"
39) "hll-sparse-max-bytes"
40) "3000"
41) "lua-time-limit"
42) "5000"
43) "slowlog-log-slower-than"
44) "10000"
45) "latency-monitor-threshold"
46) "0"
47) "slowlog-max-len"
48) "128"
49) "port"
50) "6379"
51) "tcp-backlog"
52) "511"
53) "databases"
54) "16"
55) "repl-ping-slave-period"
56) "10"
57) "repl-timeout"
58) "60"
59) "repl-backlog-size"
60) "1048576"
61) "repl-backlog-ttl"
62) "3600"
63) "maxclients"
64) "4064"
65) "watchdog-period"
66) "0"
67) "slave-priority"
68) "100"
69) "min-slaves-to-write"
70) "0"
71) "min-slaves-max-lag"
72) "10"
73) "hz"
74) "10"
75) "no-appendfsync-on-rewrite"
76) "no"
77) "slave-serve-stale-data"
78) "yes"
79) "slave-read-only"
80) "yes"
81) "stop-writes-on-bgsave-error"
82) "yes"
83) "daemonize"
84) "no"
85) "rdbcompression"
86) "yes"
87) "rdbchecksum"
88) "yes"
89) "activerehashing"
90) "yes"
91) "repl-disable-tcp-nodelay"
92) "no"
93) "aof-rewrite-incremental-fsync"
94) "yes"
95) "appendonly"
96) "no"
97) "dir"
98) "/home/deepak/Downloads/redis-2.8.13/src"
99) "maxmemory-policy" 100) "volatile-lru" 101) "appendfsync" 102) "everysec" 103) "save" 104) "3600 1 300 100 60 10000" 105) "loglevel" 106) "notice" 107) "client-output-buffer-limit" 108) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60" 109) "unixsocketperm" 110) "0" 111) "slaveof" 112) "" 113) "notify-keyspace-events" 114) "" 115) "bind" 116) "" | 15 | requirepass foobared | Set Redis connection password. If a connection password is configured, clients need to provide the password via the AUTH <password> command when connecting to Redis. Default is disabled. | | 16 | maxclients 128 | Set the maximum number of client connections at the same time. Default is unlimited. Redis can open as many client connections as the maximum file descriptors the Redis process can open. If maxclients is set to 0, it means no limit. When the client connection limit is reached, Redis will close new connections and return a "max number of clients reached" error message. | | 17 | maxmemory <bytes> | Specify the maximum memory limit for Redis. Redis loads data into memory on startup. Once the maximum memory is reached, Redis will first attempt to clear expired or soon-to-expire keys. After this method, if the maximum memory setting is still reached, no more write operations can be performed, but read operations can still be done. Redis's new VM mechanism will store keys in memory and values in the swap area. | | 18 | appendonly no | Specify whether to log updates after each operation. By default, Redis asynchronously writes data to disk. If not enabled, it may lead to data loss during power outages. This is because Redis synchronizes data files according to the save conditions mentioned above, so some data may exist only in memory for a period of time. Default is no. | | 19 | appendfilename appendonly.aof | Specify the update log file name, default is appendonly.aof. | | 20 | appendfsync everysec | Specify the update log conditions, with 3 optional values: no: wait for the operating system to sync data to disk (fast) <br>always: manually call fsync() after each update operation to write data to disk (slow, safe) <br>everysec: sync once per second (compromise, default value). | | 21 | vm-enabled no | Specify whether to enable the virtual memory mechanism. Default is no. The VM mechanism stores data in pages, with Redis swapping less frequently accessed pages (cold data) to disk and frequently accessed pages automatically swapped back to memory. | | 22 | vm-swap-file /tmp/redis.swap | Virtual memory file path, default is /tmp/redis.swap, not shareable among multiple Redis instances. | | 23 | vm-max-memory 0 | Store all data larger than vm-max-memory in virtual memory. Regardless of how small vm-max-memory is set, all index data is stored in memory (Redis's index data are keys). This means when vm-max-memory is set to 0, all values exist on disk. Default is 0. | | 24 | vm-page-size 32 | Redis swap file is divided into many pages. An object can be stored on multiple pages, but a page cannot be shared by multiple objects. The vm-page-size should be set based on the size of the stored data. The author suggests setting the page size to 32 or 64 bytes if storing many small objects; if storing large objects, use a larger page size. If unsure, use the default value. | | 25 | vm-pages 134217728 | Set the number of pages in the swap file. The page table (a bitmap indicating page free or used status) is stored in memory, with every 8 pages consuming 1 byte of memory on disk. | | 26 | vm-max-threads 4 | Set the number of threads accessing the swap file. It's best not to exceed the number of cores on the machine. If set to 0, all operations on the swap file are serial, which may cause long delays. Default is 4. | | 27 | glueoutputbuf yes | Set whether to merge and send smaller packets to clients in response. Default is enabled. | | 28 | hash-max-zipmap-entries 64<br>hash-max-zipmap-value 512 | Specify to use a special hash algorithm when exceeding a certain number of entries or when the maximum element exceeds a certain threshold. | | 29 | activerehashing yes | Specify whether to activate rehashing. Default is enabled (will be explained in detail when introducing Redis's hash algorithms). 30 | include /path/to/local.conf | Specifies the inclusion of other configuration files, allowing multiple Redis instances on the same host to share the same configuration file while each instance also has its own specific configuration file.