redis動態添加內存,動態配置,無需重啟


在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"

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM