20 Redisサーバ

26107 ワード

Redisサーバコマンドは主にredisサービスを管理するために使用されます.
≪インスタンス|Instance|emdw≫
次の例では、redisサーバの統計を取得する方法を示します.
redis 127.0.0.1:6379> INFO

# Server
redis_version:3.2.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:4d2050541c69b013
redis_mode:standalone
os:Linux 2.6.32-573.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:2330
run_id:955613d3ad935f3dee07156fab4ec98a2f1d40a5
tcp_port:6379
uptime_in_seconds:554
uptime_in_days:0
hz:10
lru_clock:618066
executable:/home/gp6/redis/redis-3.2.6/src/./redis-server
config_file:/home/gp6/redis/myRedis/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:822688
used_memory_human:803.41K
used_memory_rss:7782400
used_memory_rss_human:7.42M
used_memory_peak:822688
used_memory_peak_human:803.41K
total_system_memory:1967984640
total_system_memory_human:1.83G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:9.46
mem_allocator:jemalloc-4.0.3

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1510566952
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:1
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:31
total_net_output_bytes:5916769
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:1.05
used_cpu_user:2.37
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=1,expires=0,avg_ttl=0
db1:keys=1,expires=0,avg_ttl=0

Redisサーバコマンド
次の表に、redisサーバに関するコマンドを示します.
  • 1 Bgrewriteaof
  • Redis Bgrewriteaof            AOF(AppendOnly File)       。          AOF          。
       Bgrewriteaof     ,          ,     AOF     Bgrewriteaof          。
      :  Redis 2.4   , AOF     Redis     , BGREWRITEAOF             。
    
    #   
    redis 127.0.0.1:6379> BGREWRITEAOF 
    
    
    #    
        。
    
    
    #   
    127.0.0.1:6379> BGREWRITEAOF 
    Background append only file rewriting started
    
    
  • 2 Bgsave
  • Redis Bgsave                       。
    BGSAVE            OK ,   Redis fork        ,    Redis   (   )         ,               ,    。
    
    #   
    redis 127.0.0.1:6379> BGSAVE
    
    
    #    
        。
    
    
    #   
    127.0.0.1:6379>  BGSAVE
    Background saving started
    
  • 3 Client Kill
  • Redis Client Kill            。
    
    #   
    redis 127.0.0.1:6379> CLIENT KILL ip:port
    
    #    
         ,   OK 。
    
    
    #   
    #           
    
    127.0.0.1:6379> CLIENT LIST
    id=2 addr=127.0.0.1:44143 fd=5 name= age=1099 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
    
    #           
    
    127.0.0.1:6379> CLIENT KILL 127.0.0.1:44143
    OK
    
    #           ,CLI            
    #        44143 ,    44144
    
    127.0.0.1:6379>  CLIENT LIST
    id=3 addr=127.0.0.1:44144 fd=5 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
    
  • 4 Client Getname
  • Redis Client Getname        CLIENT SETNAME           。                 ,          , CLIENT GETNAME       。
    
    #   
    redis 127.0.0.1:6379> CLIENT GETNAME
    
    
    #    
              ,        ;        ,      。
    
    
    #   
    
    #          
    127.0.0.1:6379>  CLIENT GETNAME
    (nil)
    
    #     
    127.0.0.1:6379> CLIENT SETNAME hello-world-connection
    OK
    
    #     
    127.0.0.1:6379> CLIENT GETNAME
    "hello-world-connection"
    
  • 5 Client List
  • Redis Client List                          。
    
    #   
    redis 127.0.0.1:6379> CLIENT LIST
    
    
    #    
             ,              :
                    (  LF   )
                    =        ,          
           :
        addr :          
        fd :             
        age :           
        idle :          
        flags :     flag
        db :              ID
        sub :         
        psub :         
        multi :             
        qbuf :         (     , 0            )
        qbuf-free :             (     , 0         )
        obl :         (     , 0            )
        oll :            (             ,                       )
        omem :                  
        events :        
        cmd :          
        flag          :
        O :      MONITOR         (slave)
        S :          (normal)     
        M :        (master)
        x :          
        b :            
        i :         VM I/O   (   )
        d :      (watched)      , EXEC      
        c :            ,    
        u :        (unblocked)
        A :          
        N :       flag
                  :
        r :       (    loop  )    (readable)
        w :       (    loop  )    (writeable)
    
    #   
    redis 127.0.0.1:6379> CLIENT LIST
    id=3 addr=127.0.0.1:44144 fd=5 name=hello-world-connection age=527 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
    
  • 6 Client Pause
  • Redis Client Pause                (    )。。
    
    #   
    redis 127.0.0.1:6379> CLIENT PAUSE timeout 
    
    
    #    
       OK。   timeout           。
    
    
    #   
    127.0.0.1:6379> CLIENT PAUSE
    (error) ERR Syntax error, try CLIENT (LIST | KILL | GETNAME | SETNAME | PAUSE | REPLY)
    127.0.0.1:6379> CLIENT PAUSE 1000
    OK
    
  • 7 Client Setname
  • Redis Client Setname              。
             CLIENT LIST       ,                     。
    
    #   
    redis 127.0.0.1:6379> CLIENT SETNAME connection-name
    
    
    #    
            OK 。
    
    
    #   
    
    #          
    127.0.0.1:6379> CLIENT GETNAME
    (nil)
    
    #     
    127.0.0.1:6379> CLIENT SETNAME hello-world-connection
    OK
    
    #     
    redis 127.0.0.1:6379> CLIENT GETNAME
    "hello-world-connection"
    
    #          
    redis 127.0.0.1:6379> CLIENT LIST
    id=3 addr=127.0.0.1:44144 fd=5 
    name=hello-world-connection              #  CLIENT SETNAME        #         !
    (error) ERR Syntax error, try CLIENT (LIST | KILL ip:port)
    
    127.0.0.1:6379> CLIENT SETNAME ""     #          
    OK
    
    127.0.0.1:6379> CLIENT GETNAME        #     
    (nil)
    
  • 8 Cluster Slots
  • Redis Client Slots            ,       。
    
    #   
    redis 127.0.0.1:6379> CLUSTER SLOTS 
    
    
    #    
    IP/         。
    
    
    #   
    redis 127.0.0.1:6379> cluster slots
    1) 1) (integer) 0
       2) (integer) 4095
       3) 1) "127.0.0.1"
          2) (integer) 7000
       4) 1) "127.0.0.1"
          2) (integer) 7004
    2) 1) (integer) 12288
       2) (integer) 16383
       3) 1) "127.0.0.1"
          2) (integer) 7003
       4) 1) "127.0.0.1"
          2) (integer) 7007
    3) 1) (integer) 4096
       2) (integer) 8191
       3) 1) "127.0.0.1"
          2) (integer) 7001
       4) 1) "127.0.0.1"
          2) (integer) 7005
    4) 1) (integer) 8192
       2) (integer) 12287
       3) 1) "127.0.0.1"
          2) (integer) 7002
       4) 1) "127.0.0.1"
          2) (integer) 7006
    
  • 9 COMMAND
  • Redis Command          Redis       ,       。
    
    #   
    redis 127.0.0.1:6379> COMMAND  
    
    
    #    
       Redis         。        。
    
    
    #   
    127.0.0.1:6379> COMMAND
    #     ,      
    ......
    23) 1) "zrank"
         2) (integer) 3
         3) 1) readonly
            2) fast
         4) (integer) 1
         5) (integer) 1
         6) (integer) 1
     24) 1) "readwrite"
         2) (integer) 1
         3) 1) fast
         4) (integer) 0
         5) (integer) 0
         6) (integer) 0
     25) 1) "zrange"
         2) (integer) -4
         3) 1) readonly
         4) (integer) 1
         5) (integer) 1
         6) (integer) 1
     26) 1) "hlen"
         2) (integer) 2
         3) 1) readonly
            2) fast
         4) (integer) 1
         5) (integer) 1
         6) (integer) 1
     27) 1) "rpushx"
         2) (integer) 3
         3) 1) write
            2) denyoom
            3) fast
         4) (integer) 1
         5) (integer) 1
         6) (integer) 1
     28) 1) "randomkey"
         2) (integer) 1
         3) 1) readonly
            2) random
         4) (integer) 0
         5) (integer) 0
         6) (integer) 0
     29) 1) "set"
         2) (integer) -3
         3) 1) write
            2) denyoom
         4) (integer) 1
         5) (integer) 1
         6) (integer) 1
         ......
    
  • 10 Command Count
  • Redis Command Count        redis      。
    
    #   
    redis 127.0.0.1:6379> COMMAND COUNT
    
    
    #    
    redis    。
    
    
    #   
    127.0.0.1:6379> COMMAND COUNT
    (integer) 172
    
  • 11 Command Getkeys
  • Redis Command Getkeys          key。
    
    #   
    redis 127.0.0.1:6379> COMMAND GETKEYS
    
    
    #    
    key    。
    
    
    #   
    redis 127.0.0.1:6379> COMMAND GETKEYS MSET a b c d e f 
    1) "a"
    2) "c"
    3) "e"
    
  • 12 Time
  • Redis Time              
    
    #   
    redis 127.0.0.1:6379> TIME 
    
    
    #    
                :            (  UNIX        ),                      
    
    
    #   
    127.0.0.1:6379> TIME
    1) "1510580904"
    2) "337524"
    
  • 13 Command Info
  • Redis Command Info        redis        。
    
    #   
    redis 127.0.0.1:6379> COMMAND INFO command-name [command-name ...] 
    
    
    #    
               。
    
    
    #   
    127.0.0.1:6379> COMMAND INFO get set eval 
    1) 1) "get"
       2) (integer) 2
       3) 1) readonly
          2) fast
       4) (integer) 1
       5) (integer) 1
       6) (integer) 1
    2) 1) "set"
       2) (integer) -3
       3) 1) write
          2) denyoom
       4) (integer) 1
       5) (integer) 1
       6) (integer) 1
    3) 1) "eval"
       2) (integer) -3
       3) 1) noscript
          2) movablekeys
       4) (integer) 0
       5) (integer) 0
       6) (integer) 0
    
  • 14 Config Get
  • Redis Config Get        redis        。
      Redis 2.4    ,            CONFIG GET   ,       Redis 2.6    ,             CONFIG GET    。
    
    #   
    redis 127.0.0.1:6379> CONFIG GET parameter
    
    
    #    
            。
    
    
    #   
    127.0.0.1:6379> config get *max-*-entries* 
    1) "hash-max-ziplist-entries"
    2) "512"
    3) "set-max-intset-entries"
    4) "512"
    5) "zset-max-ziplist-entries"
    6) "128"
    
  • 15 Config rewrite
  • Redis Config rewrite       Redis          redis.conf         。
    CONFIG SET                  ,            redis.conf             , CONFIG REWRITE               ,                 redis.conf    。
    
    #   
    redis 127.0.0.1:6379> CONFIG REWRITE parameter
    
    
    #    
         :            OK ,         。
    
    
    #   
    
          CONFIG REWRITE  ,      Redis      redis.conf       appendonly      :
    
    # ...     
    appendonly no
    # ...     
    
             :
    127.0.0.1:6379> CONFIG GET appendonly           # appendonly       
    1) "appendonly"
    2) "no"
    
    127.0.0.1:6379> CONFIG SET appendonly yes       #    appendonly
    OK
    
    127.0.0.1:6379> CONFIG GET appendonly
    1) "appendonly"
    2) "yes"
    
    127.0.0.1:6379> CONFIG REWRITE                  #   appendonly        redis.conf  
    OK
    
    
         redis.conf      appendonly       :
    
    # ...     
    appendonly yes
    # ...     
    
  • 16 Config Set
  • Redis Config Set           Redis       (configuration)     。
                ,     Redis     (Persistence)  。
    
    #   
    redis 127.0.0.1:6379> CONFIG Set parameter value 
    
    
    #    
             OK ,        。
    
    
    #   
    127.0.0.1:6379>  CONFIG GET slowlog-max-len
    1) "slowlog-max-len"
    2) "128"
    127.0.0.1:6379> CONFIG SET slowlog-max-len 10086
    OK
    127.0.0.1:6379> CONFIG GET slowlog-max-len
    1) "slowlog-max-len"
    2) "10086"
    
  • 17 Dbsize
  • Redis Dbsize              key    。
    
    #   
    redis 127.0.0.1:6379> DBSIZE
    
    
    #    
           key    。
    
    
    #   
    127.0.0.1:6379> DBSIZE
    (integer) 0
    127.0.0.1:6379> SET new_key "hello_moto"             #      key   
    OK
    127.0.0.1:6379> DBSIZE
    (integer) 1
    
    
  • 18 Config Resetstat
  • Redis Config Resetstat        INFO           ,  :
        Keyspace hits (       )
        Keyspace misses (        )
        Number of commands processed (       )
        Number of connections received (        )
        Number of expired keys (  key   )
        Number of rejected connections (        )
        Latest fork(2) time(     fork(2)    )
        The aof_delayed_fsync counter(aof_delayed_fsync      )
    
    #   
    redis 127.0.0.1:6379> CONFIG RESETSTAT
    
    
    #    
         OK 。
    
    #   
    127.0.0.1:6379>  INFO
    # Server
    redis_version:3.2.6
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:4d2050541c69b013
    redis_mode:standalone
    os:Linux 2.6.32-573.el6.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    gcc_version:4.4.7
    process_id:2330
    run_id:955613d3ad935f3dee07156fab4ec98a2f1d40a5
    tcp_port:6379
    uptime_in_seconds:15816
    uptime_in_days:0
    hz:10
    lru_clock:633328
    executable:/home/gp6/redis/redis-3.2.6/src/./redis-server
    config_file:/home/gp6/redis/myRedis/redis.conf
    
    # Clients
    connected_clients:1
    client_longest_output_list:0
    client_biggest_input_buf:0
    blocked_clients:0
    
    # Memory
    used_memory:822256
    used_memory_human:802.98K
    used_memory_rss:7868416
    used_memory_rss_human:7.50M
    used_memory_peak:822688
    used_memory_peak_human:803.41K
    total_system_memory:1967984640
    total_system_memory_human:1.83G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:9.57
    mem_allocator:jemalloc-4.0.3
    
    # Persistence
    loading:0
    rdb_changes_since_last_save:0
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1510582644
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    aof_enabled:1
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_current_size:137
    aof_base_size:71
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    
    # Stats
    total_connections_received:2
    total_commands_processed:39
    instantaneous_ops_per_sec:0
    total_net_input_bytes:1302
    total_net_output_bytes:11790594
    instantaneous_input_kbps:0.00
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:0
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:0
    evicted_keys:0
    keyspace_hits:0
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:62033
    migrate_cached_sockets:0
    
    # Replication
    role:master
    connected_slaves:0
    master_repl_offset:0
    repl_backlog_active:0
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:0
    repl_backlog_histlen:0
    
    # CPU
    used_cpu_sys:27.51
    used_cpu_user:66.81
    used_cpu_sys_children:0.62
    used_cpu_user_children:0.00
    
    # Cluster
    cluster_enabled:0
    
    # Keyspace
    db0:keys=1,expires=0,avg_ttl=0
    db1:keys=1,expires=0,avg_ttl=0
    
    #      
    127.0.0.1:6379> CONFIG RESETSTAT
    OK
    
    #      INFO       
    127.0.0.1:6379>  INFO
    # Server
    redis_version:3.2.6
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:4d2050541c69b013
    redis_mode:standalone
    os:Linux 2.6.32-573.el6.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    gcc_version:4.4.7
    process_id:2330
    run_id:955613d3ad935f3dee07156fab4ec98a2f1d40a5
    tcp_port:6379
    uptime_in_seconds:15994
    uptime_in_days:0
    hz:10
    lru_clock:633506
    executable:/home/gp6/redis/redis-3.2.6/src/./redis-server
    config_file:/home/gp6/redis/myRedis/redis.conf
    
    # Clients
    connected_clients:1
    client_longest_output_list:0
    client_biggest_input_buf:0
    blocked_clients:0
    
    # Memory
    used_memory:822256
    used_memory_human:802.98K
    used_memory_rss:7868416
    used_memory_rss_human:7.50M
    used_memory_peak:822688
    used_memory_peak_human:803.41K
    total_system_memory:1967984640
    total_system_memory_human:1.83G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:9.57
    mem_allocator:jemalloc-4.0.3
    
    # Persistence
    loading:0
    rdb_changes_since_last_save:0
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1510582644
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    aof_enabled:1
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_current_size:137
    aof_base_size:71
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    
    # Stats
    total_connections_received:0
    total_commands_processed:1
    instantaneous_ops_per_sec:0
    total_net_input_bytes:14
    total_net_output_bytes:5
    instantaneous_input_kbps:0.00
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:0
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:0
    evicted_keys:0
    keyspace_hits:0
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:0
    migrate_cached_sockets:0
    
    # Replication
    role:master
    connected_slaves:0
    master_repl_offset:0
    repl_backlog_active:0
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:0
    repl_backlog_histlen:0
    
    # CPU
    used_cpu_sys:27.73
    used_cpu_user:67.70
    used_cpu_sys_children:0.62
    used_cpu_user_children:0.00
    
    # Cluster
    cluster_enabled:0
    
    # Keyspace
    db0:keys=1,expires=0,avg_ttl=0
    db1:keys=1,expires=0,avg_ttl=0
    
    
    
  • 19 Debug Object
  • Redis Debug Object          ,          。
    
    #   
    redis 127.0.0.1:6379> DEBUG OBJECT key
    
    
    #    
      key    ,      。   key     ,      。
    
    
    #   
    127.0.0.1:6379> DEBUG OBJECT new_key
    Value at:0x7f7a08e1b940 refcount:1 encoding:embstr serializedlength:11 lru:633204 lru_seconds_idle:664
    
    127.0.0.1:6379> DEBUG OBJECT mykey
    (error) ERR no such key
    
  • 20 Debug Segfault
  • Redis Debug Segfault                  Redis   ,        BUG   。
    
    #   
    redis 127.0.0.1:6379> DEBUG SEGFAULT 
    
    
    #    
     
    
    
    #   
    127.0.0.1:6379> DEBUG SEGFAULT 
    Could not connect to Redis at 127.0.0.1:6379: Connection refused
    (1.13s)
    
  • 21 Flushall
  • Redis Flushall          Redis       (           key )。
    
    #   
    redis 127.0.0.1:6379> FLUSHALL 
    
    
    #    
         OK 
    
    
    #   
    127.0.0.1:6379> DBSIZE            # 0       key   
    (integer) 9
    
    127.0.0.1:6379> SELECT 1          #     1     
    OK
    
    127.0.0.1:6379> DBSIZE         # 1       key   
    (integer) 6
    
    127.0.0.1:6379> flushall       #            key
    OK
    
    127.0.0.1:6379> DBSIZE         #    1         
    (integer) 0
    
    127.0.0.1:6379> SELECT 0       # 0     (         )   
    OK
    
    127.0.0.1:6379> DBSIZE
    (integer) 0
    
  • 22 Flushdb
  • Redis Flushdb                 key。
    
    #   
    redis 127.0.0.1:6379> FLUSHDB 
    
    
    #    
         OK 。
    
    
    #   
    
    127.0.0.1:6379> DBSIZE    #      key   
    (integer) 4
    
    127.0.0.1:6379> FLUSHDB
    OK
    
    127.0.0.1:6379> DBSIZE    #      key   
    (integer) 0
    
  • 23 Info
  • server :    Redis      ,     :
        redis_version : Redis      
        redis_git_sha1 : Git SHA1
        redis_git_dirty : Git dirty flag
        os : Redis           
        arch_bits :   (32   64  )
        multiplexing_api : Redis           
        gcc_version :    Redis       GCC   
        process_id :        PID
        run_id : Redis          (   Sentinel    )
        tcp_port : TCP/IP     
        uptime_in_seconds :   Redis        ,     
        uptime_in_days :   Redis        ,     
        lru_clock :              ,   LRU   
    
    clients :         ,     :
        connected_clients :          (                )
        client_longest_output_list :           ,       
        client_longest_input_buf :           ,      
        blocked_clients :         (BLPOP、BRPOP、BRPOPLPUSH)       
    
    memory :     ,     :
        used_memory :   Redis           ,   (byte)   
        used_memory_human :            Redis        
        used_memory_rss :         ,   Redis         (       )。     top 、 ps         。
        used_memory_peak : Redis        (      )
        used_memory_peak_human :            Redis        
        used_memory_lua : Lua           (      )
        mem_fragmentation_ratio : used_memory_rss   used_memory      
        mem_allocator :        , Redis          。    libc 、 jemalloc    tcmalloc 。
              , used_memory_rss        used_memory       。
          rss > used ,          ,    (      )    。
                    mem_fragmentation_ratio     。
          used > rss  ,   Redis                   ,      ,            。
          Redis      ,      ,     ,          。
           Redis      ,             ,   used_memory              Redis         。
           used_memory_peak               。
    
    persistence : RDB   AOF      
    stats :       
    replication :  /     
    cpu : CPU        
    commandstats : Redis       
    cluster : Redis     
    keyspace :           
    
    
    #   
    redis 127.0.0.1:6379> INFO [section] 
    
    
    #    
       ,      。
    
    
    #   
    127.0.0.1:6379>  INFO
    # Server
    redis_version:3.2.6
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:4d2050541c69b013
    redis_mode:standalone
    os:Linux 2.6.32-573.el6.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    gcc_version:4.4.7
    process_id:4913
    run_id:430a44294052a07f5c81c6e376c9038e482a5088
    tcp_port:6379
    uptime_in_seconds:480
    uptime_in_days:0
    hz:10
    lru_clock:634699
    executable:/home/gp6/redis/redis-3.2.6/src/./redis-server
    config_file:/home/gp6/redis/myRedis/redis.conf
    
    # Clients
    connected_clients:1
    client_longest_output_list:0
    client_biggest_input_buf:0
    blocked_clients:0
    
    # Memory
    used_memory:822656
    used_memory_human:803.38K
    used_memory_rss:7782400
    used_memory_rss_human:7.42M
    used_memory_peak:822656
    used_memory_peak_human:803.38K
    total_system_memory:1967984640
    total_system_memory_human:1.83G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:9.46
    mem_allocator:jemalloc-4.0.3
    
    # Persistence
    loading:0
    rdb_changes_since_last_save:2
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1510583659
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:-1
    rdb_current_bgsave_time_sec:-1
    aof_enabled:1
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:-1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_current_size:137
    aof_base_size:137
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    
    # Stats
    total_connections_received:1
    total_commands_processed:2
    instantaneous_ops_per_sec:0
    total_net_input_bytes:47
    total_net_output_bytes:5888263
    instantaneous_input_kbps:0.00
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:0
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:0
    evicted_keys:0
    keyspace_hits:0
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:0
    migrate_cached_sockets:0
    
    # Replication
    role:master
    connected_slaves:0
    master_repl_offset:0
    repl_backlog_active:0
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:0
    repl_backlog_histlen:0
    
    # CPU
    used_cpu_sys:0.94
    used_cpu_user:2.05
    used_cpu_sys_children:0.00
    used_cpu_user_children:0.00
    
    # Cluster
    cluster_enabled:0
    
    # Keyspace
    db0:keys=1,expires=0,avg_ttl=0
    db1:keys=1,expires=0,avg_ttl=0
    
  • 24 Lastsave
  • Redis Lastsave          Redis               ,  UNIX        。
    
    #   
    redis 127.0.0.1:6379> LASTSAVE 
    
    
    #    
       ,      。
    
    
    #   
    127.0.0.1:6379> LASTSAVE 
    (integer) 1510583659
    
  • 25 Monitor
  • Redis Monitor           Redis          ,   。
    
    #   
    redis 127.0.0.1:6379> MONITOR 
    
    
    #    
         OK 。
    
    
    #   
    127.0.0.1:6379> MONITOR 
    OK
    
    #        ,    
    127.0.0.1:6379> keys *
    1) "new_key"
    
    #  ,            
    1510584488.966928 [0 127.0.0.1:44149] "COMMAND"
    1510584494.538387 [0 127.0.0.1:44149] "keys" "*"
    
    
  • 26 Role
  • Redis Role              ,   master, slave, sentinel。
    
    #   
    redis 127.0.0.1:6379> ROLE 
    
    #    
          :       master, slave, sentinel       
    
    
    #   
    127.0.0.1:6379> ROLE 
    1) "master"
    2) (integer) 0
    3) (empty list or set)
    
  • 27 Save
  • Redis Save             ,    Redis          (snapshot)  RDB           。
    
    #   
    redis 127.0.0.1:6379> SAVE 
    
    
    #    
            OK 。。
    
    
    #   
    127.0.0.1:6379> SAVE 
    OK
    
  • 28 Shutdown
  • Redis Shutdown         :
               
                     ,   SAVE   
           AOF      ,   AOF   
           redis    (server)
    
    #   
    redis 127.0.0.1:6379> SHUTDOWN [NOSAVE] [SAVE] 
    
    
    #    
             。             ,            ,       。
    
    
    #   
    127.0.0.1:6379> PING
    PONG
    127.0.0.1:6379> SHUTDOWN
    not connected> 
    
  • 29 Slaveof
  • Redis Slaveof                         (slave server)。
                    (master server)      ,     SLAVEOF host port                   ,      ,              。
      ,             SLAVEOF NO ONE                 ,              ,               。
      『 SLAVEOF NO ONE            』    ,            ,              ,         。
    
    #   
    redis 127.0.0.1:6379> SLAVEOF host port  
    
    
    #    
         OK 
    
    
    #   
    127.0.0.1:6379> SLAVEOF 127.0.0.1 6379
    OK
    127.0.0.1:6379> SLAVEOF NO ONE
    OK
    
  • 30 slowlog
  • Redis slowlog   Redis                。
                      (talking)、      IO   ,                  。
      ,slow log        ,       ,           ,         slow log     Redis    。
    
    #   
    redis 127.0.0.1:6379> SLOWLOG subcommand [argument]
    
    
    #    
           ,      。
    
    
    #   
    
    #      
    127.0.0.1:6379> slowlog get 2
    (empty list or set)
    
    #         :
    127.0.0.1:6379>  SLOWLOG LEN
    (integer) 0
    
    #     SLOWLOG RESET      slow log 。
    127.0.0.1:6379> SLOWLOG LEN
    (integer) 14
    
    127.0.0.1:6379> SLOWLOG RESET
    OK
    
    127.0.0.1:6379> SLOWLOG LEN
    (integer) 0
    
  • 31 Sync
  • Redis Sync            。
    
    #   
    redis 127.0.0.1:6379> SYNC  
    
    
    #    
       。
    
    
    #   
    127.0.0.1:6379> SYNC 
    Entering slave output mode...  (press Ctrl-C to quit)
    SYNC with master, discarding 131 bytes of bulk transfer...
    SYNC done. Logging commands from master.
    "PING"