1)查看key
>keys * #查看所有的key,数据量大的时候容易阻塞
>scan 0 #每次获取11个key,直到获取所有的key,编号从0开始,下一次获取时,按照提示的编号输入scan后的值
当编号再次为0时,获取完成所有数据
[redis@t4-dtpoc-dameng-db-damengdb01-ma01 bin]$ ./redis-cli -a passw0rd
127.0.0.1:6379> keys *
1) "name1"
2) "name"
3) "colour"
4) "list"
5) "id"
6) "mobile"
7) "money"
8) "jsj"
9) "sjaf"
10) "read"
11) "jj"
12) "sss"
127.0.0.1:6379> scan 0
1) "7"
2) 1) "name1"
2) "name"
3) "jsj"
4) "sss"
5) "colour"
6) "list"
7) "sjaf"
8) "read"
9) "jj"
10) "money"
127.0.0.1:6379> scan 7
1) "0"
2) 1) "id"
2) "mobile"
2)redis-cli -a redispwd --stat #监控redis的状态
[redis@t4-dtpoc-dameng-db-damengdb01-ma01 bin]$ ./redis-cli -a passw0rd --stat
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
------- data ------ --------------------- load -------------------- - child -
keys mem clients blocked requests connections
12 1.01M 1 0 15 (+0) 3
12 1.02M 1 0 16 (+1) 3
12 1.02M 1 0 17 (+1) 3
12 1.03M 1 0 18 (+1) 3
12 1.03M 1 0 19 (+1) 3
12 1.03M 1 0 20 (+1) 3
12 1.02M 1 0 21 (+1) 3
12 1.02M 1 0 22 (+1) 3
12 1.03M 1 0 23 (+1) 3
12 1.03M 1 0 24 (+1) 3
12 1.03M 1 0 25 (+1) 3
12 1.02M 1 0 26 (+1) 3
12 1.02M 1 0 27 (+1) 3
12 1.03M 1 0 28 (+1) 3
12 1.03M 1 0 29 (+1) 3
12 1.03M 1 0 30 (+1) 3
12 1.02M 1 0 31 (+1) 3
12 1.02M 1 0 32 (+1) 3
12 1.03M 1 0 33 (+1) 3
12 1.03M 1 0 34 (+1) 3
显示多少个key,内存占多少,客户端有多少,请求数是多少,连接数是多少
通过增加客户端及key的操作可以发现变化
3)redis-cli -a redispwd monitor #监控数据操作
操作的命令,增加,删除等都会监控到
窗口1:
[redis@t4-dtpoc-dameng-db-damengdb01-ma01 bin]$ ./redis-cli -a passw0rd
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get name
"helloss"
127.0.0.1:6379> set name hellojss
OK
127.0.0.1:6379> set sss ssss
OK
127.0.0.1:6379>
监控窗口:
[redis@t4-dtpoc-dameng-db-damengdb01-ma01 bin]$ ./redis-cli -a passw0rd monitor
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
OK
1736494136.833332 [0 127.0.0.1:18754] "AUTH" "(redacted)"
1736494136.834483 [0 127.0.0.1:18754] "COMMAND" "DOCS"
1736494142.019882 [0 127.0.0.1:18754] "get" "name"
1736494169.016763 [0 127.0.0.1:18754] "set" "name" "hellojss"
1736494177.607515 [0 127.0.0.1:18754] "set" "sss" "ssss"
4)redis-cli -a redispwd info #查看redis的相关信息
包含Server、Clients、Memory、CPU、Cluster等相关信息
OK
127.0.0.1:6379> info
# Server
redis_version:7.2.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c488b705d6055300
redis_mode:standalone
os:Linux 4.19.90-23.8.v2101.ky10.aarch64 aarch64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:7.3.0
process_id:3028363
process_supervised:no
run_id:ad7a9e88a00580a6cc3cd89f5846c51293c56ade
tcp_port:6379
server_time_usec:1736494259320435
uptime_in_seconds:654
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:8441011
executable:/home/redis/redis/bin/redis-server
config_file:/home/redis/redis/conf/redis.conf
io_threads_active:0
listener0:name=tcp,bind=*,bind=-::*,port=6379
# Clients
connected_clients:2
cluster_connections:0
maxclients:10000
client_recent_max_input_buffer:8
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
total_blocking_keys:0
total_blocking_keys_on_nokey:0
# Memory
used_memory:1124880
used_memory_human:1.07M
used_memory_rss:10158080
used_memory_rss_human:9.69M
used_memory_peak:1318840
used_memory_peak_human:1.26M
used_memory_peak_perc:85.29%
used_memory_overhead:903448
used_memory_startup:898768
used_memory_dataset:221432
used_memory_dataset_perc:97.93%
allocator_allocated:1749496
allocator_active:9175040
allocator_resident:10747904
total_system_memory:7137525760
total_system_memory_human:6.65G
used_memory_lua:31744
used_memory_vm_eval:31744
used_memory_lua_human:31.00K
used_memory_scripts_eval:0
number_of_cached_scripts:0
number_of_functions:0
number_of_libraries:0
used_memory_vm_functions:32768
used_memory_vm_total:64512
used_memory_vm_total_human:63.00K
used_memory_functions:184
used_memory_scripts:184
used_memory_scripts_human:184B
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:5.24
allocator_frag_bytes:7425544
allocator_rss_ratio:1.17
allocator_rss_bytes:1572864
rss_overhead_ratio:0.95
rss_overhead_bytes:-589824
mem_fragmentation_ratio:9.21
mem_fragmentation_bytes:9055496
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_total_replication_buffers:0
mem_clients_slaves:0
mem_clients_normal:3856
mem_cluster_links:0
mem_aof_buffer:0
mem_allocator:jemalloc-5.3.0
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0
# Persistence
loading:0
async_loading:0
current_cow_peak:0
current_cow_size:0
current_cow_size_age:0
current_fork_perc:0.00
current_save_keys_processed:0
current_save_keys_total:0
rdb_changes_since_last_save:6
rdb_bgsave_in_progress:0
rdb_last_save_time:1736493605
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_saves:0
rdb_last_cow_size:0
rdb_last_load_keys_expired:0
rdb_last_load_keys_loaded:8
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_rewrites:0
aof_rewrites_consecutive_failures:0
aof_last_write_status:ok
aof_last_cow_size:0
module_fork_in_progress:0
module_fork_last_cow_size:0
# Stats
total_connections_received:5
total_commands_processed:99
instantaneous_ops_per_sec:0
total_net_input_bytes:1814
total_net_output_bytes:827304
total_net_repl_input_bytes:0
total_net_repl_output_bytes:0
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
instantaneous_input_repl_kbps:0.00
instantaneous_output_repl_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:6
evicted_keys:0
evicted_clients:0
total_eviction_exceeded_time:0
current_eviction_exceeded_time:0
keyspace_hits:1
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
pubsubshard_channels:0
latest_fork_usec:0
total_forks:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
total_active_defrag_time:0
current_active_defrag_time:0
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_error_replies:2
dump_payload_sanitizations:0
total_reads_processed:105
total_writes_processed:110
io_threaded_reads_processed:0
io_threaded_writes_processed:0
reply_buffer_shrinks:19
reply_buffer_expands:46
eventloop_cycles:6635
eventloop_duration_sum:557939
eventloop_duration_cmd_sum:8753
instantaneous_eventloop_cycles_per_sec:9
instantaneous_eventloop_duration_usec:81
acl_access_denied_auth:0
acl_access_denied_cmd:0
acl_access_denied_key:0
acl_access_denied_channel:0
# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:ed47b69a667922c10ebe75d0b6320884e1da8d30
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:0.165750
used_cpu_user:0.444332
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
used_cpu_sys_main_thread:0.162647
used_cpu_user_main_thread:0.447095
# Modules
# Errorstats
errorstat_ERR:count=2
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=12,expires=0,avg_ttl=0