Redis 命令集

  • 查看所有 key:KEYS *
  • 查看数据库大小:DBSIZE
  • 查看数据库基本信息:INFO

    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
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    redis /tmp/redis.sock> info
    # Server
    redis_version:3.2.1
    redis_git_sha1:ce18ff58
    redis_git_dirty:0
    redis_build_id:2de158ec05fb50c4
    redis_mode:standalone
    os:Linux 2.6.32.13-Cavium-Octeon mips64
    arch_bits:64
    multiplexing_api:epoll
    gcc_version:4.3.3
    process_id:2877
    run_id:91d28ac8ed2ab0f4ceb592d472a79ffcb10a1049
    tcp_port:16904192
    uptime_in_seconds:17846
    uptime_in_days:0
    hz:10
    lru_clock:11220343
    executable:/redis-server
    config_file:/etc/redis/redis_ce_global.conf

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

    # Memory
    used_memory:2230112
    used_memory_human:2.13M
    used_memory_rss:3670016
    used_memory_rss_human:3.50M
    used_memory_peak:2296768
    used_memory_peak_human:2.19M
    total_system_memory:4111892480
    total_system_memory_human:3.83G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:1.65
    mem_allocator:libc

    # Persistence
    loading:0
    rdb_changes_since_last_save:0
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1470820590
    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:623151
    aof_base_size:0
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    aof_file_cmd_num:3936
    aof_buf_cmd_num:0
    aof_is_shadowfile:0

    # Stats
    total_connections_received:25
    total_commands_processed:4483
    instantaneous_ops_per_sec:0
    total_net_input_bytes:655148
    total_net_output_bytes:6071473
    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:528
    keyspace_misses:2
    pubsub_channels:0
    pubsub_patterns:11
    latest_fork_usec:494
    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.73
    used_cpu_user:0.61
    used_cpu_sys_children:0.01
    used_cpu_user_children:0.05

    # Cluster
    cluster_enabled:0

    # Keyspace
    db0:keys=3073,expires=0,avg_ttl=0
  • MONITOR,监控数据库使用情况,CTRL C 退出。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    [0809-09:49:06:833] ~ # redis-cli -s /tmp/redis/redis_de_global.sock 
    [0809-09:49:08:744] redis /tmp/redis/redis_de_global.sock> MONITOR
    [0809-09:49:08:753] OK
    [0809-09:49:10:853]
    [0809-09:49:14:849] 1470735840.255050 [0 unix:/tmp/redis/redis_de_global.sock] "HMSET" "/SS/NHOP/TBL/7623" "INTFID" "1" "VLAN" "100" "MAC" "0000.0000.0003" "PHYID" "07001b0b" "ACTION" "2" "FLOWID" "0" "FLAG" "00000000" "CTRL_FLAG" "00000000" "ENCAPID" "0"
    [0809-09:49:14:870] 1470735840.256824 [0 unix:/tmp/redis/redis_de_global.sock] "HMSET" "/SS/UC/RT/TBL/0/0/2.2.2.3/32/0" "VID" "0" "URPF" "0" "ACTION" "2" "NH_TYPE" "0" "NH_SIZE" "1" "ECMPGRP_ID" "0" "NHBASE_ID" "7623" "ENCAP_ID" "0" "CLASSID" "0" "INTFID" "0" "PHYID" "00000000" "MAC" "0001.0203.0405"
    [0809-09:49:14:894] 1470735840.261173 [0 unix:/tmp/redis/redis_de_global.sock] "HMSET" "/SS/NHOP/TBL/7624" "INTFID" "1" "VLAN" "100" "MAC" "0000.0000.0004" "PHYID" "07001b0b" "ACTION" "2" "FLOWID" "0" "FLAG" "00000000" "CTRL_FLAG" "00000000" "ENCAPID" "0"
    [0809-09:53:05:655] 1470735856.464859 [0 unix:/tmp/redis/redis_de_global.sock] "HMSET" "/SS/NHOP/TBL/12699" "INTFID" "1" "VLAN" "100" "MAC" "0000.0000.13d7" "PHYID" "07001b0b" "ACTION" "2" "FLOWID" "0" "FLAG" ""/SS/NHOP/TBL/12700" "INTFID" "1" "VLAN" "100" "MAC" "0000.0000.13d8" "PHYID" "07001b0b" "ACTION" "2" "FLOWID" "0" "FLAG" "00000000" "CTRL_FL
    [0809-09:54:52:443] ~ #