程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Redis教程 >> 關於Redis >> Redis Stat的安裝指南

Redis Stat的安裝指南

編輯:關於Redis

redis-stat是一個用ruby寫成的監控redis的程序,基於info命令獲取信息,而不是通過monitor獲取信息

一、安裝ruby

復制代碼 代碼如下:
yum install -y ruby ruby-devel rubygems
apt-get install rubygems ruby..

由於國內網絡原因,導致 rubygems.org 存放在 Amazon S3 上面的資源文件間歇性連接失敗。所以你會與遇到 gem install rack 或 bundle install 的時候半天沒有響應,所以需要修改rubygems為淘寶鏡像。

二、替換rubygems

復制代碼 代碼如下:
gem sources --add https://ruby.taobao.org/ --remove http://rubygems.org/
gem sources -l

三、安裝redis-stat

復制代碼 代碼如下:
git clone https://github.com/junegunn/redis-stat.git
gem install redis-stat

會提示

Building native extensions. This could take a while...
Building native extensions. This could take a while...
Building native extensions. This could take a while...
ERROR: Error installing redis-stat:
redis-stat requires daemons (~> 1.1.9, runtime)

四、卸載daemons

復制代碼 代碼如下:
gem uninstall daemons
gem install daemons
gem install redis-stat

裝redis-stat同時會安裝daemons-1.1.9,如果系統已安裝daemons其他版本,需再次卸載

ERROR: Error installing redis-stat:
redis-stat requires daemons (~> 1.1.9, runtime)

復制代碼 代碼如下:
gem uninstall daemons

Select gem to uninstall:
1. daemons-1.1.9
2. daemons-1.2.3
3. All versions
> 2
Successfully uninstalled daemons-1.2.3

五、安裝SystemTimer

復制代碼 代碼如下:
gem install SystemTimer

然後就可以啟動redis-stat了

復制代碼 代碼如下:
redis-stat --verbose --server= ...: ...:
redis-stat 110.160.4.71:6379 110.47.90.168:6379 1 10

補充:redis-stat

redis-stat是實時監控Redis實例的狀態,包括overview、vmstat、vmpage、ondisk-size、latency,具體信息如下:

復制代碼 代碼如下:
$ ./redis-stat help
Usage: redis-stat <type> ... options ...

Statistic types:

復制代碼 代碼如下:
overview (default) Print general information about a Redis instance.
vmstat Print information about Redis VM activity.
vmpage Try to guess the best vm-page-size for your dataset.
ondisk-size Stats and graphs about values len once stored on disk.
latency Measure Redis server latency.

Options:

復制代碼 代碼如下:
host <hostname> Server hostname (default 127.0.0.1)
port <hostname> Server port (default 6379)
delay <milliseconds> Delay between requests (default: 1000 ms, 1 second).
samplesize <keys> Number of keys to sample for 'vmpage' stat.
logscale User power-of-two logarithmic scale in graphs.

一個簡單的測試例子:

復制代碼 代碼如下:
$ ./redis-stat host 127.0.0.1 port 6379
------- data ------ --------------------- load -------------------- - child -
keys mem clients blocked requests connections
29602 3.45M 1 0 30090 (+0) 157
29602 3.45M 1 0 30091 (+1) 157
29602 3.45M 1 0 30092 (+1) 157
29602 3.45M 1 0 30093 (+1) 157
29602 3.45M 1 0 30094 (+1) 157
29602 3.45M 1 0 30095 (+1) 157
29602 3.45M 1 0 30096 (+1) 157
29602 3.45M 1 0 30097 (+1) 157
29602 3.45M 1 0 30098 (+1) 157
...
...

查看Redis實例的實時的latency也非常有用:

復制代碼 代碼如下:
$ ./redis-stat latency host 127.0.0.1 port 6379
1: 0.23 ms
2: 0.67 ms
3: 0.21 ms
4: 0.23 ms
5: 0.23 ms
6: 0.16 ms
7: 0.37 ms
...
...

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved