perlbalのインストール
perlbalとはperlで書かれたロードバランサ兼リバースプロキシ兼ウェブサーバ
なソフトウェアで、delegateとかよりも設定とか簡単です(個人的には)
以前はapacheのリバースプロキシ機能を使ってバーチャルドメインで切っていたのだけど
どうしても、同じサーバ内で別のウェブサーバにリバースプロキシするのが
上手く機能しなかったので、丁度YAPC2009で紹介されてたこいつを使ってみました。
perl -MCPAN -e shell install IO::AIO install Net::Netmask install Perlbal
でドキュメントを斜め読み
confの下に設定例があるのでこれは見といた方が良い
vi /root/.cpan/build/Perlbal-1.72/doc/config-guide.txt /root/.cpan/build/Perlbal-1.72/conf
設定ファイルを作ってみる
# mkdir /etc/perlbal # vi /etc/perlbal/perlbal.conf LOAD vhosts CREATE POOL hoge_pool POOL hoge_pool ADD 192.168.0.XX:80 CREATE SERVICE hoge_balancer SET role = reverse_proxy SET pool = hoge_pool SET persist_client = on SET persist_backend = on SET verify_backend = on ENABLE hoge_balancer CREATE SERVICE vdemo SET listen = 0.0.0.0:80 SET role = selector SET plugins = vhosts SET persist_client = on VHOST hoge.com = hoge_balancer ENABLE vdemo CREATE SERVICE mgmt SET role = management SET listen = 127.0.0.1:60000 ENABLE mgmt
起動
perlbal -d
自動起動のスクリプトを書く
# vi /etc/perlbal/perlbal.conf #!/bin/sh # # perlbal This shell script takes care of starting and stopping # the perlbal service. # # chkconfig: - 60 20 # description: perlbal is load balancer maked by perl # configured the /etc/perlbal/perlbal.conf # probe: true RETVAL=0 # See how we were called. case "$1" in start) /usr/bin/perlbal -d ;; stop) /usr/bin/pkill perlbal ;; *) echo $"Usage: perlbal {start|stop}" RETVAL=3 ;; esac exit $RETVAL
登録
# chkconfig --add perlbal # chkconfig perlbal on # chkconfig --list