监控redis集群服务的软件还不少,但是可视化的不多,了解到的就是redis-live和radish。
但是radish国内貌似登陆不了,要翻墙,而且是收费软件,没用上。
这里主要就是描述一下redis-live的安装和使用。
相关网址:https://github.com/nkrode/RedisLive
目前所知的监控软件基本都是根据redis的命令monitor和info来做的,如果只是需要一些统计信息,自己弄一个也不难。
一、安装 (保证自己的python版本在2.7之后)
apt-get install python-setuptools python-dev
easy_install pip
pip install dateutil//安装了python-dev后就不需要安装这个了,已经包含其中了
pip install redis
pip install tornado// 不安装的话在运行redis-live.py的时候报错
二、部署配置
a. 在Github下载nkrode-RedisLive-3a18ddc.zip
b. 修改配置文件
vi ./src/redis-live.conf
可以看出这个配置文件是json格式的,注意不要产生格式错误,对着原始的配置文件来
原始的配置文件如下:
{
"RedisServers":
[
{
"server": "154.17.59.99",
"port" : 6379
},
{
"server": "localhost",
"port" : 6380,
"password" : "some-password"
}
],
"DataStoreType" : "redis",
"RedisStatsServer":
{
"server" : "ec2-184-72-166-144.compute-1.amazonaws.com",
"port" : 6385
},
"SqliteStatsStore" :
{
"path": "to your sql lite file"
}
}
解析一下:
RedisServers: 就是所要监控的redis集群的所有主机,可以配置host, port, password,注意最后一个元素后面没有逗号。
DataStoreType: 就是类似元数据存储的类型,默认是redis,也可以是sqlite;
RedisStatsServer: 如果存储类型选择了reids,就需要配置此项,即另外拿出一个redis来存储其他redis的状态信息,也就是上面说的元数据。
SqliteStatisStore: 如果存储类型选择了sqlite,就配置此项,指定一个路径保存sqlite文件。
没仔细研究,估计是已经把sqlite文件包含在安装文件里头了。
三、启动
./redis-monitor.py --duration=120
./redis-live.py
http://redisLive_host:8888/index.html
以上两个进程都是默认前台运行,可以弄到后台去执行
nohup ./redis-monitor.py --duration=36000 --quiet &
nohup ./redis-live.py --log_file_prefix=/home/user/log/redis_live --logging=warning &
usage: redis-monitor.py [-h] --duration DURATION [--quiet]
Monitor redis.
optional arguments:
-h, --help show this help message and exit
--duration DURATION duration to run the monitor command (in seconds)
--quiet do not write anything to standard output
Usage: ./redis-live.py [OPTIONS]
Options:
--debug debug mode (default 0)
--help show this help information
--port run on the given port (default 8888)
/usr/local/lib/python2.7/dist-packages/tornado/log.py options:
--log_file_max_size max size of log files before rollover
(default 100000000)
--log_file_num_backups number of log files to keep (default 10)
--log_file_prefix=PATH Path prefix for log files. Note that if you
are running multiple tornado processes,
log_file_prefix must be different for each
of them (e.g. include the port number)
--log_to_stderr Send log output to stderr (colorized if
possible). By default use stderr if
--log_file_prefix is not set and no other
logging is configured.
--logging=debug|info|warning|error|none
Set the Python log level. If 'none', tornado
won't touch the logging configuration.
(default info)