時間有限,只能簡單列出安裝步驟
可以參考Redis live官方文檔
http://www.nkrode.com/article/real-time-dashboard-for-redis
1.安裝pip
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
tar xf pip-1.5.4.tar.gz
cd pip-1.5.4
python setup.py install
2.安裝redis live依賴
安裝依賴 tornado redis模塊 python-dateutil,argparse(python版本小於2.7就需要這個)
Install Dependencies
· tornado pip install tornado
· redis.py pip install redis
· python-dateutil pip install python-dateutil
You'll also need argparse if you're running Python < 2.7:
· argparse pip install argparse
3.安裝redis live
wget https://codeload.github.com/nkrode/RedisLive/legacy.zip/master
解壓到/application/tools
進入到解壓目錄下的src目錄下
vim redis-live.conf 沒有可以將src目錄下的redis-live.conf.example 複製一份
{
"RedisServers":
[
//此處配置的是redis的地址及端口 多個可以按照下面的格式,{}添加
{
"server": "192.168.14.192",
"port" : 6379
}
],
"DataStoreType" : "sqlite",//172.16.0.70採用的是sqlite
//如果DataStoreType是用redis 不是用 sqlite 就用配置 RedisStatsServer
"RedisStatsServer":
{
"server": "192.168.14.192",
"port" : 6381
},
//如果DataStoreType不是用redis是用sqlite 就要配置SqliteStatsStore
"SqliteStatsStore":
{
"path": "/opt/portal/RedisLive/src/db/redislive.sqlite"
}
}
RedisServers爲你要監控的redis實例,可以添加多個
如果redis有密碼,可以在實例配置中加入password選項;
DataStoreType決定使用那種類型的數據存儲,(推薦用sqlite)
如果是redis,使用RedisStatsServer作爲數據存儲的目標;(配置的redis 不要是被監控的,所以還是推薦用sqlite)
如果是sqlite,使用SqliteStatsStore作爲數據存儲的目標。
RedisStatsServer是用於存儲RedisLive監控數據的redis實例,
if you don't have a spare redis instance to use to store RedisLive data, then you can configure RedisLive to use sqlite by changing to "DataStoreType" : "sqlite"
RedisLive的功能分兩個部分:
一個部分是redis-server狀態數據的採集,通過src/redis-monitor.py來執行;
另外一部分功能是提供對狀態數據的查詢服務,通過src/redis-live.py來提供web服務。
初始化DB(必須的,否則報錯)
# cd db
# cat schema.sql | sqlite3 redislive.sqlite
後臺啓動
*/5 * * * * cd /application/tools/nkrode-RedisLive-6debcb4/src; ./redis-monitor.py --duration 20 >/dev/null 2>&1
nohup ./redis-live.py & >/dev/null 2>&1