【RedisLive】

1、升級Python到2.7以上。(須要安裝gcc..等依賴)html

[root@hfelkcld0003 local]# pwd
/usr/local

[root@hfelkcld0003 local]# wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz

[root@hfelkcld0003 local]# ll
total 14988
...
-rw-------   1 root root 14135620 Apr  9  2012 Python-2.7.3.tgz
...

[root@hfelkcld0003 local]# tar -zxvf Python-2.7.3.tgz

[root@hfelkcld0003 local]# ll
total 14988
...
drwxr-x---  18 1000 1002     4096 May 11 02:44 Python-2.7.3
-rw-------   1 root root 14135620 Apr  9  2012 Python-2.7.3.tgz

[root@hfelkcld0003 local]# mkdir python27
[root@hfelkcld0003 local]# cd Python-2.7.3

[root@hfelkcld0003 Python-2.7.3]# ./configure --prefix=/usr/local/python27/ && make && make install

[root@hfelkcld0003 Python-2.7.3]# mv /usr/bin/python /usr/bin/python2.6.6
[root@hfelkcld0003 Python-2.7.3]# ln -s /usr/local/python27/bin/python2.7 /usr/bin/python


[root@hfelkcld0003 Python-2.7.3]# python -V
Python 2.7.3

升級後,yum很差用了。依賴於python2.6python

[root@hfelkcld0003 Python-2.7.3]# vi /usr/bin/yum
#!/usr/bin/python                => 修改成以前的 /usr/bin/python2.6.6
import sys
try:
    import yum
....

2、安裝esay_install 和 pipgit

[root@hfelkcld0003 local]# pwd
/usr/local

###https://pypi.python.org/pypi/ez_setup
[root@hfelkcld0003 local]# wget https://pypi.python.org/packages/ba/2c/743df41bd6b3298706dfe91b0c7ecdc47f2dc1a3104abeb6e9aa4a45fa5d/ez_setup-0.9.tar.gz

[root@hfelkcld0003 local]# tar -zxvf ez_setup-0.9.tar.gz

[root@hfelkcld0003 local]# cd ez_setup-0.9

[root@hfelkcld0003 ez_setup-0.9]# python ez_setup.py


###https://pypi.python.org/pypi/pip
[root@hfelkcld0003 local]# wget https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz#md5=87083c0b9867963b29f7aba3613e8f4a

[root@hfelkcld0003 local]# tar -zxvf pip-8.1.2.tar.gz
[root@hfelkcld0003 local]# cd pip-8.1.2
[root@hfelkcld0003 pip-8.1.2]# python setup.py install

[root@hfelkcld0003 pip-8.1.2]# chown u+w /etc/profile
[root@hfelkcld0003 pip-8.1.2]# vi /etc/profile
...
export PATH=/usr/local/python27/bin:$PATH
...

[root@hfelkcld0003 pip-8.1.2]# pip -V
pip 8.1.2 from /usr/local/python27/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg (python 2.7)

3、安裝RedisLive依賴組件github

[root@hfelkcld0003 opt]# pwd
/opt

[root@hfelkcld0003 opt]# pip install tornado
[root@hfelkcld0003 opt]# pip install redis
[root@hfelkcld0003 opt]# pip install python-dateutil

4、安裝配置RedisLiveredis

###https://github.com/nkrode/RedisLive
[root@hfelkcld0003 opt]# git clone https://github.com/nkrode/RedisLive.git

[root@hfelkcld0003 opt]# ll
total 8
drwxr-xr-x 5 root root 4096 May 11 02:38 RedisLive

[root@hfelkcld0003 src]# pwd
/opt/RedisLive/src

[root@hfelkcld0003 src]# cp redis-live.conf.example redis-live.conf -p
[root@hfelkcld0003 src]# vi redis-live.conf.example
{
	"RedisServers":
	[
		{
  			"server": "154.17.59.99",        ==> 目標監控redis ip,port
  			"port" : 6379
		},

		{
  			"server": "localhost",           ==> 能夠同時監控多臺redis server
  			"port" : 6380,
  			"password" : "some-password"
		}
	],

	"DataStoreType" : "redis",                       ==> 監控數據存儲redis/sqlite,選一

	"RedisStatsServer":
	{
		"server" : "ec2-184-72-166-144.compute-1.amazonaws.com",
		"port" : 6385
	},

	"SqliteStatsStore" :
	{
		"path":  "to your sql lite file"
	}
}

[root@hfelkcld0003 src]# cat redis-live.conf
{
	"RedisServers":
	[
		{
  			"server": "xxx.xxx.xxx.xxx",
  			"port" : 6379
		}
	],

	"DataStoreType" : "redis",        

	"RedisStatsServer":
	{
		"server" : "127.0.0.1",        ==> 須要在本server上安裝redis,並啓動
		"port" : 6379
	}
}

4、啓動sql

[root@hfelkcld0003 src]# ./redis-monitor.py -h
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

[root@hfelkcld0003 src]# ./redis-monitor.py --duration 120 &
[root@hfelkcld0003 src]# ./redis-live.py &

[root@hfelkcld0003 src]# netstat -tunpl | grep 8888
...

http://{ip}:8888/index.html



注意:啓動可能會有錯誤:(錯誤基本都是python缺乏對應的module)
如:
ImportError : No module named _sqlite3 on GAE 

Python沒有sqlit-devel模塊,即安裝這些模塊,並從新編譯python便可

[root@hfelkcld0003 src]# rpm -qa|grep sqlite-devel
sqlite-devel-3.6.20-1.el6.x86_64

[root@hfelkcld0003 Python-2.7.3]# pwd
/usr/local/Python-2.7.3

[root@hfelkcld0003 Python-2.7.3]# ./configure --prefix=/usr/local/python27/ && make && make install
相關文章
相關標籤/搜索