Redis使用config命令,可以对配置项参数热修改,不必重启。
Redis最好不要重启,重启一次会引发如下问题:
- 如果数据很多(例如几个G),读起来很慢;
- 重启风险很大,Redis有内存陷阱
- 重启会引发读快照,读AOF文件
使用config get *
获得所有的配置项的key
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| 127.0.0.1:6379> CONFIG GET * 1) "dir" 2) "/var/lib/redis" 3) "dbfilename" 4) "dump.rdb" 5) "requirepass" 6) (nil) 7) "masterauth" 8) (nil) 9) "maxmemory" 10) "0" 11) "maxmemory-policy" 12) "volatile-lru" 13) "maxmemory-samples" 14) "3" 15) "timeout" 16) "300" 17) "appendonly" 18) "no" 19) "no-appendfsync-on-rewrite" 20) "no" 21) "appendfsync" 22) "everysec" 23) "save" 24) "900 1 300 10 60 10000" 25) "slave-serve-stale-data" 26) "yes" 27) "hash-max-zipmap-entries" 28) "512" 29) "hash-max-zipmap-value" 30) "64" 31) "list-max-ziplist-entries" 32) "512" 33) "list-max-ziplist-value" 34) "64" 35) "set-max-intset-entries" 36) "512" 37) "slowlog-log-slower-than" 38) "10000" 39) "slowlog-max-len" 40) "64"
|
更改redis持久化设置
1 2
| 127.0.0.1:6379> CONFIG SET save "9000 10 3000 100 600 100000" OK
|
再次查看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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| 127.0.0.1:6379> CONFIG GET * 1) "dir" 2) "/var/lib/redis" 3) "dbfilename" 4) "dump.rdb" 5) "requirepass" 6) (nil) 7) "masterauth" 8) (nil) 9) "maxmemory" 10) "0" 11) "maxmemory-policy" 12) "volatile-lru" 13) "maxmemory-samples" 14) "3" 15) "timeout" 16) "300" 17) "appendonly" 18) "no" 19) "no-appendfsync-on-rewrite" 20) "no" 21) "appendfsync" 22) "everysec" 23) "save" 24) "9000 10 3000 100 600 100000" 25) "slave-serve-stale-data" 26) "yes" 27) "hash-max-zipmap-entries" 28) "512" 29) "hash-max-zipmap-value" 30) "64" 31) "list-max-ziplist-entries" 32) "512" 33) "list-max-ziplist-value" 34) "64" 35) "set-max-intset-entries" 36) "512" 37) "slowlog-log-slower-than" 38) "10000" 39) "slowlog-max-len" 40) "64"
|