一、连接
src/redis-cli -h 10.20.137.141 -p 6379
>auth 123456789 src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789
src/redis-cli -h {ip} -p {port} -a {password} monitor
二、常用性能分析命令
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 monitor
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info clients|grep connected_clients 查看客户端已连接个数
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info memory|egrep '(used_memory_human|used_memory_peak_human)'
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info memory|grep -e "used_memory_human" -e "used_memory_peak_human" 查看当前使用内存量和历史最高峰值
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info stats | grep total_commands 查看启动到当前处理命令总数
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info stats | grep instantaneous_ops_per_sec 每秒操作数
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info stats | grep expired_keys 已过期的key数量
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info stats | grep instantaneous_input_kbps 每秒进出流量(70444byte)0.07M
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info stats | grep rejected_connections拒绝的连接请求量
src/redis-cli -h 10.20.137.141 -p 6379 -a 123456789 info memory|grep mem_fragmentation_ratio
内存碎片比例(如果超过1,表示存在内存碎片;如果小于1,说明内存被交换到swap里面去了。计算公式为:used_memory_rss/used_memory)
src/redis-cli -h IP -p 26379 -a 123456 info|grep process_id
src/redis-cli info clients|grep connected_clients 查看客户端已连接个数
三、动态修改保存方式
config set save "" 不持久化
config rewrite
config get save
四、latency命令报告
latency latest记录最后的延迟事件记录,每个事件包含以下几个变量(事件名、事件延迟状态时间戳、延迟时间ms、此时间最大延迟)
注意:Unix时间戳转换方式为:
date -d@'1466059344' "+ %Y-%m-%d %H:%M:%S"
date -d"2016-06-16 16:50:50" '+%s'
127.0.0.1:6379>latency latest
1)"command" 事件类型
2)(integer) 1466059344 发生时间
3)(integer) 250 延迟时间0.25ms
4)(integer)1000 事件延迟最大时间为1s 127.0.0.1:6379>history events 此命令可以打印相应延迟事件相关的时间和耗时
127.0.0.1:6379>latency reset command重置事件的相关延迟操作,清空记录
127.0.0.1:6379>latency graph command
127.0.0.1:6379>slowlog get 获取慢查询日志
127.0.0.1:6379>slowlog len 获取慢查询日志条数
127.0.0.1:6379>slowlog reset 清空慢查询
127.0.0.1:6379>config get maxclients查看最大连接数配置