原文转自:http://www.tqcto.com/article/recommend/97.html
Redis如今在业务中应用已经非常广泛了,可是怎样监控redis,实时的观察redis的性能,却非常少的提及,如今常见的监控方案基本上都是使用redis自带的info命令和monitor命令获取相关信息,然后提取出来显示。
測试环境:
redis版本号:2.4.17
IP:10.20.111.188
1 redis-faina
一个使用redis自带命令monitor的输出结果做分析的python脚本,在命令行下使用。能够做实时分析使用。
官网:https://github.com/Instagram/redis-faina
下载试用:
1 2 3 4 | cd / opt / test git clone https: / / github.com / Instagram / redis - faina.git cd redis - faina / redis - cli - p 6379 MONITOR | head - n 100 | . / redis - faina.py - - redis - version = 2.4 |
能够看到一些实时的数据,而且有一定的统计数据。能够作为一个命令行工具使用。推荐使用,只是redis版本号要大于2.4。
2 redis-live
一个用来监控redis实例,分析查询语句而且有web界面的监控工具,python编写。
官网:https://github.com/nkrode/RedisLive
下载试用:
执行环境依赖包安装:http://www.nkrode.com/article/real-time-dashboard-for-redis
redis-live安装:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | cd / root git clone https: / / github.com / nkrode / RedisLive.git cd RedisLive / src ###改动redis-live.conf文件 { "RedisServers" : [ { "server" : "10.20.111.188" , "port" : 6379 } ], "DataStoreType" : "redis" , "RedisStatsServer" : { "server" : "10.20.111.188" , "port" : 6380 }, "SqliteStatsStore" : { "path" : "to your sql lite file" } } ###改动完成 ###启动监控服务。每30秒监控一次 . / redis - monitor.py - - duration = 30 ###再次开启一个终端,进入/root/RedisLive/src文件夹,启动web服务 . / redis - live.py |
一个web界面。能够同一时候监控多个redis实例,做集中监控比較好。
3 redis-stat
一个用ruby写成的监控redis的程序。基于info命令获取信息。而不是通过monitor获取信息,性能应该比monitor要好。
官网:https://github.com/junegunn/redis-stat
执行环境安装:
1 2 | apt - get install ruby apt - get install rubygems |
1 2 3 4 5 | cd / root git clone https: / / github.com / junegunn / redis - stat.git cd / root / redis - stat / bin ###./redis-stat --help 能够看到使用帮助 . / redis - stat 1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 | usage: redis - stat [HOST[:PORT] ...] [INTERVAL [COUNT]] - a, - - auth = PASSWORD Password - v, - - verbose Show more info - - style = STYLE Output style: unicode |ascii - - no - color Suppress ANSI color codes - - csv = OUTPUT_CSV_FILE_PATH Save the result in CSV format - - server[ = PORT] Launch redis - stat web server (default port: 63790 ) - - daemon Daemonize redis - stat. Must be used with - - server option. - - version Show version - - help Show this message |
1 2 3 4 5 6 7 | redis - stat redis - stat 1 redis - stat 1 10 redis - stat - - verbose redis - stat localhost: 6380 1 10 redis - stat localhost localhost: 6380 localhost: 6381 5 redis - stat localhost localhost: 6380 1 10 - - csv = / tmp / output.csv - - verbose |
1 2 3 | redis - stat - - server redis - stat - - verbose - - server = 8080 5 redis - stat - - server - - daemon |
效果例如以下:
执行web模式
1 2 | cd / root / redis - stat / bin . / redis - stat - - server = 8080 5 - - daemon |
不错的工具,既有命令行又有web界面,能够放到后台执行,数据比redis-live感觉直观 。ruby开发的。唯一的缺点是假设同一时候监控多个redis实例,不能单独显示每个实例的数据信息。貌似是总和。
4 redis-monitor
一个国人用java写的。官网的是在win下编译的,看着不错,只是我在linux下没调试起来...
官网:https://github.com/litiebiao2012/redis-monitor
个人感觉。做集中监控能够使用redis-live。在命令行使用能够使用redis-stat。也能够依据自己的情况自行编写。总之就是依据info和monitor命令获取并展示信息。