部署Tomcat负载均衡
Centso1:
一.安装tomca
1.解压apache
[root@centos ~]# tar zxvf /mnt/apache-tomcat-7.0.54.tar.gz -C /usr/local/
2.指定tomcat安装位置
[root@centos ~]# mv /usr/local/apache-tomcat-7.0.54/ /usr/local/tomcat
3.启动服务
4.停止服务:
[root@centos ~]# /usr/local/tomcat/bin/shutdown.sh
5.监听端口
二.配置tomcat虚拟主机
1.创建虚拟主机根目录
2.修改主配置文件配置虚拟主机
[root@centos04 ~]# vim /usr/local/tomcat/conf/server.xml
3.修改hosts文件
[root@centos ~]# vim /etc/hosts
Centso2:
一:安装tomcat
1.安装位置:
2.启动服务
3.启动端口
三.配置tomcat虚拟主机
4.1.创建虚拟主机根目录
5.修改主配置文件配置虚拟主机
[root@centos ~]# vim /usr/local/tomcat/conf/server.xml
6.修改hosts文件
[root@centos ~]# vim /etc/hosts
验证:
四.安装配置nginx
Centso3:
1.安装依赖程序:
2.创建管理nginx用户
3.配置nginx (liunx光盘)
./configure --prefix=/usr/local/nignx --user=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module
4.编译安装nginx
5.优化nginx 命令
[root@centos07 ~]# ln -s /usr/local/nignx/sbin/* /usr/local/sbin/
五、配置nginx反向代理
1.修改nginx主配置文件
[root@centos06 ~]# vim /usr/local/nignx/conf/nginx.conf
upstream tomcat_server {
server 192.168.100.10:8080 weight=1;
server 192.168.100.20:8080 weight=1;
}
server {
listen 80;
server_name www.dbqn.com;
charset uftp-8;
access_log logs/host.access.log;
location / {
root html;
index index.html index.htm;
proxy_pass http://tomcat_server;
}
检车配置文件
2.修改hosts文件
[root@centos07 ~]# vim /etc/hosts
2.启动nginx
[root@centos07 ~]# nginx
验证: