Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the INFO command in Redis

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use the INFO command in Redis. It is very detailed and has a certain reference value. Friends who are interested must finish it!

INFO [section]

Returns various information and statistics about the Redis server in a format that is easy to interpret (parse) and easy to read.

Given the optional parameter section, you can have the command return only a portion of the information:

The server section records the information about the Redis server, which contains the following domains:

Redis_version: Redis server version

Redis_git_sha1: Git SHA1

Redis_git_dirty: Git dirty flag

Os: host operating system of the Redis server

Arch_bits: architecture (32 or 64 bit)

Multiplexing_api: event handling mechanism used by Redis

Gcc_version: the version of GCC used when compiling Redis

Process_id: PID of the server process

Run_id: random identifier of the Redis server (for Sentinel and clustering)

Tcp_port: TCP/IP listening port

Uptime_in_seconds: the number of seconds that have passed since the Redis server was started

Uptime_in_days: the number of days that have passed since the Redis server was started

Lru_clock: a clock that increments itself in minutes for LRU management

The clients section records the information of the connected client, which contains the following domains:

Connected_clients: number of connected clients (excluding clients connected through secondary servers)

Client_longest_output_list: the longest output list among currently connected clients

Client_longest_input_buf: the maximum input cache among the currently connected clients

Blocked_clients: the number of clients waiting for blocking commands (BLPOP, BRPOP, BRPOPLPUSH)

The memory section records the memory information of the server, which contains the following fields:

Used_memory: the total amount of memory allocated by the Redis allocator in byte

Used_memory_human: returns the total amount of memory allocated by Redis in a human readable format

Used_memory_rss: returns the total amount of memory allocated by Redis (commonly known as resident set size) from an operating system perspective. This value is consistent with the output of top, ps, and so on.

Used_memory_peak: peak memory consumption of Redis (in bytes)

Used_memory_peak_human: returns the peak memory consumption of Redis in a human-readable format

Used_memory_lua: the amount of memory used by the Lua engine in bytes

Mem_fragmentation_ratio: the ratio between used_memory_rss and used_memory

Mem_allocator: the memory allocator used by Redis specified at compile time. It can be libc, jemalloc, or tcmalloc.

Ideally, the value of used_memory_rss should be only slightly higher than that of used_memory.

When rss > used, and the difference between the two values is large, it indicates that there is memory fragmentation (internal or external).

The ratio of memory fragmentation can be seen by the value of mem_fragmentation_ratio.

When used > rss, part of the memory of the Redis is swapped out to swap space by the operating system, in which case the operation may cause significant latency.

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 memory to the operating system.

If Redis frees memory but does not return it to the operating system, the value of used_memory may not match the Redis footprint displayed by the operating system.

Check the value of used_memory_peak to verify that this is happening.

The persistence section records information about RDB persistence and AOF persistence, which contains the following fields:

Loading: a flag value that records whether the server is loading a persistence file.

Rdb_changes_since_last_save: how many seconds have elapsed since the last successful creation of a persistent file.

Rdb_bgsave_in_progress: a flag value that records whether the server is creating a RDB file.

Rdb_last_save_time: the UNIX timestamp of the last successful creation of the RDB file.

Rdb_last_bgsave_status: a flag value that records whether the result of the most recent creation of a RDB file was a success or failure.

Rdb_last_bgsave_time_sec: records the number of seconds it took to create the most recent RDB file.

Rdb_current_bgsave_time_sec: if the server is creating a RDB file, this domain records the number of seconds that the current creation operation has taken.

Aof_enabled: a flag value that records whether AOF is open or not.

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 an scheduled AOF rewrite is required after the RDB file is created.

Aof_last_rewrite_time_sec: how long it took to create the last AOF file.

Aof_current_rewrite_time_sec: if the server is creating an AOF file, this domain records the number of seconds that the current creation operation has taken.

Aof_last_bgrewrite_status: a flag value that records whether the result of the most recent creation of an AOF file was a success or failure.

If AOF persistence is enabled, the following fields will be added to this section:

Aof_current_size: current size of the AOF file.

Aof_base_size: the size of the AOF file when the server starts or after AOF rewrites the last execution.

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: the size of the AOF rewrite buffer.

Aof_pending_bio_fsync: the number of fsync calls waiting to be executed in the background iCandle O queue.

Aof_delayed_fsync: the number of fsync calls delayed.

The stats section records general statistics, which contains the following fields:

Total_connections_received: the number of connection requests accepted by the server.

Total_commands_processed: the number of commands executed by the server.

Instantaneous_ops_per_sec: the number of commands executed by the server per second.

Rejected_connections: the number of connection requests rejected because of the maximum number of clients.

Expired_keys: the number of database keys that are automatically deleted because of expiration.

Evicted_keys: the number of keys that are expelled (evict) because of the maximum memory capacity limit.

Keyspace_hits: the number of times the database key was found successfully.

Keyspace_misses: the number of times it failed to find the database key.

Pubsub_channels: the number of channels currently subscribed.

Pubsub_patterns: the number of patterns currently subscribed.

Latest_fork_usec: the number of milliseconds spent on the last fork () operation.

Replication: master / slave replication information

Role: if the current server is not replicating any other server, the value of this field is master; otherwise, the value of this field is slave. Note that when creating a replication chain, one slave server may also be the master server of another server.

If the current server is a slave server, the following domains will be added to this section:

Master_host: the IP address of the primary server.

Master_port: the TCP listener port number of the primary server.

Master_link_status: copy the current status of the connection. Up means the connection is normal, and down means the connection is broken.

Master_last_io_seconds_ago: how many seconds have passed since the last time I communicated with the primary server.

Master_sync_in_progress: a flag value that records whether the master server is synchronizing with the slave server.

If a synchronization operation is in progress, the following fields will be added to this section:

Master_sync_left_bytes: how many bytes of data are missing before the synchronization is complete.

Master_sync_last_io_seconds_ago: how many seconds have elapsed since the last time I racked O because of a SYNC operation.

If the connection between the master and slave servers is disconnected, the following domains will be added to this section:

Master_link_down_since_seconds: how many seconds has the master / slave server been disconnected?

Here are some of the domains that always appear:

Connected_slaves: the number of slave servers connected.

For each slave server, the following line of information is added:

SlaveXXX: ID, IP address, port number, connection status

The cpu section records the computation statistics of CPU, which contains the following fields:

Used_cpu_sys: the system CPU consumed by the Redis server.

Used_cpu_user: the user CPU consumed by the Redis server.

Used_cpu_sys_children: the system CPU consumed by the background process.

Used_cpu_user_children: the user CPU consumed by the background process.

The commandstats section records execution statistics for different 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 so on. For each type of command, this section adds a line of information in the following format:

Cmdstat_XXX:calls=XXX,usec=XXX,usecpercall=XXX

The cluster section records the information related to the cluster, which contains the following domains:

Cluster_enabled: a flag value that records whether the cluster function has been enabled.

The keyspace section records the statistics related to the database, such as the number of keys in the database, the number of expired keys that the database has been deleted, and so on. For each database, this section adds a line of information in the following format:

DbXXX:keys=XXX,expires=XXX

In addition to the values given above, the values of the section parameter can be the following two:

All: returns all information

Default: returns information about the default selection

When the INFO command is called directly without arguments, default is used as the default parameter.

Different versions of Redis may have added or deleted some of the returned fields.

Therefore, a robust client program should be able to skip unrecognized domains and properly handle missing ones when analyzing the output of INFO commands.

The above is all the contents of the article "how to use INFO commands in Redis". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report