靳闯博客 记录是一种习惯,分享是一种态度
  • 波浪
  • 波浪
  • 波浪
  • 波浪
Redis监控工具 redis-stat
发表于: | 分类: 技术积累 | 标签: Redis | 评论:0 | 阅读: 276

redis-stat是一个用Ruby编写的简单的Redis监控工具。

它基于Redis的INFO命令,因此与基于MONITOR命令的其他监视工具不同,它通常不会影响Redis实例的性能。
redis-stat允许您监视Redis单实例和集群。
*或者使用终端的vmstat-like输出
*或者通过嵌入式Web服务器提供的仪表板页面

github源码地址:
redis-stst github地址
参考博客:
redis集群及redis集群监控redis-stat搭建

0,安装redis

参考此篇文章:centos7 安装redis

1,安装ruby gem

yum install ruby ruby-devel rubygem

2,升级ruby到2.4

参考此篇文章:升级ruby到2.4 版本

3,安装ruby和redis之间通信工具

#更换gem源,使用国内镜像源下载更快
gem source -a https://ruby.taobao.org/ #添加淘宝源
gem source -r http://rubygems.org/ #删除境外源

[root@localhost ~]# gem install redis --version 3.0.0 #默认最新是4.0版本
Fetching: redis-3.0.0.gem (100%)
Successfully installed redis-3.0.0
Parsing documentation for redis-3.0.0
Installing ri documentation for redis-3.0.0
Done installing documentation for redis after 1 seconds
1 gem installed

4,安装redis-stat

[root@localhost ~]# gem install redis-stat
Fetching: ansi256-0.2.5.gem (100%)
Successfully installed ansi256-0.2.5
Fetching: redis-3.0.7.gem (100%)
Successfully installed redis-3.0.7
Fetching: unicode-display_width-1.3.2.gem (100%)
Successfully installed unicode-display_width-1.3.2
Fetching: tabularize-0.2.10.gem (100%)
Successfully installed tabularize-0.2.10
Fetching: insensitive_hash-0.3.3.gem (100%)
Successfully installed insensitive_hash-0.3.3
Fetching: parallelize-0.4.1.gem (100%)
Successfully installed parallelize-0.4.1
Fetching: si-0.1.4.gem (100%)
Successfully installed si-0.1.4
Fetching: tilt-1.4.1.gem (100%)
Successfully installed tilt-1.4.1
Fetching: rack-1.6.10.gem (100%)
Successfully installed rack-1.6.10
Fetching: rack-protection-1.5.5.gem (100%)
Successfully installed rack-protection-1.5.5
Fetching: sinatra-1.3.6.gem (100%)
Successfully installed sinatra-1.3.6
Fetching: json-1.8.6.gem (100%)
Building native extensions.  This could take a while...
Successfully installed json-1.8.6
Fetching: option_initializer-1.5.1.gem (100%)
Successfully installed option_initializer-1.5.1
Fetching: lps-0.2.1.gem (100%)
Successfully installed lps-0.2.1
Fetching: multi_json-1.13.1.gem (100%)
Successfully installed multi_json-1.13.1
Fetching: multipart-post-2.0.0.gem (100%)
Successfully installed multipart-post-2.0.0
Fetching: faraday-0.15.0.gem (100%)
Successfully installed faraday-0.15.0
Fetching: elasticsearch-transport-1.0.18.gem (100%)
Successfully installed elasticsearch-transport-1.0.18
Fetching: elasticsearch-api-1.0.18.gem (100%)
Successfully installed elasticsearch-api-1.0.18
Fetching: elasticsearch-1.0.18.gem (100%)
Successfully installed elasticsearch-1.0.18
Fetching: daemons-1.1.9.gem (100%)
Successfully installed daemons-1.1.9
Fetching: eventmachine-1.2.6.gem (100%)
Building native extensions.  This could take a while...
Successfully installed eventmachine-1.2.6
Fetching: thin-1.5.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed thin-1.5.1
Fetching: redis-stat-0.4.14.gem (100%)
Successfully installed redis-stat-0.4.14
Parsing documentation for ansi256-0.2.5
Installing ri documentation for ansi256-0.2.5
Parsing documentation for redis-3.0.7
Installing ri documentation for redis-3.0.7
Parsing documentation for unicode-display_width-1.3.2
Installing ri documentation for unicode-display_width-1.3.2
Parsing documentation for tabularize-0.2.10
Installing ri documentation for tabularize-0.2.10
Parsing documentation for insensitive_hash-0.3.3
Installing ri documentation for insensitive_hash-0.3.3
Parsing documentation for parallelize-0.4.1
Installing ri documentation for parallelize-0.4.1
Parsing documentation for si-0.1.4
Installing ri documentation for si-0.1.4
Parsing documentation for tilt-1.4.1
Installing ri documentation for tilt-1.4.1
Parsing documentation for rack-1.6.10
Installing ri documentation for rack-1.6.10
Parsing documentation for rack-protection-1.5.5
Installing ri documentation for rack-protection-1.5.5
Parsing documentation for sinatra-1.3.6
Installing ri documentation for sinatra-1.3.6
Parsing documentation for json-1.8.6
Installing ri documentation for json-1.8.6
Parsing documentation for option_initializer-1.5.1
Installing ri documentation for option_initializer-1.5.1
Parsing documentation for lps-0.2.1
Installing ri documentation for lps-0.2.1
Parsing documentation for multi_json-1.13.1
Installing ri documentation for multi_json-1.13.1
invalid options: -SHN
(invalid options are ignored)
Parsing documentation for multipart-post-2.0.0
Installing ri documentation for multipart-post-2.0.0
Parsing documentation for faraday-0.15.0
Installing ri documentation for faraday-0.15.0
Parsing documentation for elasticsearch-transport-1.0.18
Installing ri documentation for elasticsearch-transport-1.0.18
Parsing documentation for elasticsearch-api-1.0.18
Installing ri documentation for elasticsearch-api-1.0.18
Parsing documentation for elasticsearch-1.0.18
Installing ri documentation for elasticsearch-1.0.18
Parsing documentation for daemons-1.1.9
Installing ri documentation for daemons-1.1.9
Parsing documentation for eventmachine-1.2.6
Installing ri documentation for eventmachine-1.2.6
Parsing documentation for thin-1.5.1
Installing ri documentation for thin-1.5.1
Parsing documentation for redis-stat-0.4.14
Installing ri documentation for redis-stat-0.4.14
Done installing documentation for ansi256, redis, unicode-display_width, tabularize, insensitive_hash, parallelize, si, tilt, rack, rack-protection, sinatra, json, option_initializer, lps, multi_json, multipart-post, faraday, elasticsearch-transport, elasticsearch-api, elasticsearch, daemons, eventmachine, thin, redis-stat after 22 seconds
24 gems installed

5.1,使用redis-stat 命令行形式

[root@localhost ~]# redis-stat 127.0.0.1:6379
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/si-0.1.4/lib/si/patch.rb:5: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/si-0.1.4/lib/si/patch.rb:9: warning: constant ::Bignum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/option_initializer-1.5.1/lib/option_initializer.rb:154: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/option_initializer-1.5.1/lib/option_initializer.rb:198: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/redis-3.0.7/lib/redis/client.rb:386: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/si-0.1.4/lib/si/module.rb:4: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/si-0.1.4/lib/si/module.rb:21: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/si-0.1.4/lib/si/module.rb:10: warning: constant ::Fixnum is deprecated
┌────────────────────────┬────────────────┐
│                        │ 127.0.0.1:6379 │
├────────────────────────┼────────────────┤
│          redis_version │          3.2.9 │
│             redis_mode │     standalone │
│             process_id │          24230 │
│      uptime_in_seconds │          71039 │
│         uptime_in_days │              0 │
│                   role │         master │
│       connected_slaves │              0 │
│            aof_enabled │              0 │
│ rdb_bgsave_in_progress │              0 │
│     rdb_last_save_time │     1525847100 │
└────────────────────────┴────────────────┘

┌────────┬──┬──┬──┬───┬─────┬──────┬────┬─────┬─────┬─────┬──────┬─────┬─────┬─────┐
     time us sy cl bcl   mem    rss keys cmd/s exp/s evt/s hit%/s hit/s mis/s aofcs 
├────────┼──┼──┼──┼───┼─────┼──────┼────┼─────┼─────┼─────┼──────┼─────┼─────┼─────┤
 10:08:59  -  -  1   0 803kB 7.33MB    0     -     -     -      -     -     -    0B 
 10:09:01  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:03  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:05  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:07  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:09  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:11  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:13  0  1  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:15  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:17  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:19  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:21  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
 10:09:23  0  0  1   0 803kB 7.33MB    0  0.50     0     0      -     0     0    0B 
└────────┴──┴──┴──┴───┴─────┴──────┴────┴─────┴─────┴─────┴──────┴─────┴─────┴─────┘

5.2,使用redis-stat webserver形式

[root@localhost ~]# redis-stat 127.0.0.1:6379 --server=6666 --daemon #端口自定义
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1070: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/si-0.1.4/lib/si/patch.rb:5: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/si-0.1.4/lib/si/patch.rb:9: warning: constant ::Bignum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/option_initializer-1.5.1/lib/option_initializer.rb:154: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/option_initializer-1.5.1/lib/option_initializer.rb:198: warning: constant ::Fixnum is deprecated
/usr/local/rvm/gems/ruby-2.4.1/gems/redis-3.0.7/lib/redis/client.rb:386: warning: constant ::Fixnum is deprecated

5.3,打开http://服务器ip地址:8000 访问

redis-stat.png
集群也是一样的

redis-stat 192.168.16.186:7000 192.168.16.186:7001 192.168.16.186:7002 192.168.16.186:7003 192.168.16.186:7004 192.168.16.186:7005 --server=8080 5 --daemon

redis-stat-cluster.png



如果这篇文章帮助到了你,我感到十分荣幸!

或许你不想写点什么·但我依旧在这里

icon_mrgreen.pngicon_neutral.pngicon_twisted.pngicon_arrow.pngicon_eek.pngicon_smile.pngicon_confused.pngicon_cool.pngicon_evil.pngicon_biggrin.pngicon_idea.pngicon_redface.pngicon_razz.pngicon_rolleyes.pngicon_wink.pngicon_cry.pngicon_surprised.pngicon_lol.pngicon_mad.pngicon_sad.pngicon_exclaim.pngicon_question.png2018new_aini_org.png2018new_baobao_thumb.png2018new_erha_org.png2018new_kuxiao_thumb.png2018new_yun_thumb.png2018new_hufen_thumb.png2018new_gui_org.png2018new_xiaoerbuyu_org.png2018new_heixian_thumb.png2018new_wabi_thumb.png2018new_tianping_thumb.png
captcha

站点地图 网站地图
豫ICP备17003270号 | Copyright © 2018 💖 靳闯博客
Typecho🍹Sgreen
TOP