通过redmon监控管理Redis服务器的安装配置教程
1. 通过RVM(Ruby Version Manager)来安装配置Ruby On Rails
准备工作:
sudo apt-get updatesudo apt-get upgradesudo apt-get dist-upgradesudo reboot
安装RVM:
?
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
?
安装完成后会提示:
andy@ubuntu:~$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Downloading RVM from wayneeseguin branch stable
? % Total??? % Received % Xferd? Average Speed?? Time??? Time???? Time? Current
???????????????????????????????? Dload? Upload?? Total?? Spent??? Left? Speed
100? 919k? 100? 919k??? 0???? 0? 91469????? 0? 0:00:10? 0:00:10 --:--:--? 192k
Installing RVM to /home/andy/.rvm/
??? Adding rvm PATH line to /home/andy/.bashrc /home/andy/.zshrc.
??? Adding rvm loading line to /home/andy/.bash_login /home/andy/.zlogin.
# RVM:? Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.beginrescueend.com/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Screencast: http://screencasts.org/episodes/how-to-use-rvm
# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'
Installation of RVM in /home/andy/.rvm/ is almost complete:
? * To start using RVM you need to run `source /home/andy/.rvm/scripts/rvm`
??? in all your open shell windows, in rare cases you need to reopen all shell windows.
? * Optionally you can run `rvm tools rvm-env ruby bash` which will generate
??? shebang wrappers for easier selecting ruby in scripts.
# andy,
#
#?? Thank you for using RVM!
#?? I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne
?
andy@ubuntu:~$ source /home/andy/.rvm/scripts/rvm
andy@ubuntu:~$ rvm tools rvm-env ruby bash
# use shebang: #!/usr/bin/ruby-rvm-env 1.9.3
There is no command/script 'ruby' in system.
Created link '/usr/bin/bash-rvm-env'.
?
通过下面的命令可以查看RVM是否正常工作:
andy@ubuntu:~$ source .bashrc
andy@ubuntu:~$ type rvm | head -1
rvm is a function
如果正常的话可以看到类似“rvm是函数”这样的内容,下面我们安装ruby以及rail
?
?
andy@ubuntu:~/baidu/lxb/apps/redmon$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
andy@ubuntu:~/baidu/lxb/apps/redmon$ gem install bundler
The program 'gem' can be found in the following packages:
?* rubygems1.8
?* rubygems1.9.1
Try: sudo apt-get install <selected package>
?
andy@ubuntu:~/baidu/lxb/apps/redmon$ sudo apt-get install rubygems1.9.1
[sudo] password for andy:
Reading package lists... Done
Building dependency tree??????
Reading state information... Done
Note, selecting 'ruby1.9.1' instead of 'rubygems1.9.1'
The following packages were automatically installed and are no longer required:
? linux-headers-2.6.35-22-generic linux-headers-2.6.35-22
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
? libreadline5 libruby1.9.1 libyaml-0-2 ruby1.9.1
Suggested packages:
? ruby1.9.1-examples ri1.9.1 graphviz
The following NEW packages will be installed:
? libreadline5 libruby1.9.1 libyaml-0-2 ruby1.9.1
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,046kB of archives.
After this operation, 13.9MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com/ubuntu/ maverick/main libreadline5 amd64 5.2-7build1 [147kB]
Get:2 http://archive.ubuntu.com/ubuntu/ maverick/main libyaml-0-2 amd64 0.1.3-1 [55.0kB]
Get:3 http://archive.ubuntu.com/ubuntu/ maverick/universe libruby1.9.1 amd64 1.9.2.0-1 [3,808kB]
Get:4 http://archive.ubuntu.com/ubuntu/ maverick/universe ruby1.9.1 amd64 1.9.2.0-1 [36.5kB]
Fetched 4,046kB in 37s (107kB/s)??????????????????????????????????????????????
Selecting previously deselected package libreadline5.
(Reading database ... 160453 files and directories currently installed.)
Unpacking libreadline5 (from .../libreadline5_5.2-7build1_amd64.deb) ...
Selecting previously deselected package libyaml-0-2.
Unpacking libyaml-0-2 (from .../libyaml-0-2_0.1.3-1_amd64.deb) ...
Selecting previously deselected package libruby1.9.1.
Unpacking libruby1.9.1 (from .../libruby1.9.1_1.9.2.0-1_amd64.deb) ...
Selecting previously deselected package ruby1.9.1.
Unpacking ruby1.9.1 (from .../ruby1.9.1_1.9.2.0-1_amd64.deb) ...
Processing triggers for man-db ...
Setting up libreadline5 (5.2-7build1) ...
Setting up libyaml-0-2 (0.1.3-1) ...
Setting up libruby1.9.1 (1.9.2.0-1) ...
Setting up ruby1.9.1 (1.9.2.0-1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
; 查看安装建议rvm notes; 安装一些必要的软件包sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev; 列出可以安装的ruby版本rvm list known; 安装ruby,我选择的是版本1.9.3-p0rvm install 1.9.3-p0; 设定默认使用的ruby版本rvm --default use 1.9.3-p0; 查看版本看是否正确安装ruby -vgem -v; 有必要可以手动更新一下gem update --systemgem update; 安装railsgem install rails; 查看版本看是否正确安装rails -v
这样环境就安装好了,下面提一下安装过程中可能遇到的错误信息:
在安装ruby的时候会安装yaml,可能会在make的时候出现如下的错误信息:
Compiling yaml in /home/debugcool/.rvm/src/yaml-0.1.4.ERROR: Error running 'make ', please read /home/debugcool/.rvm/log/ruby-1.9.3-p0/yaml/make.log
这是应为缺少yaml库的缘故,可以通过:
sudo apt-get install libyaml-0-2 libyaml-dev
执行这个命令来安装yaml库解决这个问题,如果还是报错,请看b错误信息
查看?/home/debugcool/.rvm/log/ruby-1.9.3-p0/yaml/make.log 日志信息:
src/Makefile.am:2: Libtool library used but `LIBTOOL' is undefinedsrc/Makefile.am:2: The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
缺少libtool库,可以通过:
sudo apt-get install libtool
执行这个命令来安装libtool库解决这个问题
2. 安装redmon监控redis
下载redmon源码:
git clone https://github.com/steelThread/redmon.git
安装运行:
bundle installruby sample/app.rb
注:如果前面不是通过RVM进行ruby、rails安装配置,而是通过源码编译、apt-get等方式安装,可能会遇到各种找不到相关gem等诡异的错误,我也是在各种百度、google无果之后才通过RVM来安装的。
运行之后可以打开在浏览器中打开http://localhost:4567来查看redis web监控页面。
redmon默认是监控本机的6379端口的redis服务器,这个是可以修改的,在redmon目录的lib目录下,可以查看redmon.rb的源码:
module Redmon extend self attr_reader :opts @opts = { :redis_url => 'redis://127.0.0.1:6379', :namespace => 'redmon', :web_interface => ['0.0.0.0', 4567], :worker => true, :poll_interval => 10 }
修改上面代码中redis_url内容即可监控自己执行的redis服务器。