redis.conf 慢日志配置
################################## 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
常用指令:
1、设置slowlog的执行耗时阈值
127.0.0.1:6379> config set slowlog-log-slower-than 1000
OK
2、查看slowlog执行耗时的阈值
127.0.0.1:6379> config get slowlog-log-slower-than
1) "slowlog-log-slower-than"
2) "10000"
3、设置slowlog保存数量的阈值
127.0.0.1:6379> config set slowlog-max-len 1024
OK
4、查看slowlog保存数量的阈值
127.0.0.1:6379> config get slowlog-max-len
1) "slowlog-max-len"
2) "1024"
5、查看slowlog的数量
127.0.0.1:6379> slowlog len
(integer) 1024
6、查询slowlog

7、清除slowlog记录
127.0.0.1:6379> slowlog reset
OK
本文介绍了Redis慢查询日志的配置方法,包括如何设置慢日志的执行耗时阈值及保存数量阈值,并提供了相关操作命令示例。
90

被折叠的 条评论
为什么被折叠?



