热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Tengine(淘宝nginx)+tomcat安装整合后篇+高可用和负载均衡

1.Nginx配置appnginxsbinnginx-VTengineversion:Tengine1.4.6(nginx1.2.9)builtbygcc4.4.7201203

1.Nginx配置

/app/nginx/sbin/nginx-V
Tengineversion:Tengine/1.4.6(nginx/1.2.9)
builtbygcc4.4.720120313(RedHat4.4.7-3)(GCC)
TLSSNIsupportenabled
configurearguments:--user=nginx--group=app--prefix=/app/nginx--with-http_stub_status_module--with-http_ssl_module--with-http_concat_module--with-http_upstream_check_module--with-http_sub_module--with-http_realip_module

vim/app/nginx/conf/nginx.conf

upstreamapp_tomcat{
consistent_hash$remote_addr;
session_sticky;

server172.16.80.1:8000id=1001weight=1;
server172.16.80.2:8000id=1002weight=1;

checkinterval=1000rise=2fall=3timeout=1000type=httpport=8000;
check_http_send"GET/HTTP/1.0\r\n\r\n";
check_http_expect_alivehttp_2xxhttp_3xx;
}

vim/app/nginx/conf.d/app.test.com

server{
listen80;
server_nameapp.test.com;

#影藏.svn代码文件

location~^(.*)\/\.svn\/{
denyall;
}

location/{
concaton;
root/app/web/app.test.com/ROOT;
indexindex.htmlindex.htmindex.jsp;
}


location/status{
stub_statuson;
access_logoff;
allow172.16.80.0/24;
}

location~(\.jsp)|(\.do)|(/url/)|(/membercard/)|(\.action)${
session_sticky_hide_COOKIEupstream=app_tomcat;
proxy_passhttp://app_tomcat;
proxy_set_headerHostapp.test.com;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
}

error_page500502503504/50x.html;
location=/50x.html{
roothtml;
}
}

2.Tomcat配置

2.1第一台Tomcat

vim/app/tomcat/conf/server.xml


expireSessiOnsOnShutdown="false"notifyListenersOnReplication="true"/>

address="224.0.0.4"
port="45365"
frequency="500"
dropTime="3000"/>
address="172.16.80.1"
port="4002"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>









tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>



主域名和二级域名之间的session复制

第二台Tomcat

vim/app/tomcat/conf/server.xml


expireSessiOnsOnShutdown="false"notifyListenersOnReplication="true"/>

address="224.0.0.4"
port="45365"
frequency="500"
dropTime="3000"/>
address="172.16.80.2"
port="4002"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>









tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>



本文出自 “linux” 博客,请务必保留此出处http://zhangxinbeijing.blog.51cto.com/6969871/1314572


推荐阅读
author-avatar
qaz9
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有