日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Redis 如何分析慢查询操作

發布時間:2023/12/3 数据库 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Redis 如何分析慢查询操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉載自??Redis 如何分析慢查詢操作

什么是慢查詢

和mysql的慢SQL日志分析一樣,redis也有類似的功能,來幫助定位一些慢查詢操作。

Redis?slowlog是Redis用來記錄查詢執行時間的日志系統。

查詢執行時間指的是不包括像客戶端響應(talking)、發送回復等IO操作,而單單是執行一個查詢命令所耗費的時間。

另外,slow log保存在內存里面,讀寫速度非常快,因此你可以放心地使用它,不必擔心因為開啟slow log而損害Redis的速度。

慢查詢參數

首先來關注下慢日志分析對應的兩個參數:

1、slowlog-log-slower-than:預設閥值,即記錄超過多少時間的記錄,默認為10000微秒,即10毫秒。

2、slowlog-max-len:記錄慢查詢的條數,默認為128條,當超過設置的條數時最早進入隊列的將被移除。線上建議增大數值,如:1000,這樣可減少隊列移除的頻率。

127.0.0.1:6379>?config?get?slowlog-log-slower-than 1)?"slowlog-log-slower-than" 2)?"10000" 127.0.0.1:6379>?config?get?slowlog-max-len 1)?"slowlog-max-len" 2)?"128"

可以用config set對這兩個參數進行調整,或者在配置文件中設置。

##################################?SLOW?LOG?####################################?The?Redis?Slow?Log?is?a?system?to?log?queries?that?exceeded?a?specified #?execution?time.?The?execution?time?does?not?include?the?I/O?operations #?like?talking?with?the?client,?sending?the?reply?and?so?forth, #?but?just?the?time?needed?to?actually?execute?the?command?(this?is?the?only #?stage?of?command?execution?where?the?thread?is?blocked?and?can?not?serve #?other?requests?in?the?meantime). # #?You?can?configure?the?slow?log?with?two?parameters:?one?tells?Redis #?what?is?the?execution?time,?in?microseconds,?to?exceed?in?order?for?the #?command?to?get?logged,?and?the?other?parameter?is?the?length?of?the #?slow?log.?When?a?new?command?is?logged?the?oldest?one?is?removed?from?the #?queue?of?logged?commands.#?The?following?time?is?expressed?in?microseconds,?so?1000000?is?equivalent #?to?one?second.?Note?that?a?negative?number?disables?the?slow?log,?while #?a?value?of?zero?forces?the?logging?of?every?command. slowlog-log-slower-than?10000#?There?is?no?limit?to?this?length.?Just?be?aware?that?it?will?consume?memory. #?You?can?reclaim?memory?used?by?the?slow?log?with?SLOWLOG?RESET. slowlog-max-len?128

慢查詢命令

語法:slowlog subcommand [argument]

如,進行查詢慢查詢、獲取慢查詢記錄的數量、重置慢查詢日志等操作:

192.168.10.38:9001>?slowlog?get (empty?list?or?set) 192.168.10.38:9001>?slowlog?get?10 (empty?list?or?set) 192.168.10.38:9001>?slowlog?len? (integer)?0 192.168.10.38:9001>?slowlog?reset OK

總結

以上是生活随笔為你收集整理的Redis 如何分析慢查询操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。