好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Redis分析慢查詢操作的實例教程

Redis分析慢查詢操作的實例教程

熱門標簽:廊坊外呼系統在哪買 一個地圖標注多少錢 地圖標注工廠入駐 臺灣電銷 高碑店市地圖標注app 南京手機外呼系統廠家 400電話辦理的口碑 四川穩定外呼系統軟件 b2b外呼系統

什么是慢查詢

慢查詢的作用:通過慢查詢分析,找到有問題的命令進行優化。

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

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

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

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

慢查詢日志四個屬性:

1、第一個字段是每個慢查詢唯一標識。

2、處理完命令后的時間戳

3、執行改名了所需要的時間,單位微妙

4、命令的參數列表,是個數組類型

每個慢查詢實體的ID都是唯一的,而且不會被重新設置,只會在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

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

您可能感興趣的文章:
  • 淺析JavaWeb項目架構之Redis分布式日志隊列
  • java獲取redis日志信息與動態監控信息的方法
  • 如何高效使用Redis作為LRU緩存
  • Linux安裝Redis實現過程及報錯解決方案
  • spring boot+redis 監聽過期Key的操作方法
  • Redis面試必會的題目
  • 在Docker中使用Redis的步驟詳解
  • SpringBoot2.3整合redis緩存自定義序列化的實現
  • Redis 執行性能測試
  • Redis緩存常用4種策略原理詳解
  • Redis緩存穿透出現原因及解決方案
  • 詳解Redis的慢查詢日志

標簽:拉薩 泰州 南寧 定州 甘南 畢節 伊春 河源

巨人網絡通訊聲明:本文標題《Redis分析慢查詢操作的實例教程》,本文關鍵詞  Redis,分析,慢,查詢,操作,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Redis分析慢查詢操作的實例教程》相關的同類信息!
  • 本頁收集關于Redis分析慢查詢操作的實例教程的相關信息資訊供網民參考!
  • 推薦文章