您的位置:首页 > 数据库 > Redis

安装ruby1.9.3-p0及redmon来监控redis

2012-02-29 15:16 483 查看
首先来个前戏:
redmon 的监控页面没有任何文字说明,仅仅就其README里面的信息来说,应该是通过ruby on rails来实现的。对于这门语言无任何涉猎的情况开始一下安装之旅。

一、安装Ruby

初始安装直接
$ wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz $ tar xzvf ruby-1.9.3-p0.tar.gz
$ cd ruby-1.9.3-p0
$ ./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
$ make
$ make install

结果发现问题:

It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.


从源码安装

$ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz $ tar xzvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure --prefix=/usr/local
$ make
$ make install

然后再清理ruby-1.9.3-p0里面的安装文件,重新来一遍,总算ruby安装成功!

二、安装rails

安装好ruby之后发现万里长征才刚刚开始,我汗。。。Gem之类的,折腾半天。记录下来

当前1.9.3版本之后已经默认集成gem进来,但也可以通过下载来运行:

1. wget http://rubyforge.org/frs/download.php/75711/rubygems-1.8.15.tgz
解压后,进入对应目录

ruby setup.rb

之后再gem -v 发现版本号已经是1.8.15

2. gem update --system 看看是否能够更新。

3. 然后安装bundler

gem install bundler

三、安装redmon

从github上克隆对应的源码下来

git clone https://github.com/steelThread/redmon.gitcd redmonbundler install提示如下错误:Fetching source index for http://rubygems.org/ Could not reach rubygems repository http://rubygems.org/ Could not find multi_json-1.0.4 in any of the sources


gem install multi_json -V (带-V的参数可以显示的看到gem去download的过程,很多时候因为被墙而下不下来)

解决方案 可以通过-p的参数来设定 http的代理访问 -p http://114.255.217.10:80 -r --backtrace 指定远程的repo下载安装

[#16 root@com8-16 redmon]# gem install activesupport -r -V
GET http://rubygems.org/latest_specs.4.8.gz 302 Found
GET http://production.s3.rubygems.org/latest_specs.4.8.gz connection reset after 1 requests, retrying
GET http://production.s3.rubygems.org/latest_specs.4.8.gz connection reset after 1 requests, retrying
GET http://rubygems.org/quick/Marshal.4.8/activesupport-3.1.3.gemspec.rz connection reset after 2 requests, retrying
GET http://rubygems.org/quick/Marshal.4.8/activesupport-3.1.3.gemspec.rz 302 Found
GET http://production.cf.rubygems.org/quick/Marshal.4.8/activesupport-3.1.3.gemspec.rz 200 OK
GET http://rubygems.org/specs.4.8.gz 302 Found
GET http://production.s3.rubygems.org/specs.4.8.gz[/code] 太多302跳转之类的了,国内对外这些技术网站的访问越来越困难,IT民工情何以堪!!

陆续又报出缺少activesupport等等。

不过经过了半天的时间,总算能够bundle install 成功了

[#16 root@com8-16 redmon]# bundle install
Fetching source index for http://rubygems.org/ Using rake (0.9.2.2)
Using multi_json (1.0.4)
Using activesupport (3.1.3)
Installing bson (1.5.2)
Installing bson_ext (1.5.2) with native extensions
Installing chronic (0.6.6)
Installing daemons (1.1.5)
Installing delorean (1.2.0)
Installing diff-lcs (1.1.3)
Installing hiredis (0.3.2) with native extensions
Installing em-hiredis (0.1.0)
Installing eventmachine (0.12.10) with native extensions
Installing haml (3.1.4)
Installing i18n (0.6.0)
Installing rack (1.4.0)
Installing rack-protection (1.2.0)
Installing rack-test (0.6.1)
Installing redis (2.2.2)
Installing tilt (1.3.3)
Installing sinatra (1.3.2)
Installing thin (1.3.1) with native extensions
Using redmon (0.0.1) from source at .
Installing rspec-core (2.6.4)
Installing rspec-expectations (2.6.0)
Installing rspec-mocks (2.6.0)
Installing rspec (2.6.0)
Installing shoulda (2.11.3)
Using bundler (1.0.21)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed

激动人心的时刻终于来了!

ruby sample/app.rb

通过浏览器来访问:
http://localhost:4567
默认是指向本地的6379端口的redis,如果需要查看其他redis的监控情况,请修改 lib/redmon.rb 里面的代码:

DEFAULT_OPTS = {
:redis_url     => 'redis://127.0.0.1:6379',
:namespace     => 'redmon',
:web_interface => ['0.0.0.0', 4567],
:worker        => true,
:poll_interval => 10


贴两张图吧,有图有真相:





总体感觉,功能上还不太完善,keys 和 slow log 都“敬请期待” 来着。

还是期待作者能尽快加入更多的功能进这个dashboard监控。

BY THE WAY:

本地 cygwin 来进行安装配置ruby on rails 的方案 请看:

http://phoneqq.com/2011/12/09/windows7cygwingitrvmruby1-9-3rails3mongodbnginxunicornrspecguardspork%EF%BC%881-cygwin%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE%EF%BC%89/

http://phoneqq.com/2011/12/10/windows7_cygwin_git_rvm_ruby1-9-3_rails3_mongodb_nginx_unicorn_rspec_guard_spork%EF%BC%882-ruby-on-rails3%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE%EF%BC%89/

这两篇文章,采用rvm来进行ruby的安装配置:

我本地也做了相应的测试,应该都没有问题:

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)[/code] 来获取RVM 来进行安装。
rvm install 1.9.3
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: