After edis-cli connects to the server, use the info command to view Redis information and status:
1
|
info
|
The memory segment shows the memory usage status of redis.
The following is copied from: http://redisdoc.com/server/info.html
INFO [section]
Returns various information and statistics about the Redis server in an easy-to-parse and easy-to-read format.
By giving optional arguments section
, you can make the command return only a certain part of the information:
-
server
The section records information about the Redis server, which contains the following fields: -
redis_version
: Redis server version -
redis_git_sha1
: Git SHA1 -
redis_git_dirty
: Git dirty flag -
os
: The host operating system of the Redis server -
arch_bits
: Architecture (32 or 64 bit) -
multiplexing_api
: The event handling mechanism used by Redis -
gcc_version
: GCC version to use when compiling Redis -
process_id
: PID of the server process -
run_id
: Random identifier for the Redis server (for Sentinel and cluster) -
tcp_port
: TCP/IP listening port -
uptime_in_seconds
: the number of seconds elapsed since the Redis server started -
uptime_in_days
: Number of days since the Redis server started -
lru_clock
: self-incrementing clock in minutes for LRU management -
clients
The section records information about connected clients and contains the following fields: -
connected_clients
: the number of connected clients (excluding clients connected through slave servers) -
client_longest_output_list
: The longest output list among currently connected clients -
client_longest_input_buf
: Among the currently connected clients, the maximum input buffer -
blocked_clients
: number of clients waiting for blocking commands (BLPOP, BRPOP, BRPOPLPUSH) -
memory
The section records the server's memory information and contains the following fields:Ideally,
used_memory_rss
the value should be onlyused_memory
slightly higher than .When
rss > used
, and the difference between the two values is large, it means that there is (internal or external) memory fragmentation.The ratio of memory fragmentation can be
mem_fragmentation_ratio
seen by the value of .At the time
used > rss
, it means that part of Redis's memory was swapped out to swap space by the operating system, in which case the operation may incur significant delays.Because Redis does not have control over how its allocations are mapped to memory pages, high
used_memory_rss
is often the result of a spike in memory usage.When Redis frees memory, the allocator may or may not return the memory to the operating system.
If Redis frees the memory but does not return the memory to the operating system,
used_memory
the value may not be consistent with the Redis memory usage displayed by the operating system.View
used_memory_peak
the value to verify that this happens. -
used_memory
: The total amount of memory allocated by the Redis allocator, in bytes -
used_memory_human
: Returns the total amount of memory allocated by Redis in human readable format -
used_memory_rss
: From the perspective of the operating system, returns the total amount of memory allocated by Redis (commonly known as the resident set size). This value is consistent with the output of thetop
,ps
etc commands. -
used_memory_peak
: Redis peak memory consumption in bytes -
used_memory_peak_human
: returns the peak memory consumption of Redis in human readable format -
used_memory_lua
: size of memory used by the Lua engine (in bytes) -
mem_fragmentation_ratio
: the ratio betweenused_memory_rss
andused_memory
-
mem_allocator
: The memory allocator used by Redis, specified at compile time. Can be libc, jemalloc or tcmalloc. -
persistence
The section records information related toRDB
persistence andAOF
persistence, and it contains the following fields:If AOF persistence is enabled, the following fields are added to this section:
-
aof_current_size
: The current size of the AOF file. -
aof_base_size
: The size of the AOF file at server startup or since the last execution of AOF rewrite. -
aof_pending_rewrite
: A flag value that records whether an AOF rewrite operation is performed after waiting for the RDB file to be created. -
aof_buffer_length
: The size of the AOF buffer. -
aof_rewrite_buffer_length
: AOF rewrite buffer size. -
aof_pending_bio_fsync
fsync
: The number of calls waiting to be executed in the background I/O queue . -
aof_delayed_fsync
fsync
: The number of calls that were delayed . -
loading
: A flag value that records whether the server is loading persistent files. -
rdb_changes_since_last_save
: How many seconds have passed since the last successful persistent file creation. -
rdb_bgsave_in_progress
: A flag value that records whether the server is creating an RDB file. -
rdb_last_save_time
: UNIX timestamp of the last successful creation of the RDB file. -
rdb_last_bgsave_status
: A flag value that records the success or failure of the last creation of the RDB file. -
rdb_last_bgsave_time_sec
: Records the number of seconds it took to create the last RDB file. -
rdb_current_bgsave_time_sec
: If the server is creating an RDB file, then this field records the number of seconds the current creation operation has taken. -
aof_enabled
: A flag value that records whether AOF is on. -
aof_rewrite_in_progress
: A flag value that records whether the server is creating an AOF file. -
aof_rewrite_scheduled
: A flag value that records whether the reserved AOF rewrite operation needs to be performed after the RDB file is created. -
aof_last_rewrite_time_sec
: The last time the AOF file was created. -
aof_current_rewrite_time_sec
: If the server is creating an AOF file, then this field records the number of seconds the current creation operation has spent. -
aof_last_bgrewrite_status
: A flag value that records the success or failure of the most recent AOF file creation. -
stats
The section documents general statistics and contains the following fields: -
total_connections_received
: The number of connection requests accepted by the server. -
total_commands_processed
: The number of commands the server has executed. -
instantaneous_ops_per_sec
: The number of commands the server executes per second. -
rejected_connections
: The number of connection requests rejected due to the maximum number of clients limit. -
expired_keys
: The number of database keys that were automatically deleted due to expiration. -
evicted_keys
: The number of keys that were evicted due to the maximum memory capacity limit. -
keyspace_hits
: The number of times the database key was found successfully. -
keyspace_misses
: The number of times that the lookup of the database key failed. -
pubsub_channels
: The number of channels currently subscribed to. -
pubsub_patterns
: The number of schemas currently subscribed to. -
latest_fork_usec
fork()
: The number of milliseconds the last operation took. -
replication
: master/slave replication informationIf the current server is a slave server, then this section will also add the following fields:
If a synchronization operation is in progress, this section also adds the following fields:
If the connection between the master and slave servers is disconnected, then this section will also add the following fields:
Here are some domains that always appear:
For each slave server, the following line of information is added:
-
slaveXXX
: ID, IP address, port number, connection status -
connected_slaves
: Number of connected slave servers. -
master_link_down_since_seconds
: How many seconds the master-slave server connection was disconnected. -
master_sync_left_bytes
: How many bytes of data are still missing until synchronization is complete. -
master_sync_last_io_seconds_ago
: The number of seconds that have passed since the last I/O due to a SYNC operation. -
master_host
: IP address of the master server. -
master_port
: The TCP listening port number of the master server. -
master_link_status
: Copy the current state of the connection,up
indicating that the connection is normal, anddown
that the connection is disconnected. -
master_last_io_seconds_ago
: The number of seconds since the last communication with the master server. -
master_sync_in_progress
: A flag value that records whether the master is synchronizing with this slave. -
role
: If the current server is not replicating any other servers, then the value of this field ismaster
; otherwise, the value of this field isslave
. Note that a slave server may also be the master of another server when creating a replication chain. -
cpu
The section records computation statistics for the CPU and contains the following fields: -
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 background processes. -
used_cpu_user_children
: User CPU consumed by background processes. -
commandstats
The section records execution statistics for various types of commands, such as the number of times the command was executed, the CPU time spent by the command, the average CPU time spent executing each command, and more. For each type of command, this section adds a line of information in the following format: -
cmdstat_XXX:calls=XXX,usec=XXX,usecpercall=XXX
-
cluster
The section documents information about the cluster and contains the following fields: -
cluster_enabled
: A flag value that records whether the cluster function has been enabled. -
keyspace
The part records database-related statistics, such as the number of keys in the database, the number of expired keys that have been deleted by the database, etc. For each database, this section adds a line of information in the following format: -
dbXXX:keys=XXX,expires=XXX
In addition to these values given above, the value of the section
parameter can also be the following two:
-
all
: return all information -
default
: Returns the information selected by default
When the INFO command is called directly without parameters , it is used default
as the default parameter.
Different versions of Redis may have added or removed some of the fields returned.
Therefore, a robust client program should be able to skip unrecognized fields when parsing the output of the INFO command, and handle missing fields gracefully.
-
Available versions:
-
>= 1.0.0
-
time complexity:
-
O(1)
-
return value:
-
See the test code below for details.
redis> INFO # Server redis_version:2.9.11 redis_git_sha1:937384d0 redis_git_dirty:0 redis_build_id:8e9509442863f22 redis_mode:standalone os:Linux 3.13.0-35-generic x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.8.2 process_id:4716 run_id:26186aac3f2380aaee9eef21cc50aecd542d97dc tcp_port:6379 uptime_in_seconds:362 uptime_in_days:0 hz:10 lru_clock:1725349 config_file: # Clients connected_clients:1 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Memory used_memory:508536 used_memory_human:496.62K used_memory_rss:7974912 used_memory_peak:508536 used_memory_peak_human:496.62K used_memory_lua:33792 mem_fragmentation_ratio:15.68 mem_allocator:jemalloc-3.2.0 # Persistence loading:0 rdb_changes_since_last_save:6 rdb_bgsave_in_progress:0 rdb_last_save_time:1411011131 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:-1 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:2 total_commands_processed:4 instantaneous_ops_per_sec:0 rejected_connections:0 sync_full:0 sync_partial_ok:0 sync_partial_err:0 expired_keys:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:0 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:0.21 used_cpu_user:0.17 used_cpu_sys_children:0.00 used_cpu_user_children:0.00 # Cluster cluster_enabled:0 # Keyspace db0:keys=2,expires=0,avg_ttl=0