redis监控
redis提供了INFO这个命令,能够随时监控服务器的状态,只用telnet到对应服务器的端口,执行命令即可:
[root@cache01 ~]# telnet localhost 6379 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. info $2290 # Server redis_version:3.2.1 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:c315aa1c1a3951d6 redis_mode:standalone os:Linux 2.6.32-573.el6.x86_64 x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.7 process_id:8936 run_id:49642c08e9bd20589b4650dbb7d1c73873845964 tcp_port:6379 uptime_in_seconds:12687 uptime_in_days:0 hz:10 lru_clock:8237610 executable:/app/server/redis/bin/redis-server config_file:/app/server/redis/conf/6379.conf # Clients connected_clients:3 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Memory used_memory:1933624 used_memory_human:1.84M used_memory_rss:3981312 used_memory_rss_human:3.80M used_memory_peak:1973552 used_memory_peak_human:1.88M total_system_memory:513724416 total_system_memory_human:489.93M used_memory_lua:37888 used_memory_lua_human:37.00K maxmemory:0 maxmemory_human:0B maxmemory_policy:volatile-lru mem_fragmentation_ratio:2.06 mem_allocator:jemalloc-4.0.3 # Persistence loading:0 rdb_changes_since_last_save:0 rdb_bgsave_in_progress:0 rdb_last_save_time:1467851744 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:0 rdb_current_bgsave_time_sec:-1 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 # Stats total_connections_received:2191 total_commands_processed:32551 instantaneous_ops_per_sec:3 total_net_input_bytes:1559080 total_net_output_bytes:49567278 instantaneous_input_kbps:0.15 instantaneous_output_kbps:1.59 rejected_connections:0 sync_full:2 sync_partial_ok:0 sync_partial_err:0 expired_keys:0 evicted_keys:0 keyspace_hits:164 keyspace_misses:3 pubsub_channels:1 pubsub_patterns:0 latest_fork_usec:246 migrate_cached_sockets:0 # Replication role:master connected_slaves:1 slave0:ip=192.168.1.68,port=6379,state=online,offset=885306,lag=1 master_repl_offset:885320 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:5778 repl_backlog_histlen:879543 # CPU used_cpu_sys:28.18 used_cpu_user:12.10 used_cpu_sys_children:0.02 used_cpu_user_children:0.00 # Cluster cluster_enabled:0 # Keyspace db0:keys=8,expires=0,avg_ttl=0 quit +OK ============================================== keyspace_hits:164 keyspace_misses:3 used_memory:1933624 expired_keys:0 evicted_keys:0 上面这几项与缓存的状态有关系; 通过计算hits和miss,我们可以得到缓存的命中率:14414110 / (14414110 + 3228654) = 81% ,一个缓存失效机制,和过期时间设计良好的系统,命中率可以做到95%以上,对于整体性能提升是很大的。 used_memory,expired_keys,evicted_keys这3个信息的具体含义,redis的官方也有一篇很详细的说明: http://redis.io/commands/info
联系方式QQ:326528263 EMAIL:clnking@163.com 网名:bass 分享技术 突破难点 创新思维