Nginx+Tomcat集群与负载均衡
Nginx+Tomcat集群与负载均衡
架构描述
前端一台nginx服务器做负载均衡器,后端放N台tomcat组成集群处理服务,通过nginx转发到后面(注:没做动静分离,静态动态全部都转给tomcat)
优点:实现了可弹性化的架构,在压力增大的时候可以临时添加tomcat服务器添加到这个架构里面去.
先修改nginx.conf配置
如想了解Nginx负载均衡策略,请查阅Nginx负载均衡策略.
user nginx; worker_processes 10; worker_rlimit_nofile 100000;error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice;#error_log /var/log/nginx/error.log info;pid /var/run/nginx.pid;events {worker_connections 1024;use epoll; }http {include /etc/nginx/mime.types;default_type application/octet-stream;log_format main '$remote_addr - $remote_user [$time_local]"$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent""$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on;tcp_nopush on;tcp_nodelay on;server_tokens off;gzip on;gzip_static on;gzip_comp_level 5;gzip_min_length 1024;keepalive_timeout 65;limit_conn_zone $binary_remote_addr zone=addr:10m;# Load config files from the /etc/nginx/conf.d directoryinclude /etc/nginx/conf.d/*.conf;upstream www.wp.com {#此处为轮询策略 换成你自己的tomcat地址#可以根据自己的需求配置多个tomcat,当某个地址无效时,nginx会自动切换server 192.168.5.206:8081;server 192.168.5.206:8082;}server {#配置对应的端口与域名listen 80;server_name www.wp.com;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;#配置上面的server nameproxy_pass http://www.wp.com;proxy_set_header X-Real-IP $remote_addr;}location ~ ^/(WEB-INF)/ {deny all;}error_page 404 /404.html;location = /404.html {root /usr/share/nginx/html;}# redirect server error pages to the static page /50x.htmlerror_page 500502503504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}}}
修改tomcat配置
找到TOMCAT_HOME/conf/server.xml,在host标签处加入Context标签
注意:如果是单机启动多tomcat需要改变对应的port,否则会启动不了,多机tomcat无此情况
<ContextdocBase="/opt/tomcat/cluster01/webapps/ROOT"path=""/>
到此重启tomcat与nginx服务即可.
转载于:https://blog.51cto.com/wxl604746107/1305440
Nginx+Tomcat集群与负载均衡相关推荐
- 实践中整理出tomcat集群和负载均衡
实践中整理出tomcat集群和负载均衡 来源:http://macrochen.blogdriver.com/macrochen/1207263.html (一)环境说明 (1)服务器有4台,一台安装 ...
- Nginx实现tomcat集群进行负载均衡
一.背景 随着业务量和用户数量的激增,单一的tomcat部署应用已经无法满足性能需求,而且对于每次发布项目期间服务不可用的问题也凸显,既然出现了这个问题,那么我们本文就借助nginx来完美的解决这个问 ...
- tomcat7+nginx+memcached 配置tomcat 集群以及负载均衡
首先:配置tomcat集群 nginx+ tomcat7 1 安装jdk (可以选择6或者7都可以) 此处不用多说. 2 下载nginx-1.2.5 (下载附件) 3 下载 memcached(下载附 ...
- linux搭建LVS+keepalive+nginx实现集群高性能负载均衡配置详解
关于nginx配置tomcat实现负载均衡可参考http://blog.csdn.net/liqi_q/article/details/78063603 安装jdk可参考:http://blog.cs ...
- nginx的集群与负载均衡
一.集群 就是同一个业务部署在不同的服务器上. 1.启动多个Web服务器 http://127.0.0.1:9001 http://127.0.0.1:9002 http://127.0.0.1:90 ...
- 结合Apache和Tomcat实现集群和负载均衡
http://fableking.iteye.com/blog/360870 TomcatApacheJSP应用服务器Web 本文基本参考自 轻松实现Apache,Tomcat集群和负载均衡,经由实 ...
- Tomcat服务器集群与负载均衡实现
一.前言 在单一的服务器上执行WEB应用程序有一些重大的问题,当网站成功建成并开始接受大量请求时,单一服务器终究无法满足需要处理的负荷量,所以就有点显得有点力不从心了.另外一个常见的问题是会产生单点故 ...
- 搭建服务器集群——Windows7系统中nginx与IIS服务器搭建集群实现负载均衡
转载:https://www.cnblogs.com/xiongze520/p/10308720.html 分布式,集群,云计算机.大数据.负载均衡.高并发······当耳边响起这些词时,做为一个菜鸟 ...
- FastDFS蛋疼的集群和负载均衡(十五)之lvs四层+Nginx七层负载均衡
###Interesting things lvs+nginx的拓扑图 准备环境,基于上一篇[Diary Report 2018-1-3]关于FastDFS蛋疼的集群和负载均衡(十三)之LVS-DR环 ...
最新文章
- Unreal Engine 4 RenderTarget制作Live Camera效果
- Spring基础专题——第十一章(高级注解编程完结)
- linux vim怎么回退,[Linux] Vim 撤销 回退 操作
- 《Linux防火墙(第4版)》——1.3 传输层机制
- 3.2.5 四则运算的例子
- sq工程师是做什么的_算法工程师为什么成天做数据,都做哪些数据?
- @Cacheable 指定缓存位置
- 关于SQL Server对于表的一些查询
- java用for打印正方形_java.java
- ARP防火墙 (防如网络执法官、网络剪刀手、局域网终结者限制本机网速)
- typra + picgo + 腾讯云 配合使用编辑微信公众号内容
- HBase:HBase的rowKey设计技巧
- asterisk注册河南联通ims
- 利用MATLAB视频函数工具箱的…
- 机器学习实战python版决策树以及Matplotlib注解绘制决策树
- Python 抓取数据并可视化
- java map字典序_java中对map的字典序排序
- JAVA外部库函数_java常用库函数
- 学习高博SLAM(1)
- Python在振动信号处理中的应用(五):振动加速度信号转换为速度或位移信号