分类: 服务器与存储
2008-06-07 19:30:36
双机备份方案(resin集群+冷备)
版权所有,请勿转载(作者:darkblue)
有两台服务器
主机名:web-srv
内网IP:10.199.55.1
外网IP:121.183.173.225
域名:web.xxxx.com
主机名:wap-srv
内网IP:10.199.55.3
外网IP:121.183.173.226
域名:wap.xxxx.com
防火墙:PIX525,服务器OS:RedHat ES4U2
需求:
web-srv和wap-srv均使用apache2+resin3.1.2提供http服务,监听端口都是80。
1、当两台主机都正常运作的时候,通过resin来实现负载均衡,web-srv的80端口提供web服务,wap-srv的80端口提供wap服务;
2、当web-srv宕机后,手工启用wap-srv上面的另一个apache进程,监听8080端口,提供web服务,这个时候两个公网IP同时指向一个私网IP10.199.55.3,结果是:80端口提供的是wap服务,8080端口提供的是web服务;
3、当wap-srv宕机后,手工启用web-srv上面的另一个apache进程,监听8080端口,提供wap服务,这个时候两个公网IP同时指向一个私网IP10.199.55.1,结果是:80端口提供的是web服务,8080端口提供的是wap服务;
配置:
一、DNS
增加两条纪录,分别是121.183.173.225 <---> web.xxxx.com,121.183.173.226 <---> wap.xxxx.com。
二、web-srv
2.1 安装apache2、resin-3.1.0
安装apache2略
安装resin-3.1.0
Wget “”
Cp resin-3.1.0.tar.gz /usr/local/
Tar –xzvf resin-3.1.0.tar.gz
cd resin-3.1.0
./ configure --with-apache=/usr/local/apache2
Make
Make install
2.2 准备配置文件和目录
copy /usr/local/apache2/conf/httpd.conf httpdweb.conf
copy /usr/local/apache2/conf/httpd.conf httpdwap.conf
mkdir /usr/local/apache2/htdocs/web
mkdir /usr/local/apache2/htdocs/wap
cp -r /usr/local/resin-3.1.0 /usr/local/resin-web
cp -r /usr/local/resin-3.1.0 /usr/local/resin-wap
2.3 修改httpdweb.conf的监听端口(80)和web的路径
file: /usr/local/apache2/conf/httpdweb.conf
ResinConfigServer 10.199.55.3 6802
ResinConfigServer 10.199.55.1 6802
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
2.4 修改httpdwap.conf的监听端口(8080)和wap的路径
file: /usr/local/apache2/conf/httpdweb.conf
ResinConfigServer 10.199.55.3 6803
ResinConfigServer 10.199.55.1 6803
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
2.5 修改resin3.1.2的集群和相关的java配置
file: /usr/local/resin-web/conf/resin.conf
………………
file: /usr/local/resin-wap/conf/resin.conf
………………
2.6 启动apache和resin
apache2
/usr/local/apache2/bin/httpd -f ./conf/httpdweb.conf
/usr/local/apache2/bin/httpd -f ./conf/httpdwap.conf
resin
/usr/local/resin-web/bin/httpd.sh -server 10.199.55.1 start
/usr/local/resin-wap/bin/httpd.sh -server 10.199.55.1 start
三、wap-srv
3.1 安装apache2、resin-3.1.0
安装apache2略
安装resin-3.1.0
Wget “”
Cp resin-3.1.0.tar.gz /usr/local/
Tar –xzvf resin-3.1.0.tar.gz
cd resin-3.1.0
./ configure --with-apache=/usr/local/apache2
Make
Make install
3.2 准备配置文件和目录
copy /usr/local/apache2/conf/httpd.conf httpdweb.conf
copy /usr/local/apache2/conf/httpd.conf httpdwap.conf
mkdir /usr/local/apache2/htdocs/web
mkdir /usr/local/apache2/htdocs/wap
cp -r /usr/local/resin-3.1.0 /usr/local/resin-web
cp -r /usr/local/resin-3.1.0 /usr/local/resin-wap
3.3 修改httpdweb.conf的监听端口(8080)和web的路径
file: /usr/local/apache2/conf/httpdweb.conf
端口和目录略
ResinConfigServer 10.199.55.3 6802
ResinConfigServer 10.199.55.1 6802
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
3.4 修改httpdwap.conf的监听端口(80)和wap的路径
file: /usr/local/apache2/conf/httpdweb.conf
端口和目录略
ResinConfigServer 10.199.55.3 6803
ResinConfigServer 10.199.55.1 6803
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
3.5 修改resin3.1.2的集群和相关的java配置
file: /usr/local/resin-web/conf/resin.conf
………………
file: /usr/local/resin-wap/conf/resin.conf
………………
3.6 启动apache和resin
apache2
/usr/local/apache2/bin/httpd -f ./conf/httpdweb.conf
/usr/local/apache2/bin/httpd -f ./conf/httpdwap.conf
resin
/usr/local/resin-web/bin/httpd.sh -server 10.199.55.3 start
/usr/local/resin-wap/bin/httpd.sh -server 10.199.55.3 start
四、防火墙的配置
因为web-srv和wap-srv只提供www服务,所以只需要对这两个内外网的IP地址对做端口映射。
static (dmz,outside) tcp 121.183.173.225 www 10.199.55.1 www netmask 255.255.255.255
static (dmz,outside) tcp 121.183.173.226 www 10.199.55.3 www netmask 255.255.255.255
五、冷备的实现
5.1 当web-srv宕机后:
5.1.1 修改防火墙配置
no static (dmz,outside) tcp 121.183.173.225 www 10.199.55.1 www netmask 255.255.255.255
static (dmz,outside) tcp 121.183.173.225 www 10.199.55.3 8080 netmask 255.255.255.255
5.1.2 启动wap-srv的第二个apache进程,监听8080端口,提供web服务
/usr/local/apache2/bin/httpd -f ./conf/httpdweb.conf
用户访问将指向10.199.55.3:8080
5.2 当wap-srv宕机后:
5.2.1 修改防火墙配置
no static (dmz,outside) tcp 121.183.173.226 www 10.199.55.3 www netmask 255.255.255.255
static (dmz,outside) tcp 121.183.173.226 www 10.199.55.1 8080 netmask 255.255.255.255
5.2.2 启动web-srv的第二个apache进程,监听8080端口,提供wap服务
/usr/local/apache2/bin/httpd -f ./conf/httpdwap.conf
用户访问将指向10.199.55.1:8080