nginx+tomcat集群高可用

需求是这样的:比如一个 tomcat 节点 down 掉,其他节点能够替换它。
使用nginx的第三方插件
nginx_upstream_check_module

我的测试环境是:nginx/1.7.2 + tomcat7

1.首先下载nginx_upstream_check_module项目后解压

2.编译安装nginx
在安装前到nginx目录中执行:
patch -p1 < /root/tools/data/healthcheck_nginx_upstreams-master/nginx.patch

注意nginx.patch要对应好自己nginx版本,github那个项目中有说明。一开始就是安装了发现不能使用health check功能发现是用的patch版本造成的。
然后
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-openssl=/usr/local/src/openssl-1.0.1g --add-module=/root/tools/data/nginx_upstream_check_module-master/

make

make install

3.配置nginx.conf

upstream test_server{
        server 127.0.0.1:8081;
        server 127.0.0.1:8082;
        check interval=5000 rise=1 fall=3 timeout=4000 type=http;
 }
server {
           listen 81;
           server_name  test.com;
           location / {
                proxy_pass http://test_server;
                proxy_connect_timeout 3;
           }
           location /status {
                check_status;
                access_log   off;
           }
    }


4.测试
好了,启动两个tomcat后,一个tomcat服务有问题nginx会检测到并舍弃这个节点。
输入 http://test.com:81/status后查看nginx检测tomcat的运行情况


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值