1. 程式人生 > >安裝redis-live監控redis叢集

安裝redis-live監控redis叢集

監控redis叢集服務的軟體還不少,但是視覺化的不多,瞭解到的就是redis-live和radish。

但是radish國內貌似登陸不了,要翻牆,而且是收費軟體,沒用上。

這裡主要就是描述一下redis-live的安裝和使用。

目前所知的監控軟體基本都是根據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)