Home >Database >Redis >In-depth analysis of the Info command in Redis

In-depth analysis of the Info command in Redis

青灯夜游
青灯夜游forward
2021-10-14 10:57:102948browse

This article will introduce you to the Info command in Redis. I hope it will be helpful to you!

In-depth analysis of the Info command in Redis

#Redis provides the info command, which returns various information and statistical values ​​about the Redis server. When using Redis, we often encounter some difficult problems that require us to troubleshoot. At this time, we can use the info command to obtain the running status of Redis, and then troubleshoot the problem. [Related recommendations: Redis Video Tutorial]

By giving the optional parameter section, the command can only return a certain part of the information:

  • server: General information about the Redis server

  • clients: The connection part of the client

  • memory: Memory consumption related information

  • persistence: RDB and AOF related information

  • stats: general statistics

  • replication: master/slave replication information

  • cpu: Statistics of CPU consumption

  • commandstats: Redis command statistics

  • cluster: Redis cluster information

  • keyspace: Database related statistics

It can also take the following values:

  • all: Return all Information
  • default: Value returns the information of the default settings

If no parameters are used, the default is default and all information is returned.

info/info all

Return all information of Redis service

# Server
redis_version:6.2.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:fa652e749408dcfd
redis_mode:standalone
os:Linux 3.10.0-327.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:9.3.1
process_id:4617
process_supervised:no
run_id:9662797d01b55345cd6cabad38d102e27db19e66
tcp_port:6379
server_time_usec:1632494557942546
uptime_in_seconds:4
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:5104605
executable:/usr/local/soft/redis-6.2.4/src/redis-server
config_file:/usr/local/soft/redis-6.2.4/redis.conf
io_threads_active:0

# Clients
connected_clients:1
cluster_connections:0
maxclients:10000
client_recent_max_input_buffer:16
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0

# Memory
used_memory:874728
used_memory_human:854.23K
used_memory_rss:10207232
used_memory_rss_human:9.73M
used_memory_peak:932800
used_memory_peak_human:910.94K
used_memory_peak_perc:93.77%
used_memory_overhead:830808
used_memory_startup:810168
used_memory_dataset:43920
used_memory_dataset_perc:68.03%
allocator_allocated:1036080
allocator_active:1380352
allocator_resident:3932160
total_system_memory:1913507840
total_system_memory_human:1.78G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:104857600
maxmemory_human:100.00M
maxmemory_policy:volatile-lfu
allocator_frag_ratio:1.33
allocator_frag_bytes:344272
allocator_rss_ratio:2.85
allocator_rss_bytes:2551808
rss_overhead_ratio:2.60
rss_overhead_bytes:6275072
mem_fragmentation_ratio:12.27
mem_fragmentation_bytes:9375272
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:20496
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0

# Persistence
loading: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:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1632494553
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size: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_last_write_status:ok
aof_last_cow_size:0
module_fork_in_progress:0
module_fork_last_cow_size:0

# Stats
total_connections_received:1
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:31
total_net_output_bytes:20324
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:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns: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
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_error_replies:0
dump_payload_sanitizations:0
total_reads_processed:2
total_writes_processed:1
io_threaded_reads_processed:0
io_threaded_writes_processed:0

# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:5b43385d46f4a601c025cb2c4ce5706b0b77db86
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:0.030666
used_cpu_user:0.000000
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
used_cpu_sys_main_thread:0.030570
used_cpu_user_main_thread:0.000000

# Modules

# Errorstats

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=2,expires=0,avg_ttl=0

info server

The following is all server related information

Parameter name Meaning
redis_version Redis server version
redis_git_sha1 Git SHA1
redis_git_dirty Git dirty flag
redis_build_id Build ID
redis_mode Server mode (standalone, sentinel or cluster)
os Host operating system of Redis server
arch_bits Architecture (32 or 64 bits)
multiplexing_api Event handling mechanism used by Redis
atomicvar_api Atomicvar API used by Redis
gcc_version The GCC version used when compiling Redis
process_id PID of the server process
run_id Random identifier of the Redis server (for Sentinel and cluster)
tcp_port TCP/IP listening port
uptime_in_seconds Seconds elapsed since the Redis server started Number
uptime_in_days The number of days that have passed since the Redis server started
hz The server Frequency setting
lru_clock A clock that increments in minutes for LRU management
executable Server executable file path
config_file Configuration file path

In-depth analysis of the Info command in Redis

info clients

The following is information related to all clients

Parameter name Meaning
connected_clients The number of connected clients (excluding connections via slave servers client)
client_longest_output_list The longest output list among the currently connected clients
client_biggest_input_buf Maximum input cache among currently connected clients
blocked_clients The number of clients that are waiting for blocking commands (BLPOP, BRPOP, BRPOPLPUSH)

In-depth analysis of the Info command in Redis

info memory

The following is all memory related information

##used_memoryAssigned by the Redis allocator Total memory, in bytesused_memory_humanReturns the total amount of memory allocated by Redis in human-readable formatused_memory_rssFrom 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 commands such as top and ps. used_memory_peakPeak memory consumption of Redis in bytes used_memory_peak_human Returns the peak memory consumption of Redis in human-readable formatused_memory_peak_percUsed memory as a percentage of peak memory used_memory_overheadThe sum (in bytes) of all overhead allocated by the server to manage its internal data structuresused_memory_startupRedis at startup Initial memory size consumed (in bytes)used_memory_datasetDataset size in bytes (used_memory minus used_memory_overhead)used_memory_dataset_percused_memory_dataset as a percentage of net memory usage (used_memory minus used_memory_startup) total_system_memoryRedis The total amount of memory the host hastotal_system_memory_humanReturns the total amount of memory the Redis host has in human-readable formatused_memory_luaThe memory size (in bytes) used by the Lua engineused_memory_lua_humanReturns the Lua engine in human-readable format The size of memory usedmaxmemoryThe value of the maxmemory configuration directivemaxmemory_humanIn human Returns the value of the maxmemory configuration directive in a readable formatmaxmemory_policyThe value of the maxmemory-policy configuration directivemem_fragmentation_ratioThe ratio between used_memory_rss and used_memorymem_allocatorSpecified at compile time, the memory allocator used by Redis. Can be libc, jemalloc or tcmallocactive_defrag_runningFlag indicating whether active defragmentation is activelazyfree_pending_objectsNumber of objects waiting to be released (due to calling UNLINK or FLUSHDB and FLUSHALL with the ASYNC option)

Ideally, the value of used_memory_rss should be only slightly higher than used_memory. When rss > used , and the difference between the two values ​​is large, it indicates the existence of (internal or external) memory fragmentation. The ratio of memory fragmentation can be seen through the value of mem_fragmentation_ratio. When used > rss, it means that part of the memory of Redis has been swapped out to the swap space by the operating system. In this case, the operation may cause significant delays. Since Redis has no control over how its allocated memory is mapped into memory pages, high resident memory (used_memory_rss) is usually the result of a spike in memory usage. When Redis frees memory, the memory is returned to the allocator, which may or may not return the memory to the operating system. If Redis releases memory but does not return the memory to the operating system, the value of used_memory may not be consistent with the memory usage of Redis displayed by the operating system. Checking the value of used_memory_peak can verify whether this is happening.

In-depth analysis of the Info command in Redis

info persistence

The following is all persistence related information:

Parameter name Meaning
##loadingInstructions to transfer A flag indicating whether the loading of the dump file is in progressrdb_changes_since_last_saveThe number of changes since the last dumprdb_bgsave_in_progressFlag indicating whether the RDB file is being savedrdb_last_save_timeThe epoch-based timestamp of the last successful RDB saverdb_last_bgsave_statusThe status of the last RDB save operation##rdb_last_bgsave_time_secrdb_current_bgsave_time_sec rdb_last_cow_sizeaof_enabledaof_rewrite_in_progressaof_rewrite_scheduledaof_last_rewrite_time_secaof_current_rewrite_time_secaof_last_bgrewrite_statusaof_last_write_statusaof_last_cow_size##changes_since_last_save refers to the time since the last call to SAVE or BGSAVE. The number of operations that produced some change in the data set.
Parameter name Meaning
The duration of the last RDB save operation (in seconds)
Duration of the ongoing RDB save operation (if any)
The size of bytes allocated by copy-on-write during the last RDB save operation
Flag indicating that the AOF record has been activated
Indicates that the AOF rewrite operation is in progress.
Indicates that once it is in progress When the RDB save operation is completed, the AOF rewrite operation will be scheduled.
The duration of the last AOF rewrite operation, in seconds
The duration of the ongoing AOF rewrite operation (if any)
The status of the last AOF rewrite operation
The status of the last AOF write operation
The byte size allocated by copy-on-write during the last AOF rewrite operation

In-depth analysis of the Info command in RedisAOF

If AOF is enabled, these additional fields are added:

Parameter name##aof_current_sizeCurrent AOF file sizeAOF file size when last started or rewrittenFlag indicating whether the AOF rewrite operation will be executed immediately after the current RDB save operation is completed. AOF buffer sizeAOF rewrite buffer sizeThe number of tasks waiting for fsync processing in the background IO queueDelayed fsync counter loading
Meaning
aof_base_size
aof_pending_rewrite
aof_buffer_length
aof_rewrite_buffer_length
aof_pending_bio_fsync
aof_delayed_fsync

If a loading operation is in progress, these additional fields will be added:

Parameter name##loading_start_timeStart time of loading operation (epoch-based timestamp) loading_total_bytesTotal file sizeloading_loaded_bytes Number of bytes loadedloading_loaded_percPercent loadedloading_eta_secondsEstimated number of seconds remaining until loading is complete

status

The following is information related to all stats:

Meaning
Parameter name Meaning
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
rejected_connections Number of connections rejected due to maxclients limit
expired_keys Total number of key expiration events
evicted_keys The number of keys evicted due to maxmemory limit
keyspace_hits The number of times the key was successfully found in the main dictionary
keyspace_misses Number of failed key lookups in the main dictionary
pubsub_channels Owning client Number of global pub/sub channels subscribed
pubsub_patterns Number of global pub/sub patterns subscribed by the client
latest_fork_usec The duration of the latest fork operation, in microseconds

info replication

The following is All replication related information:

Parameter name Meaning
role If the instance is not a slave node of any node, the value is "master", if the instance synchronizes data from a node, it is "slave". Note that a slave node can be the master of another slave node (daisy chain)

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

##master_hostHost name or IP address of the master nodemaster_portThe TCP port the master node listens onmaster_link_statusConnection status (up or down)master_last_io_seconds_agoThe number of seconds that have passed since the last interaction with the master node master_sync_in_progressIndicates that the master node is synchronizing with the slave node
Parameter name Meaning
If a SYNC operation is in progress, it will Provide the following fields:

master_sync_left_bytesThe number of bytes remaining before synchronization is completedmaster_sync_last_io_seconds_agoSince the last time during a SYNC operation The number of seconds since the IO was transferred
Parameter name Meaning
If the connection between the master and slave nodes is lost, an additional field will be provided:

##master_link_down_since_seconds The following fields will always be provided:
Parameter name Meaning
The number of seconds that have elapsed since the connection was lost

Parameter nameMeaning##connected_slavesThe number of connected slave nodes For each slave node, the following lines will be added: slaveXXX id, address, port number, status

In-depth analysis of the Info command in Redisinfo CPU

The following is all cpu related information:

Parameter name## used_cpu_sysSystem CPU consumed by the Redis serverUser CPU consumed by the Redis serverSystem CPU consumed by background processesUser CPU consumed by background processes
Meaning
used_cpu_user
used_cpu_sys_children
used_cpu_user_children

info clusterIn-depth analysis of the Info command in Redis

The cluster section currently contains only one unique field:

Parameter nameIndicates that Redis cluster is enabledinfo keyspace
##Meaning ##cluster_enabled

In-depth analysis of the Info command in RedisThe keyspace section provides information about each Statistics of the main dictionary of the database. The statistical information is the total number of keys and the total number of expired keys. For each database, provide the following lines:

Parameter name

MeaningdbXXX keys=XXX,expires=XXX
keyspace

In-depth analysis of the Info command in Redis

This article is reproduced from: https://juejin.cn/post/7014398047916883998

For more programming-related knowledge, please visit : Programming Video! !

The above is the detailed content of In-depth analysis of the Info command in Redis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.cn. If there is any infringement, please contact admin@php.cn delete