redis 5.0.4日志配置

2024-05-10 06:08
文章标签 配置 日志 redis 5.0

本文主要是介绍redis 5.0.4日志配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

    • 1. Redis配置文件中关于日志的内容
    • 2. Redis配置文件中关于慢查询日志

1. Redis配置文件中关于日志的内容

# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel notice
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile “”

  • 服务端日志级别:有4个,默认为notice。
    – debug:打印很多信息,适用于开发、测试;
    – verbose:许多有用的信息,但是没有debug级别信息多;
    – notice:适当的日志级别,适合生产模式;
    – warning:只有非常重要或者警告信息。
  • 日志的保存路径:默认为空字符串即为控制台输出日志,不生成日志文件,后台运行的Redis标准输出是/dev/null,如果需要输出到指定的文件中,修改logfile参数:logfile /var/log/redis_6379.log

2. Redis配置文件中关于慢查询日志

  慢查询日志存储于内存,读写速度快,对整体性能没什么影响。

################################## 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-log-slower-than:记录执行时间超过指定时长(microsecond, 1秒=10^6微秒) 的查询命令到慢日志文件中,生产环境可以设置为1000微秒,也就是1毫秒。
  • slowlog-max-len:指定服务器最多保存多少条慢日志,slowlog是FIFO队列,当队列大小超过设定值时,最旧的一条日志将被删除,生产环境可以设置为1000以上。

  可以通过修改配置文件或者直接在交互模式下,交互模式下使用CONFIG SET动态修改:

127.0.0.1:6379>CONFIG SET slowlog-log-slower-than 10000
127.0.0.1:6379>CONFIG SET slowlog-max-len 128

  查询慢查询日志:

--打印所有的慢查询日志
127.0.0.1:6379>  SLOWLOG GET1) 1) (integer) 19 --日志唯一标识符2) (integer) 1592818337  --命令执行的UNIX时间戳3) (integer) 12111  --命令执行时间(微秒)4) 1) "scan"  --执行的命令及参数2) "0"3) "MATCH"4) "*"5) "COUNT"6) "10000"--打印指定数量的慢查询条目
127.0.0.1:6379> SLOWLOG GET 21) 1) (integer) 192) (integer) 15928183373) (integer) 121114) 1) "scan"2) "0"3) "MATCH"4) "*"5) "COUNT"6) "10000"2) 1) (integer) 122) (integer) 15784681093) (integer) 280514) 1) "PFADD"2) "total_online_counter"3) "oLtGl5A3EQt5CWmbnf_s0BXoFG7g"

  清空慢查询日志(慢查询日志遵循先进先出缓存算法(FIFO)):

127.0.0.1:6379> slowlog len
(integer) 2
127.0.0.1:6379> slowlog reset
OK
127.0.0.1:6379> slowlog len
(integer) 0

这篇关于redis 5.0.4日志配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/975653

相关文章

Redis中Stream详解及应用小结

《Redis中Stream详解及应用小结》RedisStreams是Redis5.0引入的新功能,提供了一种类似于传统消息队列的机制,但具有更高的灵活性和可扩展性,本文给大家介绍Redis中Strea... 目录1. Redis Stream 概述2. Redis Stream 的基本操作2.1. XADD

nginx 负载均衡配置及如何解决重复登录问题

《nginx负载均衡配置及如何解决重复登录问题》文章详解Nginx源码安装与Docker部署,介绍四层/七层代理区别及负载均衡策略,通过ip_hash解决重复登录问题,对nginx负载均衡配置及如何... 目录一:源码安装:1.配置编译参数2.编译3.编译安装 二,四层代理和七层代理区别1.二者混合使用举例

Java JDK1.8 安装和环境配置教程详解

《JavaJDK1.8安装和环境配置教程详解》文章简要介绍了JDK1.8的安装流程,包括官网下载对应系统版本、安装时选择非系统盘路径、配置JAVA_HOME、CLASSPATH和Path环境变量,... 目录1.下载JDK2.安装JDK3.配置环境变量4.检验JDK官网下载地址:Java Downloads

Linux下进程的CPU配置与线程绑定过程

《Linux下进程的CPU配置与线程绑定过程》本文介绍Linux系统中基于进程和线程的CPU配置方法,通过taskset命令和pthread库调整亲和力,将进程/线程绑定到特定CPU核心以优化资源分配... 目录1 基于进程的CPU配置1.1 对CPU亲和力的配置1.2 绑定进程到指定CPU核上运行2 基于

Spring Boot spring-boot-maven-plugin 参数配置详解(最新推荐)

《SpringBootspring-boot-maven-plugin参数配置详解(最新推荐)》文章介绍了SpringBootMaven插件的5个核心目标(repackage、run、start... 目录一 spring-boot-maven-plugin 插件的5个Goals二 应用场景1 重新打包应用

Java中读取YAML文件配置信息常见问题及解决方法

《Java中读取YAML文件配置信息常见问题及解决方法》:本文主要介绍Java中读取YAML文件配置信息常见问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 目录1 使用Spring Boot的@ConfigurationProperties2. 使用@Valu

Jenkins分布式集群配置方式

《Jenkins分布式集群配置方式》:本文主要介绍Jenkins分布式集群配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装jenkins2.配置集群总结Jenkins是一个开源项目,它提供了一个容易使用的持续集成系统,并且提供了大量的plugin满

SpringBoot线程池配置使用示例详解

《SpringBoot线程池配置使用示例详解》SpringBoot集成@Async注解,支持线程池参数配置(核心数、队列容量、拒绝策略等)及生命周期管理,结合监控与任务装饰器,提升异步处理效率与系统... 目录一、核心特性二、添加依赖三、参数详解四、配置线程池五、应用实践代码说明拒绝策略(Rejected

C++ Log4cpp跨平台日志库的使用小结

《C++Log4cpp跨平台日志库的使用小结》Log4cpp是c++类库,本文详细介绍了C++日志库log4cpp的使用方法,及设置日志输出格式和优先级,具有一定的参考价值,感兴趣的可以了解一下... 目录一、介绍1. log4cpp的日志方式2.设置日志输出的格式3. 设置日志的输出优先级二、Window

Knife4j+Axios+Redis前后端分离架构下的 API 管理与会话方案(最新推荐)

《Knife4j+Axios+Redis前后端分离架构下的API管理与会话方案(最新推荐)》本文主要介绍了Swagger与Knife4j的配置要点、前后端对接方法以及分布式Session实现原理,... 目录一、Swagger 与 Knife4j 的深度理解及配置要点Knife4j 配置关键要点1.Spri