天天看點

INFO [section]

<code>INFO</code>指令以一種易于了解和閱讀的格式,傳回關于Redis伺服器的各種資訊和統計數值。

通過給定可選的參數 section ,可以讓指令隻傳回某一部分的資訊:

<code>server</code>: Redis伺服器的一般資訊

<code>clients</code>: 用戶端的連接配接部分

<code>memory</code>: 記憶體消耗相關資訊

<code>persistence</code>: RDB和AOF相關資訊

<code>stats</code>: 一般統計

<code>replication</code>: 主/從複制資訊

<code>cpu</code>: 統計CPU的消耗

<code>commandstats</code>: Redis指令統計

<code>cluster</code>: Redis叢集資訊

<code>keyspace</code>: 資料庫的相關統計

它也可以采取以下值:

<code>all</code>: 傳回所有資訊

<code>default</code>: 值傳回預設設定的資訊

如果沒有使用任何參數時,預設為<code>default</code>。

##傳回值

bulk-string-reply: 文本行的合集

每一行包含了包含一種資訊或者屬性(從#字元開始)。 所有的屬性都是以字段:值(<code>field:value</code>)的形式,已<code>\r\n</code>結尾。

##例子

請注意不同Redis版本會添加或者删除一些字段。一個健壯的用戶端應用解析該指令的結果時,應該跳過未知的字段,并且優雅的處理缺少的字段。

已下描述要求 Redis &gt;= 2.4

下面是所有 server 相關的資訊:

<code>redis_version</code>: Redis 伺服器版本

<code>redis_git_sha1</code>: Git SHA1

<code>redis_git_dirty</code>: Git dirty flag

<code>os</code>: Redis 伺服器的宿主作業系統

<code>arch_bits</code>: 架構(32 或 64 位)

<code>multiplexing_api</code>: Redis 所使用的事件處理機制

<code>gcc_version</code>: 編譯 Redis 時所使用的 GCC 版本

<code>process_id</code>: 伺服器程序的 PID

<code>run_id</code>: Redis 伺服器的随機辨別符(用于 Sentinel 和叢集)

<code>tcp_port</code>: TCP/IP 監聽端口

<code>uptime_in_seconds</code>: 自 Redis 伺服器啟動以來,經過的秒數

<code>uptime_in_days</code>: 自 Redis 伺服器啟動以來,經過的天數

<code>lru_clock</code>: 以分鐘為機關進行自增的時鐘,用于 LRU 管理

下面是所有 clients 相關的資訊:

<code>connected_clients</code>: 已連接配接用戶端的數量(不包括通過從屬伺服器連接配接的用戶端)

<code>client_longest_output_list</code>: 目前連接配接的用戶端當中,最長的輸出清單

<code>client_biggest_input_buf</code>: 目前連接配接的用戶端當中,最大輸入緩存

<code>blocked_clients</code>: 正在等待阻塞指令(BLPOP、BRPOP、BRPOPLPUSH)的用戶端的數量

下面是所有 memory 相關的資訊:

<code>used_memory</code>: 由 Redis 配置設定器配置設定的記憶體總量,以位元組(byte)為機關

<code>used_memory_human</code>: 以人類可讀的格式傳回 Redis 配置設定的記憶體總量

<code>used_memory_rss</code>: 從作業系統的角度,傳回 Redis 已配置設定的記憶體總量(俗稱常駐集大小)。這個值和 top 、 ps 等指令的輸出一緻。

<code>used_memory_peak</code>: Redis 的記憶體消耗峰值(以位元組為機關)

<code>used_memory_peak_human</code>: 以人類可讀的格式傳回 Redis 的記憶體消耗峰值

<code>used_memory_lua</code>: Lua 引擎所使用的記憶體大小(以位元組為機關)

<code>mem_fragmentation_ratio</code>: <code>used_memory_rss</code> 和 <code>used_memory</code> 之間的比率

<code>mem_allocator</code>: 在編譯時指定的, Redis 所使用的記憶體配置設定器。可以是 libc 、 jemalloc 或者 tcmalloc 。 在理想情況下, used_memory_rss 的值應該隻比 used_memory 稍微高一點兒。

當 rss &gt; used ,且兩者的值相差較大時,表示存在(内部或外部的)記憶體碎片。

記憶體碎片的比率可以通過 mem_fragmentation_ratio 的值看出。

當 used &gt; rss 時,表示 Redis 的部分記憶體被作業系統換出到交換空間了,在這種情況下,操作可能會産生明顯的延遲。

當 Redis 釋放記憶體時,配置設定器可能會,也可能不會,将記憶體返還給作業系統。

如果 Redis 釋放了記憶體,卻沒有将記憶體返還給作業系統,那麼 used_memory 的值可能和作業系統顯示的 Redis 記憶體占用并不一緻。

檢視 used_memory_peak 的值可以驗證這種情況是否發生。

下面是所有 persistence 相關的資訊:

<code>loading</code>: Flag indicating if the load of a dump file is on-going

<code>rdb_changes_since_last_save</code>: Number of changes since the last dump

<code>rdb_bgsave_in_progress</code>: Flag indicating a RDB save is on-going

<code>rdb_last_save_time</code>: Epoch-based timestamp of last successful RDB save

<code>rdb_last_bgsave_status</code>: Status of the last RDB save operation

<code>rdb_last_bgsave_time_sec</code>: Duration of the last RDB save operation in seconds

<code>rdb_current_bgsave_time_sec</code>: Duration of the on-going RDB save operation if any

<code>aof_enabled</code>: Flag indicating AOF logging is activated

<code>aof_rewrite_in_progress</code>: Flag indicating a AOF rewrite operation is on-going

<code>aof_rewrite_scheduled</code>: Flag indicating an AOF rewrite operation will be scheduled once the on-going RDB save is complete.

<code>aof_last_rewrite_time_sec</code>: Duration of the last AOF rewrite operation in seconds

<code>aof_current_rewrite_time_sec</code>: Duration of the on-going AOF rewrite operation if any

<code>aof_last_bgrewrite_status</code>: Status of the last AOF rewrite operation

<code>changes_since_last_save</code> refers to the number of operations that produced some kind of changes in the dataset since the last time either <code>SAVE</code> or <code>BGSAVE</code>was called.

If AOF is activated, these additional fields will be added:

<code>aof_current_size</code>: AOF current file size

<code>aof_base_size</code>: AOF file size on latest startup or rewrite

<code>aof_pending_rewrite</code>: Flag indicating an AOF rewrite operation will be scheduled once the on-going RDB save is complete.

<code>aof_buffer_length</code>: Size of the AOF buffer

<code>aof_rewrite_buffer_length</code>: Size of the AOF rewrite buffer

<code>aof_pending_bio_fsync</code>: Number of fsync pending jobs in background I/O queue

<code>aof_delayed_fsync</code>: Delayed fsync counter

If a load operation is on-going, these additional fields will be added:

<code>loading_start_time</code>: Epoch-based timestamp of the start of the load operation

<code>loading_total_bytes</code>: Total file size

<code>loading_loaded_bytes</code>: Number of bytes already loaded

<code>loading_loaded_perc</code>: Same value expressed as a percentage

<code>loading_eta_seconds</code>: ETA in seconds for the load to be complete

下面是所有 stats 相關的資訊:

<code>total_connections_received</code>: Total number of connections accepted by the server

<code>total_commands_processed</code>: Total number of commands processed by the server

<code>instantaneous_ops_per_sec</code>: Number of commands processed per second

<code>rejected_connections</code>: Number of connections rejected because of <code>maxclients</code> limit

<code>expired_keys</code>: Total number of key expiration events

<code>evicted_keys</code>: Number of evicted keys due to <code>maxmemory</code> limit

<code>keyspace_hits</code>: Number of successful lookup of keys in the main dictionary

<code>keyspace_misses</code>: Number of failed lookup of keys in the main dictionary

<code>pubsub_channels</code>: Global number of pub/sub channels with client subscriptions

<code>pubsub_patterns</code>: Global number of pub/sub pattern with client subscriptions

<code>latest_fork_usec</code>: Duration of the latest fork operation in microseconds

下面是所有 replication 相關的資訊:

<code>role</code>: Value is “master” if the instance is slave of no one, or “slave” if the instance is enslaved to a master. Note that a slave can be master of another slave (daisy chaining).

If the instance is a slave, these additional fields are provided:

<code>master_host</code>: Host or IP address of the master

<code>master_port</code>: Master listening TCP port

<code>master_link_status</code>: Status of the link (up/down)

<code>master_last_io_seconds_ago</code>: Number of seconds since the last interaction with master

<code>master_sync_in_progress</code>: Indicate the master is syncing to the slave

If a SYNC operation is on-going, these additional fields are provided:

<code>master_sync_left_bytes</code>: Number of bytes left before syncing is complete

<code>master_sync_last_io_seconds_ago</code>: Number of seconds since last transfer I/O during a SYNC operation

If the link between master and slave is down, an additional field is provided:

<code>master_link_down_since_seconds</code>: Number of seconds since the link is down

The following field is always provided:

<code>connected_slaves</code>: Number of connected slaves

For each slave, the following line is added:

<code>slaveXXX</code>: id, IP address, port, state

下面是所有 cpu 相關的資訊:

<code>used_cpu_sys</code>: System CPU consumed by the Redis server

<code>used_cpu_user</code>:User CPU consumed by the Redis server

<code>used_cpu_sys_children</code>: System CPU consumed by the background processes

<code>used_cpu_user_children</code>: User CPU consumed by the background processes

The commandstats section provides statistics based on the command type, including the number of calls, the total CPU time consumed by these commands, and the average CPU consumed per command execution.

For each command type, the following line is added:

<code>cmdstat_XXX</code>: <code>calls=XXX,usec=XXX,usec_per_call=XXX</code>

The cluster section currently only contains a unique field:

<code>cluster_enabled</code>: Indicate Redis cluster is enabled

The keyspace section provides statistics on the main dictionary of each database. The statistics are the number of keys, and the number of keys with an expiration.

For each database, the following line is added:

<code>dbXXX</code>: <code>keys=XXX,expires=XXX</code>

本文作者:陳群

本文來自雲栖社群合作夥伴rediscn,了解相關資訊可以關注redis.cn網站。

繼續閱讀