RedisStat的安装指南

早上好,送你清新的问候,温馨的祝福,清晨,美好的开始,祝你今天精神棒棒,活力多多,心情好好,一切都好!

redis-stat是一个用ruby写成的监控redis的程序,基于info命令获取信息,而不是通过monitor获取信息

一、安装ruby


yum install -y ruby ruby-devel rubygems
apt-get install rubygems ruby..

由于国内网络原因,导致 rubygems.org 存放在 Amazon S3 上面的资源文件间歇性连接失败。所以你会与遇到 gem install rack 或 bundle install 的时候半天没有响应,所以需要修改rubygems为淘宝镜像。

二、替换rubygems


gem sources --add https://ruby.taobao.org/ --remove http://rubygems.org/
gem sources -l

三、安装redis-stat


git clone https://github.com/junegunn/redis-stat.git
gem install redis-stat

会提示

Building native extensions. This could take a while...
Building native extensions. This could take a while...
Building native extensions. This could take a while...
ERROR: Error installing redis-stat:
redis-stat requires daemons (~> 1.1.9, runtime)

四、卸载daemons


gem uninstall daemons
gem install daemons
gem install redis-stat

装redis-stat同时会安装daemons-1.1.9,如果系统已安装daemons其他版本,需再次卸载

ERROR: Error installing redis-stat:
redis-stat requires daemons (~> 1.1.9, runtime)


gem uninstall daemons

Select gem to uninstall:
1. daemons-1.1.9
2. daemons-1.2.3
3. All versions
> 2
Successfully uninstalled daemons-1.2.3

五、安装SystemTimer


gem install SystemTimer

然后就可以启动redis-stat了


redis-stat --verbose --server= ...: ...:
redis-stat 110.160.4.71:6379 110.47.90.168:6379 1 10

补充:redis-stat

redis-stat是实时监控Redis实例的状态,包括overview、vmstat、vmpage、ondisk-size、latency,具体信息如下:


$ ./redis-stat help
Usage: redis-stat <type> ... options ...

Statistic types:


overview (default) Print general information about a Redis instance.
vmstat Print information about Redis VM activity.
vmpage Try to guess the best vm-page-size for your dataset.
ondisk-size Stats and graphs about values len once stored on disk.
latency Measure Redis server latency.

Options:


host <hostname> Server hostname (default 127.0.0.1)
port <hostname> Server port (default 6379)
delay <milliseconds> Delay between requests (default: 1000 ms, 1 second).
samplesize <keys> Number of keys to sample for 'vmpage' stat.
logscale User power-of-two logarithmic scale in graphs.

一个简单的测试例子:


$ ./redis-stat host 127.0.0.1 port 6379
------- data ------ --------------------- load -------------------- - child -
keys mem clients blocked requests connections
29602 3.45M 1 0 30090 (+0) 157
29602 3.45M 1 0 30091 (+1) 157
29602 3.45M 1 0 30092 (+1) 157
29602 3.45M 1 0 30093 (+1) 157
29602 3.45M 1 0 30094 (+1) 157
29602 3.45M 1 0 30095 (+1) 157
29602 3.45M 1 0 30096 (+1) 157
29602 3.45M 1 0 30097 (+1) 157
29602 3.45M 1 0 30098 (+1) 157
...
...

查看Redis实例的实时的latency也非常有用:


$ ./redis-stat latency host 127.0.0.1 port 6379
1: 0.23 ms
2: 0.67 ms
3: 0.21 ms
4: 0.23 ms
5: 0.23 ms
6: 0.16 ms
7: 0.37 ms
...
...

本文RedisStat的安装指南到此结束。是欲望,是理想,是伟大的梦想,充实了我们大脑,每一天,每一点,每一刻,都不能停止前进的脚步,因为为了欲飞就要努力跑,一直不停地向前行,一直走到生命的终结点,也不肯放弃。虽然我们不是鸟,是人,但是我们可以做一只天中的鸟人,鸟人多好,俯视大地,山川美景尽收眼底,那该是那么伟大而自豪的事;在地上,我们只是普普通通的小人,但是我们可以做一个了不起的人物;去认真做一件你没敢实现的大事,那么,成功就在彼岸,你就会因此而变得不平凡。小编再次感谢大家对我们的支持!