Redis Introduction
Redis is an advanced key-value database. It is similar to memcached, but data can be persistent and supports a wide range of data types. There are five types: String, linked list, hash, set, and ordered set. Allows you to compute, merge, and merge sets (difference) on the server side. Multiple sorting functions are also supported. So redis can also be seen as a data structure server. All redis data is stored in the memory and then asynchronously stored to the disk (this is called the "semi-persistent mode "); you can also write every data change to an append only file (AOF) (this is called "Full persistence mode ").
Redis monitoring
First, judge the client and serverIs the connection normal?
# If the connection between the client and the server is normal, return pongredis> pingpong # the connection between the client and the server is abnormal (the network is abnormal or the server is not running properly), and return the connection exception redis 127.0.0.1: 6379> pingcocould not connect to redis at 127.0.0.1: 6379: Connection refused
The most direct method for redis monitoring is to use the info Command provided by the system. You only need to execute the following command to obtain the status report of the redis system.
redis-cli info
The system returns eight parts, namely server, clients, memory, persistence, stats, replication, CPU, and keyspace. Extract relevant information from the returned results of info to achieve effective monitoring.
First explain the meaning of each parameter
# Serverredis_version: 2.8.8 # redis version release: Release: 0redis_build_id: Release: standaloneos: Linux 2.6.32-release _ 64 release: 64multiplexing_api: epollgcc_version: 4.4.7 # GCC version process_id: 49324 # current redis server process idrun_id: running: 6379uptime_in_seconds: 1739082 # Run Time (seconds) uptime_in_days: 20 # Run Time (days) Hz: 10lru_clock: 1734729config_file: /home/S/apps/redismulti_video_so/CONF/zzz. conf # clientsconnected_clients: 1 # number of connected clients principal: 0blocked_clients: 0 # memoryused_memory: 821848 # total memory allocated by redis used_memory_human: 802.59kused _ memory_rss: 85532672 # total memory allocated by redis (including memory fragments) used_memory_peak: Memory: 170.70 M # peak memory used by redis used_memory_lua: Memory: 104.07 # Memory Fragment ratio mem_allocator: tcmalloc-2.0 # persistenceloading: 0rdb_changes_since_last_save, in UNIX timestamp format: enabled:-1aof_enabled: 0 # Whether redis has enabled disabled: 0aof_rewrite_scheduled: enabled:-enabled: okaof_last_write_status: OK # statstotal_connections_received: 5705 # Total number of clients connected since running total_commands_processed: 204013 # Total number of commands executed since running: 0rejected_connections: 0sync_full: 0sync_partial_ OK: 0expired_keys: 34401 # Number of expired keys since running evicted_keys: 0 # number of keys deleted since running keyspace_hits: 2129 # Number of key hits keyspace_misses: 3148 # number of keys not hit pubsub_channels: 0 # number of channels currently in use pubsub_patterns: 0 # number of currently in use modes: 4391 # replicationrole: master # Master or slave: 0master_repl_offset: 0repl_backlog_active: 0repl_backlog_size: Primary: 0repl_backlog_histlen: 0 # cpuused_cpu_sys: 1551.61used _ cpu_user: ipv3.37used _ cpu_sys_children: 2.52used _ cpu_user_children: 16.79 # keyspacedb0: Keys = 3, expires = 0, avg_ttl = 0 # number of keys for each database and number of keys with a lifetime
Memory usage
If the memory used by redis exceeds the available physical memory size, the redis system may be killed. To solve this problem, you can use the info command to monitor used_memory and used_memory_peak, set the threshold for memory usage, and set the corresponding alarm mechanism. Of course, alarm is only a means. What is important is that you have to plan in advance. When the memory usage is too large, what should you do to clear useless cold data, or migrate redis to a more powerful machine.
Persistence
If your machine or redis itself causes redis to crash, your only life-saving straw may be the RDB file dumped by dump. Therefore, it is also important to monitor redis dump files. You can monitor rdb_last_save_time to learn about the time of the last dump data operation. You can also monitor rdb_changes_since_last_save to find out how much data will be lost (changed) If a fault occurs at this time.
Keys
Obtain the number of keys in each database by obtaining the results in keyspace.
QPS
That is, the number of commands executed per minute, that is: (total_commands_processed2-total_commands_processed1)/span, in order to get QPS in real time, you can set the script to run in the background, record the total_commands_processed in the past few minutes. When calculating QPS, the estimated QPS value is obtained using the past information and the current information.
Reference
Description of parameters in the redis info command
Ping
Redis monitoring Solution