redis自带的那些工具

2019-10-21  本文已影响0人  攻城狮的翅膀

慢查询日志


1、设置慢查询配置

redis>config set slowlog-log-slower-than 0(单位微妙,默认为10000,10ms)

redis>config set slowlog-max-len 5


2、获取慢查询日志

redis>slowlog get

实例:

127.0.0.1:7001> config get slowlog-log-slower-than

1) "slowlog-log-slower-than"

2) "10000"

127.0.0.1:7001> CONFIG get slowlog-max-len

1) "slowlog-max-len"

2) "128"

127.0.0.1:7001> slowlog get

1) 1) (integer) 64

    2) (integer) 1571645922

    3) (integer) 735617

    4) 1) "info"

2) 1) (integer) 63

    2) (integer) 1571328003

    3) (integer) 12295

    4) 1) "CLUSTER"

      2) "SLOTS"

监视器


1、127.0.0.1:7001> monitor

OK

1571645940.484132 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645943.485235 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645946.485290 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645949.486071 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645952.486815 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645955.487559 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645956.224340 [0 127.0.0.1:47386] "PING"

1571645958.488116 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645961.489261 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645964.489657 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645967.490261 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645970.490993 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

1571645973.491732 [0 127.0.0.1:47386] "SMEMBERS" "30_MSG_GRP_All"

查看性能


1、 /usr/local/bin/redis-cli -p 6380 info commandstats

# Commandstats

cmdstat_set:calls=4350591,usec=29221503,usec_per_call=6.72

cmdstat_strlen:calls=2,usec=13,usec_per_call=6.50

cmdstat_lpush:calls=1131624,usec=15818423,usec_per_call=13.98

cmdstat_rpop:calls=566119935,usec=4582656127,usec_per_call=8.09

cmdstat_llen:calls=16,usec=149,usec_per_call=9.31

cmdstat_mset:calls=2549897,usec=417068867,usec_per_call=163.56

cmdstat_randomkey:calls=3,usec=12542,usec_per_call=4180.67

cmdstat_select:calls=268,usec=3141,usec_per_call=11.72

cmdstat_keys:calls=4,usec=3328004,usec_per_call=832001.00

cmdstat_scan:calls=4,usec=1163,usec_per_call=290.75

cmdstat_dbsize:calls=1,usec=10,usec_per_call=10.00

cmdstat_auth:calls=11,usec=131,usec_per_call=11.91

cmdstat_ping:calls=1171948,usec=9749676,usec_per_call=8.32

cmdstat_type:calls=5,usec=40,usec_per_call=8.00

cmdstat_flushdb:calls=20,usec=3971069,usec_per_call=198553.45

cmdstat_flushall:calls=1,usec=3862302,usec_per_call=3862302.00

cmdstat_info:calls=22,usec=466266,usec_per_call=21193.91

cmdstat_monitor:calls=11,usec=118,usec_per_call=10.73

cmdstat_subscribe:calls=1,usec=36,usec_per_call=36.00

cmdstat_publish:calls=2550509,usec=11056275,usec_per_call=4.33

cmdstat_client:calls=1,usec=147895,usec_per_call=147895.00

cmdstat_slowlog:calls=1,usec=10178,usec_per_call=10178.00

cmdstat_command:calls=1,usec=1795,usec_per_call=1795.00

2、/usr/local/bin/redis-cli -p 6380 -a 密码 --stat

------- data ------ --------------------- load -------------------- - child -

keys      mem      clients blocked requests            connections         

1558655    255.93M  31      0      577880181 (+0)      408019     

1558655    256.03M  31      0      577880317 (+136)    408027     

1558655    256.17M  31      0      577880448 (+131)    408034     

1558655    256.05M  31      0      577880576 (+128)    408039     

1558655    256.07M  31      0      577880705 (+129)    408045     

1558655    256.12M  31      0      577880831 (+126)    408048 

3、/usr/local/bin/redis-cli -p 6380 -a 密码 --bigkeys

# Scanning the entire keyspace to find biggest keys as well as

# average sizes per key type.  You can use -i 0.1 to sleep 0.1 sec

# per 100 SCAN commands (not usually needed).

[00.00%] Biggest string found so far 'Market_16' with 51881 bytes

[00.00%] Biggest list  found so far 'EXPIRED_MESSAGE_TOTALCLEAN' with 923 items

[00.00%] Biggest list  found so far 'PUSH_RAW_MSG_BUFFER_10' with 38833 items

-------- summary -------

Sampled 5 keys in the keyspace!

Total key length in bytes is 90 (avg len 18.00)

Biggest string found 'Market_16' has 51881 bytes

Biggest  list found 'PUSH_RAW_MSG_BUFFER_10' has 38833 items

2 strings with 73009 bytes (40.00% of keys, avg size 36504.50)

3 lists with 39758 items (60.00% of keys, avg size 13252.67)

0 sets with 0 members (00.00% of keys, avg size 0.00)

0 hashs with 0 fields (00.00% of keys, avg size 0.00)

0 zsets with 0 members (00.00% of keys, avg size 0.00)

参考资料

https://www.cnblogs.com/BigJunOba/p/9136099.html 一篇排查redis阻塞问题的思路

上一篇下一篇

猜你喜欢

热点阅读