mongrel
昨日作ったRubyの環境にmongrelをインストールしようとしたらこんなエラーが出た。
Building native extensions. This could take a while...
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.1 for inspection.mkmfってなにさ?って調べてみたらこんなのを見つけました。http://comox.textdrive.com/pipermail/talk/2006-April/000904.html
ええ、僕は大ボケですとも。インストールを忘れてましたよ。
# dpkg -i ruby1.8-dev_1.8.4-5_i386.deb
で、改めてgemでinstallしたら上手くいきました。
mongrel_cluster
というわけで、拍子抜けするほど簡単に導入できてしまいました。確かに使い勝手はよさそう。
id:drawnboyさんの言うとおり、拍子抜けするほど簡単でした。次はpoundで負荷分散。
poundはmakeで
Requirements
We assume that the following:
* Pound and the mongrel cluster are running on the same machine1.
* Pound 2.0.4 is built and installed, including SSL support if desired.
* The mongrel gem is installed.
* The mongrel_cluster gem is installed.
って書いてあるけど、現時点でのpoundのstableな最新版は2.1*1、debianのstableでは1.8.2-1で、unstableでは2.0-1*2だからmakeしてインストールするわけだけど、http://www.apsis.ch/pound/のINSTALLATIONに書いてある、他のパッケージはどれを入れたらいいの?
Pound was tested on Linux, Solaris and OpenBSD, but it should work unchanged on just about any modern Unix-like system. You will require OpenSSL and libpthread. The PCRE package and the Hoard library are strongly recommended.
色々試すしかないね。
poundをインストール
# apt-get install openssl $ wget http://www.apsis.ch/pound/Pound-2.1.tgz $ tar zxvf Pound-2.1.tgz $ cd Pound-2.1 $ ./configure --with-ssl=/etc/ssl/ $ make $ sudo make install [ -d /usr/local/sbin ] || mkdir /usr/local/sbin /usr/bin/install -c -o bin -g bin -m 555 -s pound /usr/local/sbin/pound [ -d /usr/local/man ] || mkdir /usr/local/man [ -d /usr/local/man/man8 ] || mkdir /usr/local/man/man8 /usr/bin/install -c -o bin -g bin -m 644 pound.8 /usr/local/man/man8/pound.8 $ sudo pound -V Password: Version 2.1 Exiting...
インストールできたらしい。
manに載っていたcfgファイルをてきとうなファイル名で作って
User "rails_user"
Group "rails_user"
ListenHTTP
Address 192.168.23.131
Port 4000
Service
BackEnd
Address 127.0.0.1
Port 8000
End
BackEnd
Address 127.0.0.1
Port 8001
End
BackEnd
Address 127.0.0.1
Port 8002
End
End
Endpoundを実行する前に念のため、mongrel_rails cluster::startでサーバ群を動かしておく。
# pound -f pound-sample.cfg
でpound実行。何にも出力されないのでpsで確認。
takeshi@debian:~$ ps ax | grep pound 2103 ? Ss 0:00 pound -f pound-sample.cfg 2104 ? S 0:00 pound -f pound-sample.cfg
ブラウザで確認・・・・動いてるっすー。わーい。
次はsslを試します。
poundでSSL
http://mongrel.rubyforge.org/docs/pound.html に書いてある通りにやってみたら簡単に動いちゃった。
ちゃんとコントローラやビューで request.ssl? が変わっていることも確認できました。poundってすごく便利かも。