文章分類:操作系統(tǒng)1.需要準(zhǔn)備的硬件和安裝的軟件.
192.168.1.128安裝LVS虛擬服務(wù)器。
192.168.1.126安裝一個(gè)Apache和3個(gè)resin,LVS真實(shí)服務(wù)器
192.168.1.127安裝一個(gè)Apache和3個(gè)resin,LVS真實(shí)服務(wù)器
2.先在126上進(jìn)行安裝
3.安裝Apache.
$tar zxvf httpd-2.2.*.tar.gz
$cd httpd-2.2.*
$./configure --prefix=/usr/local/apache2 -enable-mods-shared=all --enable-so
$make
$make install
4.安裝resin
$tar zxvf resin-3.1.*.tar.gz
$cd resin-3.1.*
$ ./configure --prefix=/usr/local/resina --with-apxs=/usr/local/apache2/bin/apxs
$make
$make install
$tar zxvf resin-3.0.23.tar.gz
$cd resin-3.0.23
$ ./configure --prefix=/usr/local/resinb --with-apxs=/usr/local/apache2/bin/apxs
$make
$make install
$tar zxvf resin-3.1.*.tar.gz
$cd resin-3.1.*
$ ./configure --prefix=/usr/local/resinb --with-apxs=/usr/local/apache2/bin/apxs
$make
$make install
4.修改http.conf配置文件
在最后增加如下內(nèi)容:
LoadModule caucho_module /usr/local/apache2/modules/mod_caucho.so
ResinConfigServer localhost 6801
ResinConfigServer localhost 6802
ResinConfigServer localhost 6803
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
5.配置resina,resinb,resinc的resin.conf文件
三個(gè)配置文件修改成一樣的.
注釋掉默認(rèn)的8080端口
<server-default>
<!-- The http port -->
<!-- <http address="*" port="8080"/>-->
找到<!-- define the servers in the cluster -->一行,改為如下內(nèi)容:
<server id="a" address="127.0.0.1" port="6801"/>
<server id="b" address="127.0.0.1" port="6802"/>
<server id="c" address="127.0.0.1" port="6803"/>
6.啟動(dòng)Apache進(jìn)行驗(yàn)證:
/usr/local/apache2/bin/apachectl start
7.啟動(dòng)三個(gè)resin
$cd /usr/local/resina/bin
$httpd.sh -server a start
啟動(dòng)resinb
$cd /usr/local/resina/bin
$httpd.sh -server b start
啟動(dòng)resinc
$cd /usr/local/resinc/bin
$httpd.sh -server c start
8. 停止Apache和Resin
/usr/local/apache2/bin/apachectl stop
$cd /usr/local/resina/bin
$httpd.sh -server a stop
啟動(dòng)resinb
$cd /usr/local/resina/bin
$httpd.sh -server b stop
啟動(dòng)resinc
$cd /usr/local/resinc/bin
$httpd.sh -server c stop
9. 192.168.1.127也是這樣安裝。
10.安裝LVS
在192.168.1.128運(yùn)行如下腳本命令:
# description: start LVS of Directorserver
VIP=192.168.1.130
RIP1=192.168.1.126
RIP2=192.168.1.127
GW=192.168.1.1
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo " start LVS of DirectorServer"
# set the Virtual IP Address
/sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev eth0:0
#Clear IPVS table
/sbin/ipvsadm -C
#set LVS
/sbin/ipvsadm -A -t $VIP:80 -s rr
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
#Run LVS
/sbin/ipvsadm
#end
;;
stop)
echo "close LVS Directorserver"
/sbin/ipvsadm -C
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
在192.168.1.126和192.168.1.127下運(yùn)行如下腳本命令:
#!/bin/bash
#description : start realserver
VIP=192.168.1.130
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev lo:0
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p
#end
在瀏覽器中輸入http://192.168.1.130就通過(guò)LVS轉(zhuǎn)發(fā)到127和126兩臺(tái)不同的服務(wù)器上。
在通過(guò)Apache分發(fā)到不同的Resin服務(wù)器上.