Redis-stat(Ruby)和Redis Live(python)是兩款Redis監控工具,下面將介紹如何安裝部署這兩個工具,監控Redis運行狀況html
Ubuntu 14.04 LTS x64 Redis redis-3.0.7.tar.gz Ruby ruby 1.9.3 Python 2.7.6
Redis安裝請參照:Redis安裝與配置python
redis-stat is a simple Redis monitoring tool written in Ruby.git
It is based on INFO command of Redis, and thus generally won’t affect the performance of the Redis instance unlike the other monitoring tools based on MONITOR command.github
redis-stat allows you to monitor Redis instancesweb
Github地址redis
sudo apt-get autoremove --purge ruby*
sudo apt-get install ruby-full
gem install redis-stat
redis-stat命令參數sql
usage: redis-stat [HOST[:PORT] ...] [INTERVAL [COUNT]]vim
-a, --auth=PASSWORD 設置密碼 -v, --verbose 顯示更多信息 --style=STYLE 輸出編碼類型: unicode|ascii --no-color 取消ANSI顏色編碼 --csv=OUTPUT_CSV_FILE_PATH 以CSV格式存儲結果 --es=ELASTICSEARCH_URL 把結果發送到 ElasticSearch: [http://]HOST[:PORT][/INDEX] --server[=PORT] 運行redis-stat的web server (默認端口號: 63790) --daemon 使得redis-stat成爲進程。必須使用 --server 選項 --version 顯示版本號 --help 顯示幫助信息
redis-stat運行命令行監控 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/outpu.csv --verbose瀏覽器
Server端運行界面ruby
當設置–server選項以後,redis-stat會在後臺啓動一個嵌入式的web server(默認端口號:63790),能夠讓你在瀏覽器中監控Redis
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
而後在你的瀏覽器中輸入:
http://你的Redis IP:63790
Redis Live is a dashboard application with a number of useful widgets. At it’s heart is a monitoring script that periodically issues INFO and MONITOR command to the redis instances and stores the data for analytics.
長時間運行對Redis性能有所影響
git clone https://github.com/kumarnitin/RedisLive.git
進入src目錄
cp redis-live.conf.example ./redis-live.conf vim redis-live.conf { "RedisServers": [ { "server" : "你的Redis IP地址", "port" : 6379 } ........ 能夠多個 ],
"DataStoreType" : "redis", "RedisStatsServer": { "server" : "你的Redis 監控IP地址", "port" : 6379 }, "SqliteStatsStore" : { "path": "to your sql lite file" } }
其中RedisServers爲你要監控的redis實例,能夠添加多個,RedisStatsServer是存儲RedisLive監控數據的實例,若是redis有密碼,能夠在實例配置中加入password選項;若是沒有存儲RedisLive數據的實例,須要將DataStoreType改爲」DataStoreType」 : 「sqlite」這種設置
啓動監控腳本,監控120秒,duration參數是以秒爲單位
sudo ./redis-monitor.py --duration=120
啓動webserver。
RedisLive使用tornado做爲web服務器,因此不須要單獨安裝服務器
Tornado web server 是使用Python編寫出來的一個極輕量級、高可伸縮性和非阻塞IO的Web服務器軟件
sudo ./redis-live.py
而後在你的瀏覽器中輸入:
http://你的Redis IP:8888/index.html
本文來自http://wxmimperio.tk/2016/02/25/Redis-Monitor-Tools/ QQ討論羣組:984370849 706564342 歡迎加入討論
想要深刻學習的同窗們能夠加入QQ羣討論,有全套資源分享,經驗探討,沒錯,咱們等着你,分享互相的故事!