redis info

INFO命令以一种易于计算机解析且易于人类阅读的格式返回有关服务器的信息和统计信息。

info section

在连接redis server后,输入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
## 默认输出所有信息,可以通过指定section来查看指定内容
info [section]

## 支持section如下:

## 有关Redis服务器的信息
info server

## 客户端连接信息
info clients

## 内存使用相关信息
info memory

## RDB和AOF相关信息
info persistence

## 统计信息
info stats

## 主副本复制信息
info replication

## cpu使用相关信息
info cpu

## Redis命令统计信息
info commandstats

## Redis集群信息
info cluster

## 数据库key相关统计信息
info keyspace

info还支持以下section

1
2
3
4
5
6
7
## 返回所有section
info all

## 返回默认的section
info default

## info在没有指定任何section的情况下,执行的是info default命令

info返回值(>=2.4)

info server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Server
redis_version:3.2.10 ## redis版本
redis_git_sha1:00000000 ## git版本
redis_git_dirty:0 ## git的代码是否修改
redis_build_id:2fc357230b5d7d9e ## 编译时ID
redis_mode:standalone ## redis运行模式
os:Linux 4.1.0-16.el6.ucloud.x86_64 x86_64 ## redis服务器操纵系统内核
arch_bits:64 ## 64位/32位
multiplexing_api:epoll ## redis使用的事件循环模型
gcc_version:4.4.7 ## gcc版本
process_id:11 ## 进程pid
run_id:b87c240a1585c224b10807f110c5d6e56e5bf16c ## Redis的随机标识符(用于sentinel和集群)
tcp_port:6379 ## redis端口
uptime_in_seconds:130679 ## Redis运行时长的秒数
uptime_in_days:1 ## Redis运行时长的天数
hz:10 ## 时间事件,单位是赫兹,每10毫秒循环一次
lru_clock:9378323 ## 以分钟为单位的自增时钟,用于LRU管理maxmemory-policy 内存回收策略
executable:/data/922d93c9-13df-46b1-aa5e-04eca791a3d3/redis-server ## 服务器可执行文件的路径
config_file:/data/922d93c9-13df-46b1-aa5e-04eca791a3d3/redis.conf ## 配置文件的路径

info clients

1
2
3
4
5
# Clients
connected_clients:2 ## 已连接客户端的数量(不包括通过从属服务器连接的客户端)
client_longest_output_list:0 ## 所有客户端连接中,最长的输出列表,Redis输出缓存峰值
client_biggest_input_buf:0 ## 所有客户端连接中,最大输入缓存,Redis输入缓存峰值
blocked_clients:0 ## 正在等待阻塞命令(BLPOP、BRPOP、BRPOPLPUSH)的客户端的数量

info memory

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Memory
used_memory:70397800 ## 由Redis分配的内存的总量,字节数,给机器看的
used_memory_human:67.14M ## 由Redis分配的内存的总量,单位G,给人看的
used_memory_rss:13381632 ## Redis进程从OS角度分配的物理内存
used_memory_rss_human:12.76M ## Redis进程从OS角度分配的物理内存
used_memory_peak:70509696 ## Redis使用内存的峰值
used_memory_peak_human:67.24M ## Redis使用内存的峰值
used_memory_lua:37888 ## lua引擎使用的内存总量
used_memory_lua_human:37.00K ## lua引擎使用的内存总量
maxmemory:17179869184 ## 最大内存配置
maxmemory_human:16.00G ## 最大内存配置
maxmemory_policy:noeviction ## 最大内存配置策略
mem_fragmentation_ratio:0.19 ## Ratio between used_memory_rss and used_memory
mem_allocator:jemalloc-4.0.3 ## Redis内存管理器

info persistence

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Persistence
loading:0 ## 一个标志值,记录了服务器是否正在载入持久化文件
rdb_changes_since_last_save:47861539 ## 距离最近一次成功创建持久化文件之后,经过了多少秒。
rdb_bgsave_in_progress:0 ## 一个标志值,记录了服务器是否正在创建 RDB 文件
rdb_last_save_time:1552751516 ## 最近一次成功创建 RDB 文件的 UNIX 时间戳
rdb_last_bgsave_status:ok ## 一个标志值,记录了最近一次创建 RDB 文件的结果是成功还是失败。
rdb_last_bgsave_time_sec:-1 ## 记录了最近一次创建 RDB 文件耗费的秒数
rdb_current_bgsave_time_sec:-1 ## 如果服务器正在创建 RDB 文件,那么这个域记录的就是当前的创建操作已经耗费的秒数。
aof_enabled:1 ## 一个标志值,记录了 AOF 是否处于打开状态
aof_rewrite_in_progress:0 ## 一个标志值,记录了服务器是否正在创建 AOF 文件
aof_rewrite_scheduled:0 ## 一个标志值,记录了在 RDB 文件创建完毕之后,是否需要执行预约的 AOF 重写操作。
aof_last_rewrite_time_sec:-1 ## 最近一次创建 AOF 文件耗费的时长
aof_current_rewrite_time_sec:-1 ## 如果服务器正在创建 AOF 文件,那么这个域记录的就是当前的创建操作已经耗费的秒数。
aof_last_bgrewrite_status:ok ## 一个标志值,记录了最近一次创建 AOF 文件的结果是成功还是失败。
aof_last_write_status:ok ## 最后一次写入AOF的操作状态
aof_current_size:5072527252 ## AOF文件的当前大小
aof_base_size:0 ## 最新启动或重写时的AOF文件大小
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0

info stats

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Stats
total_connections_received:11264 ## 服务器已接受的连接请求数量
total_commands_processed:73803308 ## 服务器已执行的命令数量
instantaneous_ops_per_sec:8054 ## 服务器每秒钟执行的命令数量
total_net_input_bytes:5000387001 ## 从网络读取的总字节数
total_net_output_bytes:5119029997 ## 写入网络的总字节数
instantaneous_input_kbps:530.57 ## 网络的每秒读取速率,以KB /秒为单位
instantaneous_output_kbps:478.97 ## 网络的每秒写入速率,以KB /秒为单位
rejected_connections:0 ## 因为最大客户端数量限制而被拒绝的连接请求数量
sync_full:1
sync_partial_ok:0
sync_partial_err:0
expired_keys:21817730 ## 因为过期而被自动删除的数据库键数量
evicted_keys:0 ## 因为最大内存容量限制而被驱逐(evict)的键数量
keyspace_hits:25773688 ## 查找数据库键成功的次数
keyspace_misses:6 ## 查找数据库键失败的次数
pubsub_channels:0 ## 目前被订阅的频道数量
pubsub_patterns:0 ## 目前被订阅的模式数量
latest_fork_usec:12283 ## 最近一次 fork() 操作耗费的毫秒数
migrate_cached_sockets:0 ## 为MIGRATE目的打开的套接字数量

info replication

1
2
3
4
5
6
7
8
9
# Replication
role:master ## 如果当前服务器没有在复制任何其他服务器,那么这个域的值就是 master ;否则的话,这个域的值就是 slave 。注意,在创建复制链的时候,一个从服务器也可能是另一个服务器的主服务器
connected_slaves:1 ## 已连接的从服务器数量
slave0:ip=10.10.155.57,port=6379,state=online,offset=4740420472,lag=1 ## ID、IP 地址、端口号、连接状态
master_repl_offset:4740828912
repl_backlog_active:1
repl_backlog_size:62914560
repl_backlog_first_byte_offset:4677914353
repl_backlog_histlen:62914560

info cpu

1
2
3
4
5
# CPU
used_cpu_sys:1788.78 ## Redis 服务器耗费的系统 CPU
used_cpu_user:638.75 ## Redis 服务器耗费的用户 CPU
used_cpu_sys_children:0.00 ## 后台进程耗费的系统 CPU
used_cpu_user_children:0.00 ## 后台进程耗费的用户 CPU

info commandstats

commandsstats部分根据命令类型提供数据统计,包括命令调用次数,总cpu时间,平均每个命令cpu时间,

1
2
3
4
5
6
7
8
9
10
11
12
13
# Commandstats
cmdstat_get:calls=9,usec=32,usec_per_call=3.56
cmdstat_set:calls=3,usec=52,usec_per_call=17.33
cmdstat_del:calls=1,usec=3,usec_per_call=3.00
cmdstat_incr:calls=26328979,usec=85602622,usec_per_call=3.25
cmdstat_expire:calls=22557247,usec=42154769,usec_per_call=1.87
cmdstat_auth:calls=6280,usec=12328,usec_per_call=1.96
cmdstat_psync:calls=1,usec=26,usec_per_call=26.00
cmdstat_replconf:calls=150681,usec=268080,usec_per_call=1.78
cmdstat_info:calls=6239,usec=256697,usec_per_call=41.14
cmdstat_ttl:calls=26328982,usec=15140788,usec_per_call=0.58
cmdstat_config:calls=51,usec=1561,usec_per_call=30.61
cmdstat_command:calls=5034,usec=2020156,usec_per_call=401.30

info cluster

1
2
3
# Cluster
## 表示是否启用了redis集群
cluster_enabled:0

info keyspace

1
2
3
# Keyspace
## keys代表所有key的数量,expires代表设有过期时间key的数量,avg_ttl代表平均key过期时间
db0:keys=263224,expires=263207,avg_ttl=39615

参考

  1. http://redisdoc.com/client_and_server/info.html
  2. https://redis.io/commands/info
  3. https://yq.aliyun.com/articles/414650