Redis Monitoring Solutions

Source: Internet
Author: User

About Redis

Redis is an advanced Key-value database. It is similar to memcached, but the data can be persisted and the supported data types are rich. There are 5 types of strings, linked lists, hashes, collections, and ordered collections. Support for compute and intersection and complement sets (difference) on the server side, as well as a variety of sorting functions. So Redis can also be viewed as a data structure server. All redis data is stored in memory and then periodically asynchronously saved to disk (this is called "semi-persistent mode"), and each data change can be written to a append only file (AOF) (this is called "Full persistence mode").

Redis Monitoring

First determine if the client and server connections are normal

?
1234567 # 客户端和服务器连接正常,返回PONGredis> PINGPONG# 客户端和服务器连接不正常(网络不正常或服务器未能正常运行),返回连接异常redis 127.0.0.1:6379> PINGCould not connect to Redis at 127.0.0.1:6379:Connection refused

The most straightforward approach to redis monitoring is to use the Info command provided by the system to obtain status reports for the Redis system by executing one of the following commands.

?
1 redis-cli info

The results are returned to Server, clients, Memory, persistence, Stats, Replication, CPU, keyspace 8 parts. The purpose of effective monitoring can be achieved by extracting relevant information from the large return results of info.

Explain the meaning of each parameter first

?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 66676869707172737475767778798081828384 # Serverredis_version:2.8.8 # Redis 的版本redis_git_sha1:00000000redis_git_dirty:0redis_build_id:bf5d1747be5380fredis_mode:standaloneos:Linux 2.6.32-220.7.1.el6.x86_64 x86_64arch_bits:64multiplexing_api:epollgcc_version:4.4.7 #gcc版本process_id:49324# 当前 Redis 服务器进程idrun_id:bbd7b17efcf108fdde285d8987e50392f6a38f48tcp_port:6379uptime_in_seconds:1739082# 运行时间(秒)uptime_in_days:20 # 运行时间(天)hz:10lru_clock:1734729config_file:/home/s/apps/RedisMulti_video_so/conf/zzz.conf# Clientsconnected_clients:1#连接的客户端数量client_longest_output_list:0client_biggest_input_buf:0blocked_clients:0# Memoryused_memory:821848#Redis分配的内存总量              used_memory_human:802.59Kused_memory_rss:85532672 #Redis分配的内存总量(包括内存碎片) used_memory_peak:178987632used_memory_peak_human:170.70M           #Redis所用内存的高峰值used_memory_lua:33792mem_fragmentation_ratio:104.07#内存碎片比率mem_allocator:tcmalloc-2.0# Persistenceloading:0rdb_changes_since_last_save:0#上次保存数据库之后,执行命令的次数rdb_bgsave_in_progress:0#后台进行中的 save 操作的数量rdb_last_save_time:1410848505#最后一次成功保存的时间点,以 UNIX 时间戳格式显示rdb_last_bgsave_status:okrdb_last_bgsave_time_sec:0rdb_current_bgsave_time_sec:-1aof_enabled:0#redis是否开启了aofaof_rewrite_in_progress:0aof_rewrite_scheduled:0aof_last_rewrite_time_sec:-1aof_current_rewrite_time_sec:-1aof_last_bgrewrite_status:okaof_last_write_status:ok# Statstotal_connections_received:5705#运行以来连接过的客户端的总数量total_commands_processed:204013# 运行以来执行过的命令的总数量instantaneous_ops_per_sec:0rejected_connections:0sync_full:0sync_partial_ok:0sync_partial_err:0expired_keys:34401#运行以来过期的 key 的数量evicted_keys:0#运行以来删除过的key的数量keyspace_hits:2129#命中key 的次数keyspace_misses:3148#没命中key 的次数pubsub_channels:0#当前使用中的频道数量pubsub_patterns:0#当前使用中的模式数量latest_fork_usec:4391# Replicationrole:master                              #当前实例的角色master还是slaveconnected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0# CPUused_cpu_sys:1551.61used_cpu_user:1083.37used_cpu_sys_children:2.52used_cpu_user_children:16.79# Keyspacedb0:keys=3,expires=0,avg_ttl=0#各个数据库的 key 的数量,以及带有生存期的 key 的数量

Memory usage

If the memory used by Redis exceeds the available physical memory size, Redis is likely to be killed. For this, you can use the info command to monitor used_memory and Used_memory_peak, set thresholds for the amount of memory used, and set the appropriate alarm mechanism. Of course, the alarm is only a means, the important thing is that you have to plan ahead, when the memory usage is too large, you should do something to clean up some useless cold data, or to move Redis to a more powerful machine.

Persistence of

If Redis crashes because of problems with your machine or redis itself, your only lifeline might be the Rdb file that you dump, so it's important to monitor the Redis dump file. The rdb_last_save_time can be monitored to understand the time of the most recent dump data operation, and the rdb_changes_since_last_save can be monitored to get how much data is lost (that is, changed) if a failure occurs.

Keys

Get the number of keys in each database by getting the results in Keyspace

QPS

That is, the number of commands executed per minute, namely: (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, recording the last few minutes of Total_ Commands_processed. When calculating a QPS, use past information and current information to derive a QPS estimate.

Reference

What each parameter means in the Redis info command

Redis Monitoring Solutions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.