一、实验规划
1、模拟图:
2、IP规划:
客户端IP:192.168.18.12
转发器1:192.168.18.1
转发器2:192.168.18.2
apach+php1的IP :192.168.18.3
apach+php2 的IP:192.168.18.9
nginx+jsp1 的IP:192.168.18.4
nginx+jsp2 的IP: 192.168.18.10
转发器3的IP:192.168.18.5
mysql+a 的IP: 192.168.18.6
mysql+B1的IP: 192.168.18.7
mysql+B2的IP:192.168.18.8
二、配置apach+php两个服务器
1、配置好yum 环境
2、yum install httpd php –y
3、对于apach+ php1
vim /var/www/html/index.php
<? echo time() ?>
对于apach+php2
vim /var/www/html/index.php
<? phpinfo() ?>
4、启动服务
Service httpd start
三、配置nginx+tomact
1、安装nginx
rpm -ivh nginx-0.6.36-1.el5.i386.rpm
2、安装Java环境
chmod +x jdk-1_5_0-linux-i586-rpm.bin
./jdk-1_5_0-linux-i586-rpm.bin
cp bash_profile /root/.bash_profile
source /root/.bash_profile
3、测试安装是否成功
java -version
java version "1.5.0"
4、install tomcat
tar fvxz apache-tomcat-6.0.20.tar.gz
mv apache-tomcat-6.0.20 /usr/local/tomcat
测试启动和关闭
[root@server1 tomcat]# /usr/local/tomcat/bin/startup.sh
Using CaTaLIna_BaSE: /usr/local/tomcat
Using CaTaLIna_HOmE: /usr/local/tomcat
Using CaTaLIna_TmPDIR: /usr/local/tomcat/temp
Using JRE_HOmE: /usr/java/jdk1.5.0
[root@server1 tomcat]# /usr/local/tomcat/bin/shutdown.sh
Using CaTaLIna_BaSE: /usr/local/tomcat
Using CaTaLIna_HOmE: /usr/local/tomcat
Using CaTaLIna_TmPDIR: /usr/local/tomcat/temp
Using JRE_HOmE: /usr/java/jdk1.5.0
编写测试页面
cd /usr/local/tomcat/webapps/ROOT/
对于nginx+jsp1
Vim test.jsp
<%= new java.util.Date() %>
对于nginx+jsp2
Vim test.jsp
mv index.jsp test.jsp
5、启动服务
Service nginx start
/usr/local/tomcat/bin/startup.sh
四、配置转发器1、2
1、安装nginx
rpm -ivh nginx-0.6.36-1.el5.i386.rpm
2、安装keepalived install
ld1#tar fvxz keepalived-1.1.17.tar.gz
ld1#cd keepalived-1.1.17
ld1#./configure --prefix=/usr/local/keepalived
ld1#make
ld1#make install
安装后,把人家提供好的文件进行对应的复制!
ld1#cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
ld1#cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ld1#mkdir -pv /etc/keepalived
mkdir: 已创建目录 “/etc/keepalived”
#cp/root/keepalived.lay7.conf /usr/local/keepalived/etc/keepalived/keepalived.conf
#cp/root/keepalived.lay7.conf /etc/keepalived/keepalived.conf
ld1#ln -s /usr/local/keepalived/sbin/keepalived /sbin/
同样的安装步骤在ld2上执行一次!
几个特色地方按照老师要求整改
/etc/init.d/keepalived start
3、编译nginx.conf
Vim /etc/nginx/nginx.conf
剩余apache到mysql这一块做的过程除了个小问题,随后在添加