In-depth analysis of the Info command in Redis
This article will introduce you to the Info command in Redis. I hope it will be helpful to you!
#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 |
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) |
info memory
The following is all memory related information
Parameter name | Meaning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Assigned by the Redis allocator Total memory, in bytes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Returns the total amount of memory allocated by Redis in human-readable format | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 commands such as top and ps. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Peak memory consumption of Redis in bytes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Returns the peak memory consumption of Redis in human-readable format | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Used memory as a percentage of peak memory | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The sum (in bytes) of all overhead allocated by the server to manage its internal data structures | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Redis at startup Initial memory size consumed (in bytes) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dataset size in bytes (used_memory minus used_memory_overhead) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
used_memory_dataset as a percentage of net memory usage (used_memory minus used_memory_startup) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Redis The total amount of memory the host has | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Returns the total amount of memory the Redis host has in human-readable format | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The memory size (in bytes) used by the Lua engine | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Returns the Lua engine in human-readable format The size of memory used | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The value of the maxmemory configuration directive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
In human Returns the value of the maxmemory configuration directive in a readable format | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The value of the maxmemory-policy configuration directive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The ratio between used_memory_rss and used_memory | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Specified at compile time, the memory allocator used by Redis. Can be libc, jemalloc or tcmalloc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Flag indicating whether active defragmentation is active | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Number of objects waiting to be released (due to calling UNLINK or FLUSHDB and FLUSHALL with the ASYNC option) |
Parameter name | Meaning |
---|---|
Instructions to transfer A flag indicating whether the loading of the dump file is in progress | |
The number of changes since the last dump | |
Flag indicating whether the RDB file is being saved | |
The epoch-based timestamp of the last successful RDB save | |
The status of the last RDB save operation | |
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 |
AOF
If AOF is enabled, these additional fields are added:
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:
Meaning | ##loading_start_time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
loading_total_bytes | Total file size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
loading_loaded_bytes | Number of bytes loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
loading_loaded_perc | Percent loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
loading_eta_seconds | Estimated number of seconds remaining until loading is complete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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:
Parameter name | Meaning |
---|---|
Host name or IP address of the master node | |
The TCP port the master node listens on | |
Connection status (up or down) | |
The number of seconds that have passed since the last interaction with the master node | |
Indicates that the master node is synchronizing with the slave node |
Parameter name | Meaning |
---|---|
The number of bytes remaining before synchronization is completed | |
Since the last time during a SYNC operation The number of seconds since the IO was transferred |
Parameter name | Meaning |
---|---|
The number of seconds that have elapsed since the connection was lost |
Meaning | |
---|---|
info CPU
The following is all cpu related information:
Meaning | |
---|---|
used_cpu_user | |
used_cpu_sys_children | |
used_cpu_user_children | |
info cluster
The cluster section currently contains only one unique field:
##Meaning | ##cluster_enabled |
---|---|
The 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
keyspace | |
---|---|
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Redis cluster mode deploys Redis instances to multiple servers through sharding, improving scalability and availability. The construction steps are as follows: Create odd Redis instances with different ports; Create 3 sentinel instances, monitor Redis instances and failover; configure sentinel configuration files, add monitoring Redis instance information and failover settings; configure Redis instance configuration files, enable cluster mode and specify the cluster information file path; create nodes.conf file, containing information of each Redis instance; start the cluster, execute the create command to create a cluster and specify the number of replicas; log in to the cluster to execute the CLUSTER INFO command to verify the cluster status; make

How to clear Redis data: Use the FLUSHALL command to clear all key values. Use the FLUSHDB command to clear the key value of the currently selected database. Use SELECT to switch databases, and then use FLUSHDB to clear multiple databases. Use the DEL command to delete a specific key. Use the redis-cli tool to clear the data.

To read a queue from Redis, you need to get the queue name, read the elements using the LPOP command, and process the empty queue. The specific steps are as follows: Get the queue name: name it with the prefix of "queue:" such as "queue:my-queue". Use the LPOP command: Eject the element from the head of the queue and return its value, such as LPOP queue:my-queue. Processing empty queues: If the queue is empty, LPOP returns nil, and you can check whether the queue exists before reading the element.

Using the Redis directive requires the following steps: Open the Redis client. Enter the command (verb key value). Provides the required parameters (varies from instruction to instruction). Press Enter to execute the command. Redis returns a response indicating the result of the operation (usually OK or -ERR).

Using Redis to lock operations requires obtaining the lock through the SETNX command, and then using the EXPIRE command to set the expiration time. The specific steps are: (1) Use the SETNX command to try to set a key-value pair; (2) Use the EXPIRE command to set the expiration time for the lock; (3) Use the DEL command to delete the lock when the lock is no longer needed.

On CentOS systems, you can limit the execution time of Lua scripts by modifying Redis configuration files or using Redis commands to prevent malicious scripts from consuming too much resources. Method 1: Modify the Redis configuration file and locate the Redis configuration file: The Redis configuration file is usually located in /etc/redis/redis.conf. Edit configuration file: Open the configuration file using a text editor (such as vi or nano): sudovi/etc/redis/redis.conf Set the Lua script execution time limit: Add or modify the following lines in the configuration file to set the maximum execution time of the Lua script (unit: milliseconds)

Use the Redis command line tool (redis-cli) to manage and operate Redis through the following steps: Connect to the server, specify the address and port. Send commands to the server using the command name and parameters. Use the HELP command to view help information for a specific command. Use the QUIT command to exit the command line tool.

In Debian systems, readdir system calls are used to read directory contents. If its performance is not good, try the following optimization strategy: Simplify the number of directory files: Split large directories into multiple small directories as much as possible, reducing the number of items processed per readdir call. Enable directory content caching: build a cache mechanism, update the cache regularly or when directory content changes, and reduce frequent calls to readdir. Memory caches (such as Memcached or Redis) or local caches (such as files or databases) can be considered. Adopt efficient data structure: If you implement directory traversal by yourself, select more efficient data structures (such as hash tables instead of linear search) to store and access directory information
