Redis监控之redis-stat
监控的界面比较简单,也没有邮件报警之类的功能。
命令行界面:
web界面(记得关闭防火墙):
安装的方式有3种
1.java -jar启动jar包
2.安装ruby后使用gem install redis-stat在线联网安装
3.安装ruby后,gem离线安装
其中,第1种最简单,这里先介绍第1种方式。
java -jar启动jar包
下载链接:https://github.com/junegunn/redis-stat/releases
安装java环境:rpm -ivh jdk-8u301-linux-x64.rpm
启动:java -jar redis-stat-0.4.14.jar 192.168.1.214:6380 192.168.1.214:6379 192.168.1.214:6381 --server=8090 --verbose
这样就完成了。
web访问使用192.168.1.179:8090即可。
也可以使用nohup java -jar redis-stat-0.4.14.jar 192.168.1.214:6380 192.168.1.214:6379 192.168.1.214:6381 --server=8090 --verbose &放后台执行,但是要立刻exit推出SecureCRT会话。不然会报如下错误:
[root@node3 redis-stat]# nohup java -jar redis-stat-0.4.14.jar 192.168.1.214:6380 192.168.1.214:6379 192.168.1.214:6381 --server=8090 --verbose & [1] 12387 [root@node3 redis-stat]# nohup: ignoring input and appending output to ‘nohup.out’ [root@node3 redis-stat]# [1]+ Stopped nohup java -jar redis-stat-0.4.14.jar 192.168.1.214:6380 192.168.1.214:6379 192.168.1.214:6381 --server=8090 --verbose [root@node3 redis-stat]# jobs [1]+ Stopped nohup java -jar redis-stat-0.4.14.jar 192.168.1.214:6380 192.168.1.214:6379 192.168.1.214:6381 --server=8090 --verbose
搞不懂。
另外两种方式均需要安装ruby功能。
参考我的另外一篇博客:ruby安装指南
安装ruby后使用gem install redis-stat在线联网安装
使用gem install redis-stat安装即可。
如果是通过yum安装的ruby,在CentOS Linux 7下,有ruby版本过低的问题。
[root@node1 ~]# ruby -v ruby 2.0.0p648 (2015-12-16) [x86_64-linux] [root@node1 ~]# gem install redis-stat ERROR: Error installing redis-stat: faraday-em_http requires Ruby version >= 2.4.0.
估计是redis-stat版本过高,但是安装指定的redis-stat又报错另外的。
[root@node1 ~]# gem install redis-stat --version 0.3.9 Building native extensions. This could take a while... ERROR: Error installing redis-stat: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h Gem files will remain installed in /usr/local/share/gems/gems/eventmachine-1.2.7 for inspection. Results logged to /usr/local/share/gems/gems/eventmachine-1.2.7/ext/gem_make.out
通过编译安装的ruby,版本比较高则不会有问题。
[root@node2 ~]# ruby -v ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux] [root@node2 ~]# gem -v 3.2.22 [root@node2 ~]# gem install redis-stat Fetching eventmachine-1.2.7.gem Fetching daemons-1.1.9.gem Fetching thin-1.5.1.gem Fetching unicode-display_width-2.0.0.gem Fetching tabularize-0.2.10.gem Fetching rack-protection-1.5.5.gem Fetching rack-1.6.13.gem Fetching tilt-1.4.1.gem Fetching sinatra-1.3.6.gem Fetching si-0.1.4.gem Fetching redis-3.0.7.gem Fetching parallelize-0.4.1.gem Fetching option_initializer-1.5.1.gem Fetching lps-0.2.1.gem Fetching json-1.8.6.gem Fetching insensitive_hash-0.3.3.gem Fetching multi_json-1.15.0.gem Fetching ruby2_keywords-0.0.5.gem Fetching multipart-post-2.1.1.gem Fetching faraday-patron-1.0.0.gem Fetching faraday-net_http_persistent-1.2.0.gem Fetching faraday-net_http-1.0.1.gem Fetching faraday-httpclient-1.0.1.gem Fetching faraday-excon-1.1.0.gem Fetching redis-stat-0.4.14.gem Fetching faraday-em_synchrony-1.0.0.gem Fetching faraday-em_http-1.0.0.gem Fetching faraday-1.5.1.gem Fetching elasticsearch-transport-1.0.18.gem Fetching elasticsearch-api-1.0.18.gem Fetching elasticsearch-1.0.18.gem Fetching ansi256-0.2.5.gem Successfully installed rack-1.6.13 Building native extensions. This could take a while... Successfully installed eventmachine-1.2.7 Successfully installed daemons-1.1.9 Building native extensions. This could take a while... Successfully installed thin-1.5.1 Successfully installed unicode-display_width-2.0.0 Successfully installed tabularize-0.2.10 Successfully installed tilt-1.4.1 Successfully installed rack-protection-1.5.5 Successfully installed sinatra-1.3.6 Successfully installed si-0.1.4 Successfully installed redis-3.0.7 Successfully installed parallelize-0.4.1 Successfully installed option_initializer-1.5.1 Successfully installed lps-0.2.1 Building native extensions. This could take a while... Successfully installed json-1.8.6 Successfully installed insensitive_hash-0.3.3 Successfully installed multi_json-1.15.0 Successfully installed ruby2_keywords-0.0.5 Successfully installed multipart-post-2.1.1 Successfully installed faraday-patron-1.0.0 Successfully installed faraday-net_http_persistent-1.2.0 Successfully installed faraday-net_http-1.0.1 Successfully installed faraday-httpclient-1.0.1 Successfully installed faraday-excon-1.1.0 Successfully installed faraday-em_synchrony-1.0.0 Successfully installed faraday-em_http-1.0.0 Successfully installed faraday-1.5.1 Successfully installed elasticsearch-transport-1.0.18 Successfully installed elasticsearch-api-1.0.18 Successfully installed elasticsearch-1.0.18 Successfully installed ansi256-0.2.5 Successfully installed redis-stat-0.4.14 Parsing documentation for rack-1.6.13 Installing ri documentation for rack-1.6.13 Parsing documentation for eventmachine-1.2.7 Installing ri documentation for eventmachine-1.2.7 Parsing documentation for daemons-1.1.9 Installing ri documentation for daemons-1.1.9 Parsing documentation for thin-1.5.1 Installing ri documentation for thin-1.5.1 Parsing documentation for unicode-display_width-2.0.0 Installing ri documentation for unicode-display_width-2.0.0 Parsing documentation for tabularize-0.2.10 Installing ri documentation for tabularize-0.2.10 Parsing documentation for tilt-1.4.1 Installing ri documentation for tilt-1.4.1 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 si-0.1.4 Installing ri documentation for si-0.1.4 Parsing documentation for redis-3.0.7 Installing ri documentation for redis-3.0.7 Parsing documentation for parallelize-0.4.1 Installing ri documentation for parallelize-0.4.1 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 json-1.8.6 Installing ri documentation for json-1.8.6 Parsing documentation for insensitive_hash-0.3.3 Installing ri documentation for insensitive_hash-0.3.3 Parsing documentation for multi_json-1.15.0 Installing ri documentation for multi_json-1.15.0 Parsing documentation for ruby2_keywords-0.0.5 Installing ri documentation for ruby2_keywords-0.0.5 Parsing documentation for multipart-post-2.1.1 Installing ri documentation for multipart-post-2.1.1 Parsing documentation for faraday-patron-1.0.0 Installing ri documentation for faraday-patron-1.0.0 Parsing documentation for faraday-net_http_persistent-1.2.0 Installing ri documentation for faraday-net_http_persistent-1.2.0 Parsing documentation for faraday-net_http-1.0.1 Installing ri documentation for faraday-net_http-1.0.1 Parsing documentation for faraday-httpclient-1.0.1 Installing ri documentation for faraday-httpclient-1.0.1 Parsing documentation for faraday-excon-1.1.0 Installing ri documentation for faraday-excon-1.1.0 Parsing documentation for faraday-em_synchrony-1.0.0 Installing ri documentation for faraday-em_synchrony-1.0.0 Parsing documentation for faraday-em_http-1.0.0 Installing ri documentation for faraday-em_http-1.0.0 Parsing documentation for faraday-1.5.1 Installing ri documentation for faraday-1.5.1 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 ansi256-0.2.5 Installing ri documentation for ansi256-0.2.5 Parsing documentation for redis-stat-0.4.14 Installing ri documentation for redis-stat-0.4.14 Done installing documentation for rack, eventmachine, daemons, thin, unicode-display_width, tabularize, tilt, rack-protection, sinatra, si, redis, parallelize, option_initializer, lps, json, insensitive_hash, multi_json, ruby2_keywords, multipart-post, faraday-patron, faraday-net_http_persistent, faraday-net_http, faraday-httpclient, faraday-excon, faraday-em_synchrony, faraday-em_http, faraday, elasticsearch-transport, elasticsearch-api, elasticsearch, ansi256, redis-stat after 17 seconds 32 gems installed
就是使用redis-stat报错。。。
[root@node2 ~]# redis-stat --help usage: redis-stat [HOST[:PORT] ...] [INTERVAL [COUNT]] -a, --auth=PASSWORD Password -v, --verbose Show more info --style=STYLE Output style: unicode|ascii --no-color Suppress ANSI color codes --csv[=CSV_FILE] Print or save the result in CSV --es=ELASTICSEARCH_URL Send results to ElasticSearch: [http://]HOST[:PORT][/INDEX] --server[=PORT] Launch redis-stat web server (default port: 63790) --daemon Daemonize redis-stat. Must be used with --server option. --version Show version --help Show this message [root@node2 ~]# [root@node2 ~]# [root@node2 ~]# [root@node2 ~]# redis-stat 192.168.1.214:6380 undefined method `display_width' for "┌────────────────────────":String Did you mean? display
目前尚未找到解决方法。
感觉是ruby版本过高导致的,有时间试试2.4.0版本的ruby。
安装ruby后,gem离线安装
待补充。