十年網站開發(fā)經驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網站問題一站解決
1.什么是slowlog
成都創(chuàng)新互聯公司專注于運城網站建設服務及定制,我們擁有豐富的企業(yè)做網站經驗。 熱誠為您提供運城營銷型網站建設,運城網站制作、運城網頁設計、運城網站官網定制、成都微信小程序服務,打造運城網絡公司原創(chuàng)品牌,更為您提供運城網站排名全網營銷落地服務。
Slow log 是 redis 用來記錄查詢執(zhí)行時間的日志系統(tǒng)。
查詢執(zhí)行時間指的是不包括像客戶端響應(talking)、發(fā)送回復等 IO 操作,而單單是執(zhí)行一個查詢命令所耗費的時間。
另外,slow log 保存在內存里面,讀寫速度非???,因此你可以放心地使用它,不必擔心因為開啟 slow log 而損害 Redis 的速度。
2.查看慢查詢日志參數
127.0.0.1:6379> config get slowlog*
1) "slowlog-log-slower-than"
2) "10000" --單位微妙
3) "slowlog-max-len" --最多保存慢查詢日志數量
4) "128"
3.可動態(tài)修改,動態(tài)參數
127.0.0.1:6379> config set slowlog-log-slower-than 100000
OK
127.0.0.1:6379> config set slowlog-max-len 256
OK
127.0.0.1:6379> config get slowlog*
1) "slowlog-log-slower-than"
2) "100000"
3) "slowlog-max-len"
4) "256"
4.查看命令
127.0.0.1:6379> slowlog get 2
1) 1) (integer) 1 # 唯一性(unique)的日志標識符
2) (integer) 1480331288 # 被記錄命令的執(zhí)行時間點,以 UNIX 時間戳格式表示
3) (integer) 43136 # 查詢執(zhí)行時間,以微秒為單位
4) 1) "config" # 執(zhí)行的命令,以數組的形式排列,完整命令 config get slowlog*
2) "get"
3) "slowlog*"
2) 1) (integer) 0
2) (integer) 1480331280
3) (integer) 54158
4) 1) "info"
127.0.0.1:6379>
127.0.0.1:6379> slowlog len
(integer) 2
5.清除命令
127.0.0.1:6379> slowlog reset
OK
127.0.0.1:6379> slowlog get 2
(empty list or set)
127.0.0.1:6379>
6.幫助
127.0.0.1:6379> help slowlog
SLOWLOG subcommand [argument]
summary: Manages the Redis slow queries log
since: 2.2.12
group: server