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

相关文章

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

hadoop开启回收站配置

开启回收站功能,可以将删除的文件在不超时的情况下,恢复原数据,起到防止误删除、备份等作用。 开启回收站功能参数说明 (1)默认值fs.trash.interval = 0,0表示禁用回收站;其他值表示设置文件的存活时间。 (2)默认值fs.trash.checkpoint.interval = 0,检查回收站的间隔时间。如果该值为0,则该值设置和fs.trash.interval的参数值相等。

NameNode内存生产配置

Hadoop2.x 系列,配置 NameNode 内存 NameNode 内存默认 2000m ,如果服务器内存 4G , NameNode 内存可以配置 3g 。在 hadoop-env.sh 文件中配置如下。 HADOOP_NAMENODE_OPTS=-Xmx3072m Hadoop3.x 系列,配置 Nam

wolfSSL参数设置或配置项解释

1. wolfCrypt Only 解释:wolfCrypt是一个开源的、轻量级的、可移植的加密库,支持多种加密算法和协议。选择“wolfCrypt Only”意味着系统或应用将仅使用wolfCrypt库进行加密操作,而不依赖其他加密库。 2. DTLS Support 解释:DTLS(Datagram Transport Layer Security)是一种基于UDP的安全协议,提供类似于

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal

零基础学习Redis(10) -- zset类型命令使用

zset是有序集合,内部除了存储元素外,还会存储一个score,存储在zset中的元素会按照score的大小升序排列,不同元素的score可以重复,score相同的元素会按照元素的字典序排列。 1. zset常用命令 1.1 zadd  zadd key [NX | XX] [GT | LT]   [CH] [INCR] score member [score member ...]

flume系列之:查看flume系统日志、查看统计flume日志类型、查看flume日志

遍历指定目录下多个文件查找指定内容 服务器系统日志会记录flume相关日志 cat /var/log/messages |grep -i oom 查找系统日志中关于flume的指定日志 import osdef search_string_in_files(directory, search_string):count = 0

我在移动打工的日志

客户:给我搞一下录音 我:不会。不在服务范围。 客户:是不想吧 我:笑嘻嘻(气笑) 客户:小姑娘明明会,却欺负老人 我:笑嘻嘻 客户:那我交话费 我:手机号 客户:给我搞录音 我:不会。不懂。没搞过。 客户:那我交话费 我:手机号。这是电信的啊!!我这是中国移动!! 客户:我不管,我要充话费,充话费是你们的 我:可是这是移动!!中国移动!! 客户:我这是手机号 我:那又如何,这是移动!你是电信!!

沁恒CH32在MounRiver Studio上环境配置以及使用详细教程

目录 1.  RISC-V简介 2.  CPU架构现状 3.  MounRiver Studio软件下载 4.  MounRiver Studio软件安装 5.  MounRiver Studio软件介绍 6.  创建工程 7.  编译代码 1.  RISC-V简介         RISC就是精简指令集计算机(Reduced Instruction SetCom