admin 管理员组文章数量: 894189
18. Redis 管理命令
Redis 提供了info 命令, 可以查看Redis 服务器的相关信息。
1. info 命令格式
info 命令可以查询redis 服务器的相关信息, 默认查看全部的信息。也可以查看具体某部分信息, 支持的参数有:
- keyspace: 数据库的相关统计
- clients: 查看当前服务器的客户端连接数量等信息
- commandstats: Redis命令统计
- memory: 查看redis内存占用和峰值设置
- cpu: 统计CPU的消耗
- replication: 主/从复制信息
- server: Redis服务器的一般信息
- persistence: RDB和AOF相关信息
- stats: 一般统计
- cluster: Redis集群信息
1.1 查看各数据库key情况
- keys: 当前数据库中key总数量
- expires: 当前数据库中设置了过期时间的key的数量
127.0.0.1:6379> info keyspace# Keyspace
db0:keys=2,expires=0,avg_ttl=0
db1:keys=1,expires=0,avg_ttl=0
db2:keys=1,expires=0,avg_ttl=0
1.2 查看Redis 客户端连接数
127.0.0.1:6379> info clients# Clients
connected_clients:3
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0
1.3 查看命令执行次数统计
127.0.0.1:6379> info commandstats# Commandstats
cmdstat_exists:calls=2,usec=12,usec_per_call=6.00
cmdstat_role:calls=1,usec=8,usec_per_call=8.00
cmdstat_type:calls=4,usec=23,usec_per_call=5.75
cmdstat_setbit:calls=18,usec=140,usec_per_call=7.78
cmdstat_keys:calls=12,usec=151,usec_per_call=12.58
cmdstat_expire:calls=4,usec=32,usec_per_call=8.00
cmdstat_time:calls=1,usec=3,usec_per_call=3.00
1.4 查看内存
127.0.0.1:6379> info memory# Memory
used_memory:637888
used_memory_human:622.94K
used_memory_rss:5570560
used_memory_rss_human:5.31M
used_memory_peak:701328
used_memory_peak_human:684.89K
used_memory_peak_perc:90.95%
used_memory_overhead:613428
used_memory_startup:512648
used_memory_dataset:24460
used_memory_dataset_perc:19.53%
allocator_allocated:1139440
allocator_active:1523712
allocator_resident:7806976
total_system_memory:8268652544
total_system_memory_human:7.70G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.34
allocator_frag_bytes:384272
allocator_rss_ratio:5.12
allocator_rss_bytes:6283264
rss_overhead_ratio:0.71
rss_overhead_bytes:-2236416
mem_fragmentation_ratio:9.33
mem_fragmentation_bytes:4973688
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:100460
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
1.5 查看cpu
127.0.0.1:6379> info cpu# CPU
used_cpu_sys:51.677294
used_cpu_user:56.132481
used_cpu_sys_children:0.002255
used_cpu_user_children:0.006267
1.6 查看主从
127.0.0.1:6379> info replication# Replication
role:master
connected_slaves:0
master_replid:26639fafdfe16db738d4315ed49dabf42a4c4b44
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
1.7 查看服务器相关信息
127.0.0.1:6379> info server# Server
#redis 版本号
redis_version:5.0.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:8c41f1f4b4d10d62
redis_mode:standalone
os:Linux 4.15.0-20-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:7.3.0
# 进程id
process_id:7981
run_id:260bd91704038cb639575dbd95843dafda6978b0
tcp_port:6379
uptime_in_seconds:74878
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:13793393
# 启动命令
executable:/usr/local/src/redis-5.0.4/redis-server
# 配置文件
config_file:/usr/local/src/redis-5.0.4/redis.conf
本文标签: 18 Redis 管理命令
版权声明:本文标题:18. Redis 管理命令 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1688191652h190185.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论