濮阳杆衣贸易有限公司

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

Redis分析慢查詢操作的實(shí)例教程

熱門標(biāo)簽:廊坊外呼系統(tǒng)在哪買 一個(gè)地圖標(biāo)注多少錢 地圖標(biāo)注工廠入駐 臺(tái)灣電銷 高碑店市地圖標(biāo)注app 南京手機(jī)外呼系統(tǒng)廠家 400電話辦理的口碑 四川穩(wěn)定外呼系統(tǒng)軟件 b2b外呼系統(tǒng)

什么是慢查詢

慢查詢的作用:通過慢查詢分析,找到有問題的命令進(jìn)行優(yōu)化。

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

Redis slowlog是Redis用來記錄查詢執(zhí)行時(shí)間的日志系統(tǒng)。

查詢執(zhí)行時(shí)間指的是不包括像客戶端響應(yīng)(talking)、發(fā)送回復(fù)等IO操作,而單單是執(zhí)行一個(gè)查詢命令所耗費(fèi)的時(shí)間。

另外,slow log保存在內(nèi)存里面,讀寫速度非???,因此你可以放心地使用它,不必?fù)?dān)心因?yàn)殚_啟slow log而損害Redis的速度。

慢查詢?nèi)罩舅膫€(gè)屬性:

1、第一個(gè)字段是每個(gè)慢查詢唯一標(biāo)識(shí)。

2、處理完命令后的時(shí)間戳

3、執(zhí)行改名了所需要的時(shí)間,單位微妙

4、命令的參數(shù)列表,是個(gè)數(shù)組類型

每個(gè)慢查詢實(shí)體的ID都是唯一的,而且不會(huì)被重新設(shè)置,只會(huì)在redis重啟后才會(huì)重置它.

慢查詢參數(shù)

首先來關(guān)注下慢日志分析對(duì)應(yīng)的兩個(gè)參數(shù):

1、slowlog-log-slower-than:預(yù)設(shè)閥值,即記錄超過多少時(shí)間的記錄,默認(rèn)為10000微秒,即10毫秒。

2、slowlog-max-len:記錄慢查詢的條數(shù),默認(rèn)為128條,當(dāng)超過設(shè)置的條數(shù)時(shí)最早進(jìn)入隊(duì)列的將被移除。線上建議增大數(shù)值,如:1000,這樣可減少隊(duì)列移除的頻率。

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對(duì)這兩個(gè)參數(shù)進(jìn)行調(diào)整,或者在配置文件中設(shè)置。

################################## 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]

如,進(jìn)行查詢慢查詢、獲取慢查詢記錄的數(shù)量、重置慢查詢?nèi)罩镜炔僮鳎?/p>

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

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問大家可以留言交流,謝謝大家對(duì)腳本之家的支持。

您可能感興趣的文章:
  • 淺析JavaWeb項(xiàng)目架構(gòu)之Redis分布式日志隊(duì)列
  • java獲取redis日志信息與動(dòng)態(tài)監(jiān)控信息的方法
  • 如何高效使用Redis作為L(zhǎng)RU緩存
  • Linux安裝Redis實(shí)現(xiàn)過程及報(bào)錯(cuò)解決方案
  • spring boot+redis 監(jiān)聽過期Key的操作方法
  • Redis面試必會(huì)的題目
  • 在Docker中使用Redis的步驟詳解
  • SpringBoot2.3整合redis緩存自定義序列化的實(shí)現(xiàn)
  • Redis 執(zhí)行性能測(cè)試
  • Redis緩存常用4種策略原理詳解
  • Redis緩存穿透出現(xiàn)原因及解決方案
  • 詳解Redis的慢查詢?nèi)罩?/li>

標(biāo)簽:拉薩 泰州 南寧 定州 甘南 畢節(jié) 伊春 河源

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Redis分析慢查詢操作的實(shí)例教程》,本文關(guān)鍵詞  Redis,分析,慢,查詢,操作,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Redis分析慢查詢操作的實(shí)例教程》相關(guān)的同類信息!
  • 本頁收集關(guān)于Redis分析慢查詢操作的實(shí)例教程的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    和静县| 瑞金市| 西丰县| 潢川县| 新田县| 丹江口市| 丹寨县| 桐庐县| 伽师县| 廉江市| 宁河县| 淅川县| 张北县| 定安县| 靖江市| 新化县| 海伦市| 共和县| 商南县| 横峰县| 竹山县| 江城| 洱源县| 定日县| 勐海县| 白银市| 康定县| 内乡县| 阳信县| 金门县| 稷山县| 乐至县| 依兰县| 台安县| 儋州市| 乌拉特前旗| 黄大仙区| 汕尾市| 临夏县| 三明市| 黔西县|