20210609 Use of info command in redis

Info command usage summary (attribute name, attribute value, attribute description)

模块名			模块含义 Server			服务器信息Clients			客户端信息Memory			内存信息   Persistence		持久化信息Stats			全局统计信息(缓存命中率)Replication		复制信息CPU			    CPU消耗信息Commandstats	命令统计信息Cluster			集群信息Keyspace		数据库键统计信息

One, info Server

Contains some information about the Redis service itself, such as version number, operating mode, operating system version, TCP port, etc.

redis-test:0>info server"# Serverredis_version:5.0.6redis_git_sha1:00000000redis_git_dirty:0redis_build_id:c15635ea8e16946aredis_mode:standalone   os:Linux 2.6.32-504.23.4.el6.x86_64 x86_64arch_bits:64multiplexing_api:epollatomicvar_api:sync-builtingcc_version:4.4.7process_id:576150run_id:c90380b6bc2814e8018a94d9a2b4e44be80faf79tcp_port:50346uptime_in_seconds:1023294uptime_in_days:11hz:10configured_hz:10lru_clock:12611922executable:/opt/soft/redis50/bin/redis-serverconfig_file:/work/redis50346/redis50346.conf"

1. Redis_mode operating mode, redis operating mode is divided into: Cluster.Sentinel.Standalone;

2. The port monitored by tcp_port;

3. Uptime_in_seconds and uptime_in_days have been running in seconds and days since the Redis service was started;

4. config_file The location of the Redis configuration file;

Two , info Clients

The statistical information of the info Clients module includes the number of connections, the number of blocked command connections, input and output buffers and other related statistical information.

How to check the current connection information or how many connections are there ?

Redis>info clients{    "client_recent_max_output_buffer": 0,      "blocked_clients": 0,     "connected_clients": 51,     "client_recent_max_input_buffer": 2}

1. Number of connections: It is related to the configuration of the connection pool;

2. The number of blocked client connections: blocked_clients, which is generally caused by the BLPOP or BRPOP command of the list data type. This value should preferably be 0.

3. CLIENT common commands

CLIENT LIST Get the client list; the name field indicates the name of the current connection.

CLIENT SETNAME set the name of the current connection point redis;

CLIENT GETNAME view the name of the current connection;

CLIENT KILL ip:port kills the specified connection;

Three , info Memory

The statistical information of the info Memory module includes Redis memory usage, system memory usage, fragmentation rate, memory allocator and other related statistics.

Redis>info Memory{    "mem_clients_normal": 1789214,     "rss_overhead_ratio": 0.2,     "used_memory_peak_human": "1.04G",     "maxmemory_human": "2.00G",     "used_memory_dataset_perc": "2.68%",     "mem_not_counted_for_evict": 1320,     "used_memory_peak_perc": "99.66%",     "allocator_frag_ratio": 1.0,     "used_memory_lua_human": "37.00K",     "used_memory": 1113726728,     "used_memory_scripts": 0,     "maxmemory": 2147483648,     "used_memory_scripts_human": "0B",     "total_system_memory_human": "251.89G",     "allocator_rss_ratio": 1.01,     "allocator_frag_bytes": 633000,     "number_of_cached_scripts": 0,     "mem_replication_backlog": 1073741824,     "lazyfree_pending_objects": 0,     "allocator_rss_bytes": 10297344,     "mem_aof_buffer": 1320,     "rss_overhead_bytes": -897171456,     "allocator_allocated": 1113782104,     "mem_clients_slaves": 49694,     "maxmemory_policy": "volatile-lru",     "used_memory_startup": 791456,     "used_memory_human": "1.04G",     "active_defrag_running": 0,     "used_memory_dataset": 29816508,     "allocator_active": 1114415104,     "used_memory_lua": 37888,     "used_memory_overhead": 1083910220,     "total_system_memory": 270467923968,     "mem_allocator": "jemalloc-5.1.0",     "mem_fragmentation_bytes": -886164808,     "used_memory_peak": 1117551160,     "allocator_resident": 1124712448,     "used_memory_rss": 227540992,     "mem_fragmentation_ratio": 0.2,     "used_memory_rss_human": "217.00M"}

1. The maximum memory of maxmemory and maxmemory_human is 2G;

2. maxmemory_policy memory elimination strategy;

3. mem_fragmentation_ratio memory fragmentation rate

Persistence info

The statistical information of the info Persistence module includes some persistent statistical information of RDB and AOF.

redis-test:0>info Persistence "# Persistenceloading:0rdb_changes_since_last_save:1213741rdb_bgsave_in_progress:0rdb_last_save_time:1622201389rdb_last_bgsave_status:okrdb_last_bgsave_time_sec:0rdb_current_bgsave_time_sec:-1rdb_last_cow_size:278528aof_enabled:1aof_rewrite_in_progress:0aof_rewrite_scheduled:0aof_last_rewrite_time_sec:-1aof_current_rewrite_time_sec:-1aof_last_bgrewrite_status:okaof_last_write_status:okaof_last_cow_size:0aof_current_size:167953757aof_base_size:0aof_pending_rewrite:0aof_buffer_length:0aof_rewrite_buffer_length:0aof_pending_bio_fsync:0aof_delayed_fsync:0"

Five, info Stats

The statistical information of the info Stats module is the basic statistical information of Redis, including: connection, command, network, expiration, synchronization and many other statistical information

1. The number of rejected connections (rejected_connections) also needs attention. The ideal state of this value is 0. If it is greater than 0, it indicates that the number of connections created exceeds maxclients, and you need to troubleshoot the cause. Is the redis connection pool configuration unreasonable or too many services connected to this redis instance?

Redis>info Stats{    "active_defrag_key_hits": 0,     "rejected_connections": 0,     "pubsub_patterns": 0,     "expired_time_cap_reached_count": 0,     "sync_partial_ok": 0,     "migrate_cached_sockets": 0,     "keyspace_misses": 144363,     "total_net_output_bytes": 47355923253,     "active_defrag_hits": 0,     "slave_expires_tracked_keys": 0,     "expired_stale_perc": 0.0,     "instantaneous_ops_per_sec": 6011,     "total_commands_processed": 373073062,     "latest_fork_usec": 269,     "total_connections_received": 24517,     "sync_full": 1,     "active_defrag_misses": 0,     "pubsub_channels": 1,     "expired_keys": 0,     "active_defrag_key_misses": 0,     "total_net_input_bytes": 11914643391,     "evicted_keys": 0,     "instantaneous_input_kbps": 186.43,     "instantaneous_output_kbps": 737.4,     "sync_partial_err": 1,     "keyspace_hits": 249967588}

Six, info Replication

The statistical information of the info Replication module contains some statistical information of Redis master-slave replication. According to the master-slave node, the statistical information is slightly different.

redis-test:0>info Replication"# Replicationrole:masterconnected_slaves:1slave0:ip=10.166.254.236,port=50346,state=online,offset=389738337,lag=0master_replid:a4df37f43f87291a91a87a3ebc99bbdb9841f77cmaster_replid2:0000000000000000000000000000000000000000master_repl_offset:389738337second_repl_offset:-1repl_backlog_active:1repl_backlog_size:134217728repl_backlog_first_byte_offset:255520610repl_backlog_histlen:134217728"

Seven, info CPU

Info The statistics of the CPU module include some statistics about the CPU consumption of the Redis process and child processes.

redis-test:0>info CPU"# CPUused_cpu_sys:203.586050used_cpu_user:407.154103used_cpu_sys_children:0.000000used_cpu_user_children:0.000000"

Eight, info Commandstats

The statistical information of the info Commandstats module is Redis command statistics, including the command name, total number of times, total time, and average time of each command

redis-test:0>info Commandstats"# Commandstatscmdstat_client:calls=390,usec=11789,usec_per_call=30.23cmdstat_type:calls=78,usec=174,usec_per_call=2.23cmdstat_ttl:calls=75,usec=88,usec_per_call=1.17cmdstat_scan:calls=1261,usec=5642591,usec_per_call=4474.70cmdstat_slowlog:calls=17905,usec=116448,usec_per_call=6.50cmdstat_select:calls=232,usec=136,usec_per_call=0.59cmdstat_publish:calls=1511708,usec=4376704,usec_per_call=2.90cmdstat_exists:calls=599638,usec=455262,usec_per_call=0.76cmdstat_get:calls=4664,usec=10175,usec_per_call=2.18cmdstat_auth:calls=24512,usec=37469,usec_per_call=1.53cmdstat_keys:calls=1,usec=3939,usec_per_call=3939.00cmdstat_config:calls=1478,usec=70899,usec_per_call=47.97cmdstat_ping:calls=3091664,usec=1093731,usec_per_call=0.35cmdstat_replconf:calls=1025063,usec=598074,usec_per_call=0.58cmdstat_del:calls=620681,usec=560526,usec_per_call=0.90cmdstat_subscribe:calls=3,usec=8,usec_per_call=2.67cmdstat_memory:calls=24,usec=244,usec_per_call=10.17cmdstat_info:calls=352140,usec=16445560,usec_per_call=46.70cmdstat_psync:calls=1,usec=461,usec_per_call=461.00cmdstat_set:calls=713137,usec=1082454,usec_per_call=1.52"

Nine, info Cluster

The statistical information of the info Cluster module, currently there is only one statistical information, which identifies whether the current Redis is in Cluster mode.

redis-test:0>info cluster"# Clustercluster_enabled:0"

十、info Keyspace

The statistical information of the info Keyspace module contains the key-value statistical information of each database.

redis-test:0>info Keyspace"# Keyspacedb0:keys=147186,expires=0,avg_ttl=0"

1. Status monitoring of redis key space

1) Number of keys (keys): The number of keys contained in the redis instance. It is recommended to control it within 1kw; if the number of single-instance keys is too large, it may lead to untimely recovery of expired keys. Count the number of current node keys (how many cached data).

2) Set the number of keys with a lifetime: (keys_expires): It is a pure cache or a long business expiration, it is recommended to set TTL for the key; avoid the dead key problem of the business. (expires field)

3) Estimate the average lifetime of the key to set the survival time: (avg_ttl): redis will sample and estimate the average duration of the TTL key in the instance, in milliseconds. If there is no TTL key or in Slave, avg_ttl is always 0

2. Is the number of keys displayed by keyspace in info different from the number displayed by dbsize?

Because redis is a cluster, there are many nodes, keyspace displays the number of keys of a node, and dbsize displays the number of keys of all nodes. In the figure redis uses three nodes, and the dbsize is almost exactly three times the keyspace.

https://blog.csdn.net/pbymw8iwm/article/details/111714329