获取 Redis 服务器的各种信息和统计数值
语法
INFO [section [section ...]]
可用版本:
1.0.0
时间复杂度:
O(1)
ACL 类别:
@slow
, @dangerous
该INFO
命令以计算机易于解析且人类易于阅读的格式返回有关服务器的信息和统计信息。
可选参数可用于选择特定的信息部分:
它还可以采用以下值:
如果未提供参数,default
则假定该选项。
返回
批量字符串回复:作为文本行的集合。
行可以包含部分名称(以 # 字符开头)或属性。所有的属性都是由field:value
终止的形式\r\n
。
redis> INFO
"# Server
redis_version:7.0.5
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:383256aa4e712b9d
redis_mode:standalone
os:Linux 5.13.0-1017-aws x86_64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:10.2.1
process_id:1
process_supervised:no
run_id:28bf0201395c84d589c1adf8a5225104e3ddbbd2
tcp_port:6379
server_time_usec:1664096309288395
uptime_in_seconds:249207
uptime_in_days:2
hz:10
configured_hz:10
lru_clock:3151925
executable:/data/redis-server
config_file:/etc/redis/redis.conf
io_threads_active:0
# 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
# Memory
used_memory:17414440
used_memory_human:16.61M
used_memory_rss:23871488
used_memory_rss_human:22.77M
used_memory_peak:17432320
used_memory_peak_human:16.62M
used_memory_peak_perc:99.90%
used_memory_overhead:4902064
used_memory_startup:863512
used_memory_dataset:12512376
used_memory_dataset_perc:75.60%
allocator_allocated:17536336
allocator_active:18444288
allocator_resident:21512192
total_system_memory:16585785344
total_system_memory_human:15.45G
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:4294967296
maxmemory_human:4.00G
maxmemory_policy:allkeys-lru
allocator_frag_ratio:1.05
allocator_frag_bytes:907952
allocator_rss_ratio:1.17
allocator_rss_bytes:3067904
rss_overhead_ratio:1.11
rss_overhead_bytes:2359296
mem_fragmentation_ratio:1.37
mem_fragmentation_bytes:6479344
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_total_replication_buffers:0
mem_clients_slaves:0
mem_clients_normal:3600
mem_cluster_links:0
mem_aof_buffer:0
mem_allocator:jemalloc-5.2.1
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:195777
rdb_bgsave_in_progress:0
rdb_last_save_time:1663847102
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:0
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:243
total_commands_processed:245059
instantaneous_ops_per_sec:0
total_net_input_bytes:19397773
total_net_output_bytes:6535396
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:5719
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:15151
evicted_keys:0
evicted_clients:0
total_eviction_exceeded_time:0
current_eviction_exceeded_time:0
keyspace_hits:52153
keyspace_misses:5991
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:479
dump_payload_sanitizations:0
total_reads_processed:245466
total_writes_processed:245224
io_threaded_reads_processed:0
io_threaded_writes_processed:0
reply_buffer_shrinks:939
reply_buffer_expands:708
# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:650750170b0041e7597cc9f94f9af7124494c514
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:184.940825
used_cpu_user:240.415998
used_cpu_sys_children:0.003435
used_cpu_user_children:0.001329
used_cpu_sys_main_thread:184.899192
used_cpu_user_main_thread:240.366716
# Modules
# Errorstats
errorstat_ERR:count=279
errorstat_EXECABORT:count=1
errorstat_NOPERM:count=162
errorstat_WRONGTYPE:count=37
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=74492,expires=186,avg_ttl=31512946846890
"
redis>
返回数据如上所述。
笔记
请注意,根据 Redis 的版本,某些字段已被添加或删除。因此,一个健壮的客户端应用程序应该通过跳过未知属性来解析这个命令的结果,并优雅地处理丢失的字段。
这是 Redis >= 2.4 的字段说明。
以下是服务器部分中所有字段的含义:
redis_version
: Redis 服务器的版本
redis_git_sha1
:Git SHA1
redis_git_dirty
: Git 脏标志
redis_build_id
:构建ID
redis_mode
:服务器的模式(“独立”、“哨兵”或“集群”)
os
: 托管 Redis 服务器的操作系统
arch_bits
:架构(32 或 64 位)
multiplexing_api
: Redis 使用的事件循环机制
atomicvar_api
: Redis 使用的 Atomicvar API
gcc_version
: 用于编译 Redis 服务器的 GCC 编译器版本
process_id
: 服务器进程的PID
process_supervised
:受监督的系统(“upstart”、“systemd”、“unknown”或“no”)
run_id
: 标识 Redis 服务器的随机值(由 Sentinel 和 Cluster 使用)
tcp_port
: TCP/IP 监听端口
server_time_usec
:基于纪元的系统时间,精度为微秒
uptime_in_seconds
: Redis 服务器启动后的秒数
uptime_in_days
:以天为单位表示的相同值
hz
:服务器当前频率设置
configured_hz
:服务器配置的频率设置
lru_clock
:时钟每分钟递增一次,用于 LRU 管理
executable
: 服务器可执行文件的路径
config_file
: 配置文件的路径
io_threads_active
: 指示 I/O 线程是否处于活动状态的标志
shutdown_in_milliseconds
:副本在完成关闭序列之前赶上复制的最长时间。该字段仅在关机期间出现。
以下是客户端部分中所有字段的含义:
connected_clients
: 客户端连接数(不包括来自副本的连接)
cluster_connections
:集群总线使用的套接字数量的近似值
maxclients
:maxclients
配置指令的值。connected_clients
这是 和之connected_slaves
和 的上限cluster_connections
。
client_recent_max_input_buffer
: 当前客户端连接中最大的输入缓冲区
client_recent_max_output_buffer
: 当前客户端连接中最大的输出缓冲区
blocked_clients
: 等待阻塞调用的客户端数量 ( BLPOP
, BRPOP
, BRPOPLPUSH
, BLMOVE
, BZPOPMIN
, BZPOPMAX
)
tracking_clients
: 被跟踪的客户数量 (CLIENT TRACKING
)
clients_in_timeout_table
: 客户端超时表中的客户端数量
以下是内存部分中所有字段的含义:
used_memory
: Redis 使用其分配器分配的总字节数(标准libc、jemalloc或替代分配器,例如tcmalloc)
used_memory_human
:以前值的人类可读表示
used_memory_rss
:操作系统看到的 Redis 分配的字节数(也称为驻留集大小)。这是由工具报告的数字,例如top(1)
和ps(1)
used_memory_rss_human
:以前值的人类可读表示
used_memory_peak
: Redis 消耗的峰值内存(以字节为单位)
used_memory_peak_human
:以前值的人类可读表示
used_memory_peak_perc
:used_memory_peak
出来 的百分比used_memory
used_memory_overhead
:服务器分配用于管理其内部数据结构的所有开销的总和(以字节为单位)
used_memory_startup
: Redis 在启动时消耗的初始内存量(以字节为单位)
used_memory_dataset
:数据集的大小(以字节为单位)(used_memory_overhead
减去used_memory
)
used_memory_dataset_perc``used_memory_dataset
:超出净内存使用的百分比(used_memory
减used_memory_startup
)
total_system_memory
: Redis 主机拥有的内存总量
total_system_memory_human
:以前值的人类可读表示
used_memory_lua
: Lua 引擎使用的字节数
used_memory_lua_human
:以前值的人类可读表示
used_memory_scripts
: 缓存 Lua 脚本使用的字节数
used_memory_scripts_human
:以前值的人类可读表示
maxmemory
:maxmemory
配置指令的值
maxmemory_human
:以前值的人类可读表示
maxmemory_policy
:maxmemory-policy
配置指令的值
mem_fragmentation_ratio``used_memory_rss
:和之间的比率used_memory
。请注意,这不仅包括碎片,还包括其他进程开销(参见allocator_*
指标),以及代码、共享库、堆栈等开销。
mem_fragmentation_bytes``used_memory_rss
:和之间的差值used_memory
。请注意,当总分片字节数较低(几兆字节)时,较高的比率(例如 1.5 及以上)并不表示存在问题。
allocator_frag_ratio:``allocator_active
:和之间的比率allocator_allocated
。这是真正的(外部)碎片度量(不是mem_fragmentation_ratio
)。
allocator_frag_bytes``allocator_active
和之间的增量allocator_allocated
。请参阅关于mem_fragmentation_bytes
.
allocator_rss_ratio``allocator_resident
:和之间的比率allocator_active
。这通常表明分配器可以并且可能很快将释放回操作系统的页面。
allocator_rss_bytes``allocator_resident
:和之间的差值allocator_active
rss_overhead_ratio``used_memory_rss
: (进程 RSS) 和之间的比率allocator_resident
。这包括与分配器或堆无关的 RSS 开销。
rss_overhead_bytes
: used_memory_rss
(进程 RSS)和allocator_resident
allocator_allocated
:从分配器分配的总字节数,包括内部碎片。通常与used_memory
.
allocator_active
:分配器活动页面中的总字节数,这包括外部碎片。
allocator_resident
: 分配器中驻留的总字节数 (RSS),这包括可以释放到操作系统的页面(通过MEMORY PURGE
,或只是等待)。
mem_not_counted_for_evict
: 使用的内存不计入键逐出。这基本上是瞬态副本和 AOF 缓冲区。
mem_clients_slaves
: 副本客户端使用的内存 - 从 Redis 7.0 开始,副本缓冲区与复制积压共享内存,因此当副本不触发内存使用量增加时,此字段可以显示 0。
mem_clients_normal
: 普通客户端使用的内存
mem_cluster_links
:启用集群模式时,链接到集群总线上的对等点所使用的内存。
mem_aof_buffer
: 用于 AOF 和 AOF 重写缓冲区的瞬态内存
mem_replication_backlog
:复制积压使用的内存
mem_total_replication_buffers
:复制缓冲区消耗的总内存 - 在 Redis 7.0 中添加。
mem_allocator
:内存分配器,在编译时选择。
active_defrag_running
:activedefrag
启用时,这表明碎片整理当前是否处于活动状态,以及它打算使用的 CPU 百分比。
lazyfree_pending_objects
: 等待释放的对象数(调用UNLINK
或使用ASYNC 选项FLUSHDB
的结果)FLUSHALL
lazyfreed_objects
: 已被延迟释放的对象数。
理想情况下,该used_memory_rss
值应仅略高于 used_memory
. 当使用 rss >> 时,较大的差异可能意味着存在(外部)内存碎片,可以通过检查 allocator_frag_ratio
,来评估allocator_frag_bytes
。当使用 >> rss 时,这意味着部分 Redis 内存已被操作系统交换掉:预计会有一些显着的延迟。
由于 Redis 无法控制其分配如何映射到内存页面,因此高used_memory_rss
通常是内存使用量激增的结果。
当 Redis 释放内存时,内存会归还给分配器,分配器可能会将内存还给系统,也可能不会。used_memory
操作系统报告的值和内存消耗之间可能存在差异。这可能是由于内存已被 Redis 使用和释放,但没有归还给系统。该 used_memory_peak
值通常对检查这一点很有用。
通过参考MEMORY STATS
命令和MEMORY DOCTOR
.
以下是持久性部分中所有字段的含义: