Redis 如何分析慢查询操作
转载自 Redis 如何分析慢查询操作
什么是慢查询
和mysql的慢SQL日志分析一样,redis也有类似的功能,来帮助定位一些慢查询操作。
Redis slowlog是Redis用来记录查询执行时间的日志系统。
查询执行时间指的是不包括像客户端响应(talking)、发送回复等IO操作,而单单是执行一个查询命令所耗费的时间。
另外,slow log保存在内存里面,读写速度非常快,因此你可以放心地使用它,不必担心因为开启slow log而损害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
Redis 如何分析慢查询操作相关推荐
- python查询oracle数据库_python针对Oracle常见查询操作实例分析
本文实例讲述了python针对Oracle常见查询操作.分享给大家供大家参考,具体如下: 1.子查询(难): 当进行查询的时候,发现需要的数据信息不明确,需要先通过另一个查询得到, 此查询称为子查询: ...
- python如何实时查询oracle_python针对Oracle常见查询操作实例分析
本文实例讲述了python针对Oracle常见查询操作.分享给大家供大家参考,具体如下: 1.子查询(难): 当进行查询的时候,发现需要的数据信息不明确,需要先通过另一个查询得到, 此查询称为子查询: ...
- 【Redis】Redis 哈希 Hash 键值对集合操作 ( 哈希 Hash 键值对集合简介 | 查询操作 | 增加操作 | 修改操作 )
文章目录 一.哈希 Hash 键值对集合 二.查询操作 1.Redis 中查询 Hash 键值对数据 2.查询 Hash 键是否存在 3.查询 Hash 中所有的键 Field 4.查询 Hash 中 ...
- tp5 日期范围查询_tp5(thinkPHP5框架)时间查询操作实例分析,tp5thinkphp5
tp5(thinkPHP5框架)时间查询操作实例分析,tp5thinkphp5 本文实例讲述了tp5(thinkPHP5框架)时间查询操作.分享给大家供大家参考,具体如下: 在项目中 可能会遇到 跨月 ...
- tp5 日期范围查询_tp5(thinkPHP5框架)时间查询操作实例分析
本文实例讲述了tp5(thinkPHP5框架)时间查询操作.分享给大家供大家参考,具体如下: 在项目中 可能会遇到 跨月份进行查询 比如在 当输入201809 会获取当月的开始时间$start_mon ...
- Redis实现库存扣减操作
具体关于lua脚本的内容使用请移步至 redis命令参考–Script脚本 : http://doc.redisfans.com/script/index.html 在日常开发中有很多地方都有类似扣减 ...
- redis提高oracle性能,redis性能分析与优化建议
首先,并不是说redis是内存应用就完全没性能问题,用的不好,还是会出现各种状况,例如RDB频繁,碎片太多等. 性能分析 info信息: 在redis-cli进入登录界面后,输入info all,或者 ...
- 双汇大数据方案选型:从棘手的InfluxDB+Redis到毫秒级查询的TDengine
双汇发展多个分厂的能源管控大数据系统主要采用两种技术栈:InfluxDB/Redis和Kafka/Redis/HBase/Flink,对于中小型研发团队来讲,无论是系统搭建,还是实施运维都非常棘手.经 ...
- 案例分析 | 由Decimal操作计算引发的Spark数据丢失问题
转载自 案例分析 | 由Decimal操作计算引发的Spark数据丢失问题 供稿 | Hadoop Team 编辑 | 顾欣怡 本文3058字,预计阅读时间10分钟 导读 eBay的Hadoop集群 ...
最新文章
- 交换机工作原理、MAC地址表、路由器工作原理详解
- python读取c盘中的csv文件-python读取当前目录下的CSV文件数据
- Qt运行一个实例进程
- 一些奇妙的线段树操作
- 树,森林,二叉树的互相转换
- [CareerCup] 4.7 Lowest Common Ancestor of a Binary Search Tree 二叉树的最小共同父节点
- js中split,splice,slice方法之间的差异。
- thread类 java_java入门避坑必读,通过Thread类创建java多线程
- 二重循环~~for循环
- android多板面式布局,Android Design
- 怎么把git代码导入到本地仓库_git在本地仓库添加了一个tag,如何把这个tag同步到远程仓库?...
- Debian+Django+uWsgi+nginx+mysql+celery
- jQuery命令汇总(转)
- wafer map格式转换_如何将谷歌地球KML图层转换为Mapinfo TAB图层?
- 【转载】SI 9000 及阻抗匹配学习笔记(一)
- 小米摄像头共享显示服务器错误6,小米摄像头
- dx逆向建模步骤_什么是3D打印?游戏建模具体是什么的?哪个更有发展
- 关于 U盘被写保护的问题
- windows查找文件内容和文件内容
- github创建仓库以及上传项目到github
热门文章
- K-periodic Garland CodeForces - 1353E(暴力+贪心+dp)
- ajax获取php的数组,使用AJAX请求获取数组并将其传递到php数组中 - javascript
- html自定义鼠标右键,js自定义鼠标右键的实现原理及源码
- Java将五个整数存入整形数组_异常处理:从命令行输入5个整数,放入一整型数组,然后打印输出。。。...
- 内存超频trfc_这只是开始?四款DDR4内存超频效果对比
- word List 34
- 【BZOJ4916】神犇和蒟蒻(杜教筛)
- Codeforces Round #579 (Div. 3) F1. Complete the Projects (easy version) 排序 + 贪心
- Codeforces Round #736 (Div. 2) D. Integers Have Friends ST表gcd + 尺取
- Codeforces Round #624 (Div. 3) D. Three Integers 数论