Linux之实现nginx+tomcat负载均衡

4 篇文章 0 订阅
2 篇文章 0 订阅

nginx+tomcat结构设计
这里写图片描述
1 安装及配置nginx
a.下载nginx:http://nginx.org/download/nginx-1.12.0.tar.gz
b.安装:

>tar -xzf nginx-1.11.12.tar.gz
>cd nginx-1.11.12 
>useradd -s /sbin/nologin -M nginx
>./configure --prefix=/usr/local/nginx --useer=nginx --group=nginx --conf-path=/etc/nginx.d --sbin-path=/usr/local/bin --with-http_ssl_module  --with-http_stub_status_module 
>make && make install

c.配置nginx.conf

vim /etc/nginx.d/nginx.conf
    location ~ \.jsp${
                proxy_pass http://192.168.100.32;
    }

2 安装及配置tomcat
a.安装详细请查看这里写链接内容

3 配置环境
a.配置nginx主机IP

>ifconfig eth0 172.16.113.157 up
>ifconfig eth1 192.168.100.32 up
b.配置tomcat主机IP
 >ifconfig eth0 192.168.100.34
c.关闭iptables
>service iptables stop

4 测试
curl http://172.168.113.157
这里写图片描述

nginx+tomcat+tomcat体系机构设计
这里写图片描述

1.配置nginx.conf

http{
    upstream tomcat{
    server 192.168.100.23:8080;
    server 192.168.100.14:8080;
    }
    server{
    location / {
        proxy_pass http://tomcat;
        }
    }
}

2.配置tomcatA环境及测试页面

>ifconfig eth0 192.168.100.23 up
>service iptables stop
>vim /usr/local/tomcat/webapps/text/index.jsp
    <html>
    <head>
            <title>tomcatA</title>
    </head>
    <body>
            <h1>tomcatA is runing!!!</h1>
    </body>
    </html>

3.配置tomcatB环境及测试页面

>ifconfig eth0 192.168.100.14 up
>service iptables stop
>vim /usr/local/tomcat/webapps/text/index.jsp
    <html>
    <head>
            <title>tomcatB</title>
    </head>
    <body>
            <h1>tomcatB is runing!!!</h1>
    </body>
    </html>

4.测试
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值