您的位置:首页 > 数据库 > Redis

redis怎么动态添加内存,动态配置,无需重启。

2015-01-18 22:43 585 查看
在redis的使用过程中,有时候需要急需修改redis的配置,比如在业务运行的情况下,内存不够怎么办,这时要么赶紧删除无用的内存,要么扩展内存。如果有无用的内容可删除那么所有问题都已经解决。如果内容都是重要的,那只能选择扩展内存。说到扩展内存,redis为我们提供了一个命令。

CONFIG SET

CONFIG SET parameter value

CONFIG SET 命令可以动态地调整 Redis 服务器的配置(configuration)而无须重启。

你可以使用它修改配置参数,或者改变 Redis 的持久化(Persistence)方式。

CONFIG SET 可以修改的配置参数可以使用命令 CONFIG GET * 来列出,所有被 CONFIG SET 修改的配置参数都会立即生效。

关于 CONFIG SET 命令的更多消息,请参见命令 CONFIG GET 的说明。

关于如何使用 CONFIG SET 命令修改 Redis 持久化方式,请参见 Redis Persistence

可用版本:>= 2.0.0时间复杂度:不明确返回值:当设置成功时返回 OK ,否则返回一个错误。
例如:动态添加内存

redis 127.0.0.1:6379> config get maxmemory
1) "maxmemory"
2) "3221225472"
redis 127.0.0.1:6379> config set maxmemory 4294967296
OK
redis 127.0.0.1:6379> config get maxmemory
1) "maxmemory"
2) "4294967296"


我们看看那些参数 redis可以动态设置

redis 127.0.0.1:6379> config get *
1) "dbfilename"
2) "dump.rdb"
3) "requirepass"
4) ""
5) "masterauth"
6) ""
7) "bind"
8) ""
9) "unixsocket"
10) ""
11) "logfile"
12) ""
13) "pidfile"
14) "/usr/local/redis/var/run/redis.pid"
15) "maxmemory"
16) "4294967296"
17) "maxmemory-samples"
18) "3"
19) "timeout"
20) "0"
21) "tcp-keepalive"
22) "60"
23) "auto-aof-rewrite-percentage"
24) "100"
25) "auto-aof-rewrite-min-size"
26) "67108864"
27) "hash-max-ziplist-entries"
28) "512"
29) "hash-max-ziplist-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) "zset-max-ziplist-entries"
38) "128"
39) "zset-max-ziplist-value"
40) "64"
41) "lua-time-limit"
42) "5000"
43) "slowlog-log-slower-than"
44) "10000"
45) "slowlog-max-len"
46) "128"
47) "port"
48) "6379"
49) "databases"
50) "32"
51) "repl-ping-slave-period"
52) "10"
53) "repl-timeout"
54) "60"
55) "maxclients"
56) "10000"
57) "watchdog-period"
58) "0"
59) "slave-priority"
60) "100"
61) "hz"
62) "10"
63) "no-appendfsync-on-rewrite"
64) "no"
65) "slave-serve-stale-data"
66) "yes"
67) "slave-read-only"
68) "yes"
69) "stop-writes-on-bgsave-error"
70) "yes"
71) "daemonize"
72) "yes"
73) "rdbcompression"
74) "yes"
75) "rdbchecksum"
76) "yes"
77) "activerehashing"
78) "yes"
79) "repl-disable-tcp-nodelay"
80) "no"
81) "aof-rewrite-incremental-fsync"
82) "yes"
83) "appendonly"
84) "no"
85) "dir"
86) "/usr/local/redis/db"
87) "maxmemory-policy"
88) "volatile-lru"
89) "appendfsync"
90) "everysec"
91) "save"
92) "900 1 300 10 60 10000"
93) "loglevel"
94) "notice"
95) "client-output-buffer-limit"
96) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
97) "unixsocketperm"
98) "0"
99) "slaveof"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: