一、基础环境安装
https://pypi.python.org/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_hostname-3.4.0.2.tar.gz
tar xvzf backports.ssl_match_hostname-3.4.0.2.tar.gz
cd backports.ssl_match_hostname-3.4.0.2
python setup.py install
https://github.com/facebook/tornado/archive/v3.2.0.tar.gz
tar xvzf tornado-3.2.0.tar.gz
cd tornado-3.2.0
python setup.py install
https://pypi.python.org/packages/source/r/redis/redis-2.9.1.tar.gz
tar xvzf redis-py-2.9.1.tar.gz
cd redis-py-2.9.1
python setup.py install
https://pypi.python.org/packages/source/s/six/six-1.5.2.tar.gz
tar xvzf six-1.5.2.tar.gz
cd six-1.5.2
python setup.py install
https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.2.tar.gz
tar xvzf python-dateutil-2.2.tar.gz
cd python-dateutil-2.2
python setup.py install
https://pypi.python.org/packages/18/dd/e617cfc3f6210ae183374cd9f6a26b20514bbb5a792af97949c5aacddf0f/argparse-1.4.0.tar.gz#md5=08062d2ceb6596fcbc5a7e725b53746f
tar xvzf argparse-1.4.0.tar.gz
cd argparse-1.4.0
python setup.py install
https://codeload.github.com/nkrode/RedisLive/zip/master
unzip RedisLive-master.zip
mv RedisLive-master RedisLive
http://distfiles.macports.org/py-setuptools/
setuptools-36.2.7.zip
unzip setuptools-36.2.7.zip
sh setuptools*
https:
//github.com/nkrode/RedisLive
tar -xf RedisLive-master.zip -C /data/
cd /data/
mv RedisLive-master RedisLive
|
在RedisServers中设置需要监控的Redis-server;
DataStoreType决定使用那种类型的数据存储,
如果是redis,使用RedisStatsServer作为数据存储的目标;
如果是sqlite,使用SqliteStatsStore作为数据存储的目标。
整个配置实际上是一个json对象,RedisServers是redis服务器的信息,由于是数组类型所以配置多个redis实例。DataStoreType是监控信息的存储方式,有”redis”和” sqlite”两种方式,分别对应下面RedisStatsServer和SqliteStatsStore,编辑完成后保存。
redis-live.py是用来启动web服务的,默认端口是8888 。redis-monitor.py就是redis监控的核心服务。
2、初始化DBcd db
cat schema.sql | sqlite3 redislive.sqlite
3、配置RedisLive的定期监控
*/5 * * * * cd /data/Redis-Monitor/RedisLive/src; ./redis-monitor.py --duration 20 >/dev/null 2>&1
4、服务启动
RedisLive的功能分两个部分:
一个部分是redis-server状态数据的采集,通过src/redis-monitor.py来执行;
另外一部分功能是提供对状态数据的查询服务,通过src/redis-live.py来提供web服务。
./redis-monitor.py --duration 120 &
//启动监控,duration是心跳时间
./redis-live.py&
//启动web服务,默认监听8888端口
注:./redis-live.py &
[root@pro-kibana src]# Traceback (most recent call last):
File "./redis-live.py", line 10, in
from api.controller.ServerListController import ServerListController
File "/data/RedisLive/src/api/controller/ServerListController.py", line 1, in
from BaseController import BaseController
File "/data/RedisLive/src/api/controller/BaseController.py", line 1, in
from dataprovider.dataprovider import RedisLiveDataProvider
File "/data/RedisLive/src/dataprovider/dataprovider.py", line 2, in
import sqliteprovider
File "/data/RedisLive/src/dataprovider/sqliteprovider.py", line 3, in
import sqlite3
File "/usr/local/python2.7/lib/python2.7/sqlite3/__init__.py", line 24, in
from dbapi2 import *
File "/usr/local/python2.7/lib/python2.7/sqlite3/dbapi2.py", line 28, in
from _sqlite3 import *
ImportError: No module named _sqlite3
解决:安装sqlite
tar -xf setuptools-23.0.0.tar.gz
cd sqlite-autoconf-3130000
./configure --prefix=/usr/local/sqlite3
make && make install
netstat
-ntpl
|grep python
root@storm-master-01:/home/redis/monitor/RedisLive-master/src#netstat -anltp|grep pythontcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 194074/python tcp 0 0 192.168.1.247:43929 192.168.1.247:3309 ESTABLISHED 126445/python3 tcp 0 0 192.168.1.247:45314 192.168.1.247:3309 ESTABLISHED 192761/python3 tcp 0 0 192.168.1.247:8888 192.168.0.250:65142 ESTABLISHED 194074/python tcp 0 0 192.168.1.247:8888 192.168.0.250:64907 ESTABLISHED 194074/python tcp 0 0 192.168.1.247:8888 192.168.0.250:64594 ESTABLISHED 194074/python tcp 0 0 192.168.1.247:45313 192.168.1.247:3309 ESTABLISHED 192761/python3 tcp 0 0 192.168.1.247:8888 192.168.0.250:63135 ESTABLISHED 194074/python tcp6 0 0 :::8888 :::* LISTEN 194074/python root@storm-master-01:/home/redis/monitor/RedisLive-master/src#5、然后在浏览器中打开 http://192.168.1.247:8888/index.html,就可以看到监控信息了:6、安装redis-stat卸载老版本: yum erase ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs1)安装ruby 2.0以上 tar -xf ruby-2.1.9.tar.gz cd ruby-2.1.9./configure --prefix=/usr/local/ruby2.0makemake install配置连接: cd /usr/local/ruby2.0/for i in `ls`;do ln -s /usr/local/ruby2.0/bin/$i /usr/bin/$i;done添加淘宝源: gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/2)安装redis-stat cd /data/git clone https://github.com/junegunn/redis-stat.gitcd /data/redis-stat/bin/
# ./redis-stat --help
命令行运行:
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
|
redis-stat运行为服务:
redis-stat --server
redis-stat --verbose --server=
8080
5
# redis-stat server can be daemonized
redis-stat --server --daemon
# Kill the daemon
killall -
9
redis-stat-daemon
|
以守护进程模式启动:
redis-stat --verbose --server=
8080
5
--daemon
|
运行其它主机实例: