zoukankan      html  css  js  c++  java
  • redis 动态添加内存 动态配置 无需重启

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    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 ,否则返回一个错误。

      

    例如:动态添加内存

    1
    2
    3
    4
    5
    6
    7
    8
    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可以动态设置

    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
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    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"
  • 相关阅读:
    CentOS下Redis 2.2.14安装配置详解(转载)
    centos 6.3 64位安装php5.5及配置tengine
    linux下安装php扩展redis缓存
    linux安装ruby ruby-devel rubygems bundler
    composer的create-project安装php框架laravel for mac教程
    Homebrew安装php5及composer for mac教程
    KeepAlive详解
    方便mac os 10.9系统中phpstorm配置php运行环境
    Android使用adb工具及root权限完成手机抓包
    linux服务器监控流量sh脚本
  • 原文地址:https://www.cnblogs.com/huibaobao/p/13538102.html
Copyright © 2011-2022 走看看