美文网首页redis
redis动态增加内存(不重启)

redis动态增加内存(不重启)

作者: 团长plus | 来源:发表于2018-07-11 10:35 被阅读47次

    在redis的使用过程中,有时候需要修改redis的配置,如在业务运行的情况下,内存不够怎么办,这时要么赶紧删除无用的内存,要么扩展内存。如果有无用的内容可删除那么所有问题都已经解决。如果内容都是重要的,那只能选择扩展内存。说到扩展内存,redis为我们提供了一个动态调整的命令。
    CONFIG SET (官网https://redis.io/commands/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 ,否则返回一个错误。

    例:动态添加内存 3G到10G
    1、获取当前值
    redis 127.0.0.1:6379> config get maxmemory

    1. "maxmemory"
    2. "3221225472"

    2、设置新数值
    redis 127.0.0.1:6379> config set maxmemory 10737418240
    OK

    3、查看修改后的值
    redis 127.0.0.1:6379> CONFIG GET maxmemory

    1. "maxmemory"
    2. "10737418240"

    我们看看那些参数 redis可以动态设置
    127.0.0.1:6379> CONFIG GET *

    1. "dbfilename"
    2. "dump.rdb"
    3. "requirepass"
    4. "123456"
    5. "masterauth"
    6. ""
    7. "unixsocket"
    8. ""
    9. "logfile"
    10. "/diskc/redis-2.8.19/log/6379_slave.log"
    11. "pidfile"
    12. "/var/run/redis.pid"
    13. "maxmemory"
    14. "10737418240"
    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. "100000"
    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. "15000"
    65. "watchdog-period"
    66. "200"
    67. "slave-priority"
    68. "100"
    69. "min-slaves-to-write"
    70. "0"
    71. "min-slaves-max-lag"
    72. "10"
    73. "hz"
    74. "10"
    75. "repl-diskless-sync-delay"
    76. "5"
    77. "no-appendfsync-on-rewrite"
    78. "no"
    79. "slave-serve-stale-data"
    80. "yes"
    81. "slave-read-only"
    82. "yes"
    83. "stop-writes-on-bgsave-error"
    84. "yes"
    85. "daemonize"
    86. "yes"
    87. "rdbcompression"
    88. "yes"
    89. "rdbchecksum"
    90. "yes"
    91. "activerehashing"
    92. "yes"
    93. "repl-disable-tcp-nodelay"
    94. "no"
    95. "repl-diskless-sync"
    96. "no"
    97. "aof-rewrite-incremental-fsync"
    98. "yes"
    99. "aof-load-truncated"
    100. "yes"
    101. "appendonly"
    102. "no"
    103. "dir"
    104. "/diskc/redis-2.8.19"
    105. "maxmemory-policy"
    106. "volatile-lru"
    107. "appendfsync"
    108. "everysec"
    109. "save"
    110. "900 1 300 10 60 10000"
    111. "loglevel"
    112. "notice"
    113. "client-output-buffer-limit"
    114. "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
    115. "unixsocketperm"
    116. "0"
    117. "slaveof"
    118. ""
    119. "notify-keyspace-events"
    120. ""
    121. "bind"
    122. ""

    相关文章

      网友评论

        本文标题:redis动态增加内存(不重启)

        本文链接:https://www.haomeiwen.com/subject/ahacpftx.html