Redis 版本至
1.0.0
起可用。info
指令提供可供人类阅读的关于Redis Server相关的信息和统计。同时提供一些可选参数来过滤选择你想要了解的信息。
Info
1、 一般形式:
INFO [section]
2、可选参数(section部分):
• server: General information about the Redis server
• clients: Client connections section
• memory: Memory consumption related information
• persistence: RDB and AOF related information
• stats: General statistics
• replication: Master/replica replication information
• cpu: CPU consumption statistics
• commandstats: Redis command statistics
• cluster: Redis Cluster section
• keyspace: Database related statistics
• all: Return all sections
• default: Return only the default set of sections
3、返回结果:#
后面是 section 值。所有的值都是以 field:value
的形式展示。
# Server
redis_version:3.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:2c447c96fab1e1d9
redis_mode:standalone
os:Linux 2.6.32-573.18.1.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:2116
run_id:d55e938946cdc63342ab5361bb56fa2ecdfe6d3e
tcp_port:6379
uptime_in_seconds:10364
uptime_in_days:0
hz:10
lru_clock:4097034
config_file:/opt/software/redis-3.0.1/redis.conf
# Clients
connected_clients:11
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:260191592
used_memory_human:248.14M
used_memory_rss:278179840
used_memory_peak:265660368
used_memory_peak_human:253.35M
used_memory_lua:35840
mem_fragmentation_ratio:1.07
mem_allocator:jemalloc-3.6.0
# Persistence
loading:0
rdb_changes_since_last_save:156
rdb_bgsave_in_progress:0
rdb_last_save_time:1564378088
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:31
rdb_current_bgsave_time_sec:-1
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_last_write_status:ok
# Stats
total_connections_received:1680
total_commands_processed:144366
instantaneous_ops_per_sec:0
total_net_input_bytes:6610548
total_net_output_bytes:28625201
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:3
evicted_keys:0
keyspace_hits:37277
keyspace_misses:4652
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:21211
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:137.42
used_cpu_user:90.21
used_cpu_sys_children:113.54
used_cpu_user_children:763.18
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=42790,expires=0,avg_ttl=000
section 详解
根据不同的Redis版本,指令返回的字段有增加或是删除,这里的字段描述基于 Redis >= 2.4。
server
命令结果:
营销测试:0>info server
"# Server
redis_version:3.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:2c447c96fab1e1d9
redis_mode:standalone
os:Linux 2.6.32-573.18.1.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:2116
run_id:d55e938946cdc63342ab5361bb56fa2ecdfe6d3e
tcp_port:6379
uptime_in_seconds:12502
uptime_in_days:0
hz:10
lru_clock:4099172
config_file:/opt/software/redis-3.0.1/redis.conf
字段分析:
• redis_version: Version of the Redis server (版本)
• redis_git_sha1: Git SHA1
• redis_git_dirty: Git dirty flag
• redis_build_id: The build id
• redis_mode: The server’s mode (“standalone”, “sentinel” or “cluster”) (模式:单例、哨兵或是集群)
• os: Operating system hosting the Redis server (操作系统)
• arch_bits: Architecture (32 or 64 bits)
• multiplexing_api: Event loop mechanism used by Redis(Redis使用的事件循环机制)
• atomicvar_api: Atomicvar API used by Redis
• gcc_version: Version of the GCC compiler used to compile the Redis server(编译Redis的Gcc版本)
• process_id: PID of the server process (进程ID)
• run_id: Random value identifying the Redis server (to be used by Sentinel and Cluster) (标识Redis服务器的随机值(由Sentinel和Cluster使用))
• tcp_port: TCP/IP listen port (端口)
• uptime_in_seconds: Number of seconds since Redis server start (Redis服务器启动后的秒数)
• uptime_in_days: Same value expressed in days (Redis服务器启动后的天数)
• hz: The server’s frequency setting (服务器的频率设置)
• lru_clock: Clock incrementing every minute, for LRU management
• executable: The path to the server’s executable (redis-server执行文件位置)
• config_file: The path to the config file (redis.conf配置文件位置)
clients
命令结果:
营销测试:0>info clients
# Clients
connected_clients:111
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
字段分析:
- connected_clients: Number of client connections (excluding connections from replicas) (客户端连接数(不包括来自副本的连接))
- client_longest_output_list: longest output list among current client connections (当前客户端连接中最长的输出列表)
- client_biggest_input_buf: biggest input buffer among current client connections (当前客户端连接中最大的输入缓冲区)
- blocked_clients: Number of clients pending on a blocking call (BLPOP, BRPOP, BRPOPLPUSH) (阻塞队列,呼叫中待处理的客户端数量(BLPOP,BRPOP,BRPOPLPUSH))
memory
命令结果:
营销测试:0>info memory
# Memory
used_memory:262287880
used_memory_human:250.14M
used_memory_rss:278179840
used_memory_peak:265875032
used_memory_peak_human:253.56M
used_memory_lua:35840
mem_fragmentation_ratio:1.06
mem_allocator:jemalloc-3.6.0
字段分析:
• used_memory: Total number of bytes allocated by Redis using its allocator (either standard libc, jemalloc, or an alternative allocator such as tcmalloc) (Redis使用其分配器分配的总字节数)
• used_memory_human: Human readable representation of previous value (Redis使用其分配器分配的值,人类可读)
• used_memory_rss: Number of bytes that Redis allocated as seen by the operating system (a.k.a resident set size). This is the number reported by tools such as top(1) and ps(1) (操作系统看到的Redis分配的字节数)
• used_memory_peak: Peak memory consumed by Redis (in bytes) (Redis消耗的峰值内存)
• used_memory_peak_human: Human readable representation of previous value
• used_memory_lua: Number of bytes used by the Lua engine (Lua引擎使用的字节数)
• mem_fragmentation_ratio: Ratio between used_memory_rss and used_memory (used_memory_rss和used_memory之间的比率)
• mem_allocator: Memory allocator, chosen at compile time (内存分配器,在编译时选择)
备注:
理想情况下,used_memory_rss值应仅略高于used_memory。 当rss >> used 时,差异很大意味着存在内存碎片 (internal or external),可以通过检查mem_fragmentation_ratio来评估。当 used >> rss,这意味着Redis内存的一部分已被操作系统调用其他占用了,这会导致访问Redis时产生一些延迟。
由于Redis无法控制其分配如何映射到内存页面,因此高used_memory_rss通常是内存使用量激增的结果。
persistence
命令结果:
营销测试:0>info persistence
# Persistence
loading:0
rdb_changes_since_last_save:169
rdb_bgsave_in_progress:0
rdb_last_save_time:1564383418
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:31
rdb_current_bgsave_time_sec:-1
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_last_write_status:ok
字段分析:
• loading: Flag indicating if the load of a dump file is on-going (转储文件的加载是否正在进行的标志)
• rdb_changes_since_last_save: Number of changes since the last dump (自上次转储以来的更改数)
• rdb_bgsave_in_progress: Flag indicating a RDB save is on-going (RDB保存是否正在进行的标识)
• rdb_last_save_time: Epoch-based timestamp of last successful RDB save (上次成功RDB保存的基于纪元的时间戳)
• rdb_last_bgsave_status: Status of the last RDB save operation (最后一次RDB保存是否成功)
• rdb_last_bgsave_time_sec: Duration of the last RDB save operation in seconds (最后一次RDB保存操作的持续时间,以秒为单位)
• rdb_current_bgsave_time_sec: Duration of the on-going RDB save operation if any
rdb_last_cow_size: The size in bytes of copy-on-write allocations during the last RBD save operation (上一次RBD保存操作期间写时复制分配的字节大小)• aof_enabled: Flag indicating AOF logging is activated
• aof_rewrite_in_progress: Flag indicating a AOF rewrite operation is on-going
• aof_rewrite_scheduled: Flag indicating an AOF rewrite operation will be scheduled once the on-going RDB save is complete.
• aof_last_rewrite_time_sec: Duration of the last AOF rewrite operation in seconds
• aof_current_rewrite_time_sec: Duration of the on-going AOF rewrite operation if any
• aof_last_bgrewrite_status: Status of the last AOF rewrite operation
• aof_last_write_status: Status of the last write operation to the AOF
• aof_last_cow_size: The size in bytes of copy-on-write allocations during the last AOF rewrite operation
stats
命令结果:
营销测试:0>info stats
# Stats
total_connections_received:6113
total_commands_processed:264746
instantaneous_ops_per_sec:0
total_net_input_bytes:12067215
total_net_output_bytes:52412027
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:3
evicted_keys:0
keyspace_hits:66766
keyspace_misses:8293
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:2562356
migrate_cached_sockets:0
字段分析:
• total_connections_received: Total number of connections accepted by the server (服务器接受的连接总数)
• total_commands_processed: Total number of commands processed by the server (服务器处理的命令总数)
• instantaneous_ops_per_sec: Number of commands processed per second (每秒处理的命令数)
• total_net_input_bytes: The total number of bytes read from the network (从网络读取的总字节数)
• total_net_output_bytes: The total number of bytes written to the network (写入网络的总字节数)
• instantaneous_input_kbps: The network’s read rate per second in KB/sec (网络的每秒读取速率,以KB /秒为单位)
• instantaneous_output_kbps: The network’s write rate per second in KB/sec (网络的每秒写入速率,以KB /秒为单位)
• rejected_connections: Number of connections rejected because of maxclients limit (由于maxclients限制而被拒绝的连接数)
• sync_full: The number of full resyncs with replicas
• sync_partial_ok: The number of accepted partial resync requests
• sync_partial_err: The number of denied partial resync requests
• expired_keys: Total number of key expiration events (key到期事件的总数)
• evicted_keys: Number of evicted keys due to maxmemory limit (由于maxmemory限制而被驱逐的密钥数量)
• keyspace_hits: Number of successful lookup of keys in the main dictionary (主字典中键的成功查找次数)
• keyspace_misses: Number of failed lookup of keys in the main dictionary (主字典中键的查找失败次数)
• pubsub_channels: Global number of pub/sub channels with client subscriptions (具有客户端订阅的全局pub / sub通道数)
• pubsub_patterns: Global number of pub/sub pattern with client subscriptions
• latest_fork_usec: Duration of the latest fork operation in microseconds
• migrate_cached_sockets: The number of sockets open for MIGRATE purposes
replication
命令结果:
营销测试:0>info replication
# 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
字段说明:
• role: Value is “master” if the instance is replica of no one, or “slave” if the instance is a replica of some master instance. Note that a replica can be master of another replica (chained replication).
• connected_slaves: Number of connected replicas
• master_repl_offset: The server’s current replication offset
• repl_backlog_active: Flag indicating replication backlog is active
• repl_backlog_size: Total size in bytes of the replication backlog buffer
• repl_backlog_first_byte_offset: The master offset of the replication backlog buffer
• repl_backlog_histlen: Size in bytes of the data in the replication backlog buffer
cpu
命令结果:
营销测试:0>info cpu
"# CPU
used_cpu_sys:328.35
used_cpu_user:168.55
used_cpu_sys_children:234.90
used_cpu_user_children:1554.65
字段说明:
- used_cpu_sys: System CPU consumed by the Redis server
- used_cpu_user:User CPU consumed by the Redis server
- used_cpu_sys_children: System CPU consumed by the background processes
- used_cpu_user_children: User CPU consumed by the background processes
commandstats
调用次数(calls),这些命令消耗的总CPU时间(usec)以及每个命令执行所消耗的平均CPU时间(usec_per_call)。
营销测试:0>info commandstats
# Commandstats
cmdstat_get:calls=20354,usec=635227,usec_per_call=31.21
cmdstat_setex:calls=132,usec=52772,usec_per_call=399.79
cmdstat_exists:calls=3,usec=51,usec_per_call=17.00
cmdstat_lpush:calls=1,usec=258,usec_per_call=258.00
cmdstat_hset:calls=9778,usec=3244155,usec_per_call=331.78
cmdstat_hget:calls=80836,usec=9376850,usec_per_call=116.00
cmdstat_hmset:calls=129,usec=61467,usec_per_call=476.49
cmdstat_hincrby:calls=148,usec=16559,usec_per_call=111.89
cmdstat_hdel:calls=268,usec=15965,usec_per_call=59.57
cmdstat_hvals:calls=50,usec=12155,usec_per_call=243.10
cmdstat_hgetall:calls=32088,usec=2823967,usec_per_call=88.01
cmdstat_incrby:calls=1185,usec=476440,usec_per_call=402.06
cmdstat_select:calls=17,usec=358,usec_per_call=21.06
cmdstat_expire:calls=1,usec=37,usec_per_call=37.00
cmdstat_auth:calls=9176,usec=312602,usec_per_call=34.07
cmdstat_ping:calls=298832,usec=4627400,usec_per_call=15.48
cmdstat_info:calls=19,usec=9877,usec_per_call=519.84
cluster
命令结果:
营销测试:0>info cluster
"# Cluster
cluster_enabled:0
字段说明:
- cluster_enabled: Indicate Redis cluster is enabled
keyspace
在每个数据库的主词典上。 统计信息是key数和到期key数。
营销测试:0>info 营销测试:0>keyspace
"# Keyspace
db0:keys=42792,expires=2,avg_ttl=4736072