1. INFO

info指令返回服务器相关信息,包括:

  • server: General information about the Redis server

  • clients: Client connections section

  • memory: Memory consumption related information

  • persistence: RDB and AOF related information

  • stats: General statistics

  • replication: Master/slave replication information

  • cpu: CPU consumption statistics

  • commandstats: Redis command statistics

  • cluster: Redis Cluster section

  • keyspace: Database related statistics

其本身支持定制返回列表:

[root@~]# redis-cli info
[root@~]# redis-cli info default
[root@~]# redis-cli info all

详情请见: http://www.redis.cn/commands/info.html

2. MONITOR

MONITOR是一个调试命令,返回服务器处理的每一个命令,它能帮助我们了解在数据库上发生了什么操作。共有3种操作方法:

[root@~]# redis-cli monitor
OK
1417532512.619715 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623624"
[root@~]# telnet 127.0.0.1 6379
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
monitor
+OK
+1417532567.733458 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623708"
+1417532568.735936 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623708"
quit
+OK
Connection closed by foreign host.
[root@~]# redis-cli
127.0.0.1:6379> monitor
OK
1417532590.785487 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623736"

由于MONITOR命令返回服务器处理的所有的命令, 所以在性能上会有一些消耗。使用官方的压测工具测试结果如下

在不运行MONITOR命令的情况下,benchmark的测试结果:

[root@~/software/redis-2.8.17]# src/redis-benchmark -c 10 -n 100000 -q
PING_INLINE: 51020.41 requests per second
PING_BULK: 50607.29 requests per second
SET: 37257.82 requests per second
GET: 49800.80 requests per second
INCR: 38699.69 requests per second
LPUSH: 38910.51 requests per second
LPOP: 39277.30 requests per second
SADD: 54614.96 requests per second
SPOP: 51948.05 requests per second
LPUSH (needed to benchmark LRANGE): 38819.88 requests per second
LRANGE_100 (first 100 elements): 20112.63 requests per second
LRANGE_300 (first 300 elements): 9025.27 requests per second
LRANGE_500 (first 450 elements): 6836.67 requests per second
LRANGE_600 (first 600 elements): 5406.28 requests per second
MSET (10 keys): 19394.88 requests per second

在运行MONITOR命令的情况下,benchmark的测试结果: (redis-cli monitor > /dev/null):

[root@~/software/redis-2.8.17]# src/redis-benchmark -c 10 -n 100000 -q
PING_INLINE: 42211.91 requests per second
PING_BULK: 42936.88 requests per second
SET: 26143.79 requests per second
GET: 33990.48 requests per second
INCR: 26553.37 requests per second
LPUSH: 27337.34 requests per second
LPOP: 27225.70 requests per second
SADD: 30459.95 requests per second
SPOP: 39494.47 requests per second
LPUSH (needed to benchmark LRANGE): 26315.79 requests per second
LRANGE_100 (first 100 elements): 22055.58 requests per second
LRANGE_300 (first 300 elements): 8104.38 requests per second
LRANGE_500 (first 450 elements): 6371.05 requests per second
LRANGE_600 (first 600 elements): 5031.95 requests per second
MSET (10 keys): 14861.05 requests per second

可以看到各项指标基本都有所下降。

详情请见: http://www.redis.cn/commands/monitor.html

3. SLOWLOG

通过SLOWLOG可以读取慢查询日志。

使用SLOWLOG LEN就可以获取当前慢日志长度。

[root@~/software/redis-2.8.17]# redis-cli
127.0.0.1:6379> slowlog len
(integer) 28

使用SLOWLOG GET就可以获取所有慢日志。

127.0.0.1:6379> slowlog get
1) 1) (integer) 27
2) (integer) 1417531320
3) (integer) 24623
4) 1) "info"

其中,各项指标表示:

  • A unique progressive identifier for every slow log entry.

  • The unix timestamp at which the logged command was processed.

  • The amount of time needed for its execution, in microseconds(注意,microseconds翻译成微秒,而不是毫秒).

  • The array composing the arguments of the command.

使用SLOWLOG GET N就可以获取最近N条慢日志。

127.0.0.1:6379> slowlog get 2
1) 1) (integer) 27
2) (integer) 1417531320
3) (integer) 24623
4) 1) "info"
2) 1) (integer) 26
2) (integer) 1417528379
3) (integer) 21363
4) 1) "get"
2) "user:score"

使用SLOWLOG RESET命令重置慢日志。一旦执行,将丢失以前的所有慢日志。

127.0.0.1:6379> slowlog reset

详情请见: http://www.redis.cn/commands/slowlog.html

Redis常用命令解析——INFO, MONITOR, SLOWLOG的更多相关文章

  1. No-sql之redis常用命令

    转自:http://blog.csdn.net/nicewuranran/article/details/51793760 No-SQL之Redis 介绍 Redis是一种基于内存存储的key-val ...

  2. Redis常用命令

    Redis常用命令Redis提供了丰富的命令对数据库和各种数据类型进行操作,这些命令可以再Linux终端使用.1.键值相关命令2.服务器相关命令 一.键值相关命令 1.get get 键值 当 key ...

  3. Redis常用命令手册:服务器相关命令

    Redis提供了丰富的命令(command)对数据库和各种数据类型进行操作,这些command可以在Linux终端使用.在编程时,比如各类语言包,这些命令都有对应的方法.下面将Redis提供的命令做一 ...

  4. 第2讲 Redis常用命令与高级应用

    目录 一.redis数据类型 5. sorted sets类型和操作 二.Redis常用命令 1.键值相关命令 2.服务器相关命令 三. redis高级应用 1. 给redis服务器设置密码 2.持久 ...

  5. redis redis常用命令及内存分析总结(附RedisClient工具简介

    redis常用命令及内存分析总结(附RedisClient工具简介 by:授客 QQ:1033553122 redis-cli工具 查看帮助 连接redis数据库 常用命令 exists key se ...

  6. Redis常用命令与高级应用

    附: 127.0.0.1:6379> set xiaofei 小飞 OK 127.0.0.1:6379> get xiaofei "\xe5\xb0\x8f\xe9\xa3\x9 ...

  7. Redis快速起步及Redis常用命令大全

    本系列教程内容提要 Java工程师之Redis实战系列教程教程是一个学习教程,是关于Java工程师的Redis知识的实战系列教程,本系列教程均以解决特定问题为目标,使用Redis快速解决在实际生产中的 ...

  8. angular-cli.json配置参数解析,常用命令解析

    1.angular-cli.json配置参数解析 { "project": { "name": "ng-admin", //项目名称 &qu ...

  9. redis配置密码 redis常用命令

    redis配置密码 1.通过配置文件进行配置yum方式安装的redis配置文件通常在/etc/redis.conf中,打开配置文件找到 [plain] view plain copy   #requi ...

随机推荐

  1. Android安装包相关知识汇总 (编译过程图给力)

    转自: https://mp.weixin.qq.com/s?__biz=MzAwNDY1ODY2OQ==&mid=208008519&idx=1&sn=278b7793699 ...

  2. import MySQLdb UserWarning

    Finished processing dependencies for MySQL-python==1.2.5 ╭─haoke@haokedeMBP ~/ProgramFiles/MySQL-pyt ...

  3. #define 与 typedef

    1.#define:预编译指令,在预编译的时候,进行文本替换. 2.typedef:编译时处理,为类型取一个别名. 3.#define与typedef的顺序是相反的,记住typedef就行了.type ...

  4. Android应用更新自动检测下载

    由于Android项目开源所致,市面上出现了N多安卓软件市场.为了让我们开发的软件有更多的用户使用,我们需要向N多市场发布,软件升级后,我们也必须到安卓市场上进行更新,给我们增加了工作量.因此我们有必 ...

  5. webservice接口示例(spring+xfire+webservice)

      webservice接口示例(spring+xfire+webservice) CreateTime--2018年4月2日17:36:07 Author:Marydon 一.准备工作 1.1 ja ...

  6. 【Django】ImportError: cannot import name 'execute_manager'

    错误描述 在使用Django 2.0 启动项目的时候,报错如下: ImportError: cannot import name 'execute_manager' 修改前后代码对比 修改前的代码 # ...

  7. 如何自动生成Makefile

    作为Linux下的程序开发人员,大家一定都遇到过Makefile,用make命令来编译自己写的程序确实是很方便.一般情况下,大家都是手工写一个简单Makefile,如果要想写出一个符合自由软件惯例的M ...

  8. 通讯录结构体方法的实现 和VS中存在的一些问题的分析

    实现一个通讯录: 通讯录能够用来存储1000个人的信息.每一个人的信息包含: 姓名.性别.年龄.电话.住址 功能例如以下: 1.  加入联系人信息 2.  删除指定联系人信息 3.  查找指定联系人信 ...

  9. PHP-"php://(类型)"访问各个输入/输出流以及全局变量$HTTP_RAW_POST_DATA讲解

    $_POST $HTTP_RAW_POST_DATA php://input 先来讲以上三者的区别: $_POST:以关联数组方式组织提交的数据, 并对原数据进行编码处理(urldecode)和编码转 ...

  10. C-常用构造哈希函数

    1.定址法(比如0-100岁的人数统计, 可以按年龄作为散列地址, 1980年后每年出生人数的统计, 可以把"年限 - 1980"作为散列地址) 2.取余法 3.数字分析法(比如一 ...