host1:10.0.0.10(部署nginx和tomcat)

host2:10.0.0.11(部署tomcat)

平台环境(2主机一样)

[root@smp ~]# uname -r
3.10.0-862.el7.x86_64
[root@smp ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core)

host1及host2上操作:

安装tomcat

https://www.cnblogs.com/liliyang/p/9742284.html

按照上面的博文将将两台机器上的tomcat均部署好,

然后访问

host1上安装nginx

yum install  wget -y

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum install  nginx  -y

cat  /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; events {
worker_connections 2048;
use epoll;
} http {
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;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf; upstream tomcatservers {     #这里注意tomcatserver为池的名称,这里的名称可任意取,但是名称内不能有下划线(有的书中使用了下划线)!!!!!!! server 10.0.0.10:8080 weight=1;
server 10.0.0.11:8080 weight=1;
} server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 10.0.0.10;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
proxy_pass http://tomcatservers;    #这里的名称必须是服务池的名称
proxy_redirect default; }                          #除了红色部分其余均为系统默认配置 error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}

[root@smp nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@smp nginx]# systemctl start nginx

访问测试:

nginx+tomcat实现简单的负载均衡的更多相关文章

  1. Windows下nginx+tomcat实现简单的负载均衡

    Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请 ...

  2. Nginx + Tomcat Windows下的负载均衡配置

     Nginx + Tomcat Windows下的负载均衡配置 一.为什么需要对Tomcat服务器做负载均衡?    Tomcat服务器作为一个Web服务器,其并发数在300-500之间,如果超过50 ...

  3. 图文解说:Nginx+tomcat配置集群负载均衡

    图文解说:Nginx+tomcat配置集群负载均衡 博客分类: appserver nginxTomcatUbuntuLinux网络应用  作者:niumd Blog:http://ari.iteye ...

  4. 搭建 Keepalived + Nginx + Tomcat 的高可用负载均衡架构

    1 概述 初期的互联网企业由于业务量较小,所以一般单机部署,实现单点访问即可满足业务的需求,这也是最简单的部署方式,但是随着业务的不断扩大,系统的访问量逐渐的上升,单机部署的模式已无法承载现有的业务量 ...

  5. 搭建Keepalived + Nginx + Tomcat的高可用负载均衡架构

    1 概述 初期的互联网企业由于业务量较小,所以一般单机部署,实现单点访问即可满足业务的需求,这也是最简单的部署方式,但是随着业务的不断扩大,系统的访问量逐渐的上升,单机部署的模式已无法承载现有的业务量 ...

  6. Nginx+Tomcat多实例及负载均衡配置

    Nginx+Tomcat多实例及负载均衡配置 采用nginx的反向代理负载均衡功能,配合后端的tomcat多实例来实现tomcat WEB服务的负载均衡 01 安装nginx服务 安装所需的pcre库 ...

  7. Keepalived + Nginx + Tomcat 的高可用负载均衡架构搭建

    Keepalived + Nginx + Tomcat 的高可用负载均衡架构搭建 Nginx 是一个高性能的 HTTP反向代理服务器 Keepalived 是一个基于VRRP协议来实现的LVS服务高可 ...

  8. Docker+nginx+tomcat7配置简单的负载均衡

    本文为原创,原始地址为:http://www.cnblogs.com/fengzheng/p/4995513.html 本文介绍在Docker上配置简单的负载均衡,宿主机为Ubuntu 14.04.2 ...

  9. Nginx+proxy实现简单的负载均衡

    环境说明:操作系统centos6.6 64位web操纵系统是:web1=192.168.10.10(LAMP) web2=192.168.10.11(LNMP),这里只是测试nginx实现负载均衡效果 ...

随机推荐

  1. PTA 朋友圈【并查集的合并问题】

    一开始,考虑的是每次就是把第一个作为祖先,这样很明显是错误的,比如 7 4 3 1 2 3 2 4 2 3 5 6 7 1 6 所以这正是更好地体现对于集合的代表.只有把所有的元素合并一下,然后选一个 ...

  2. python __builtins__ tuple类 (68)

    68.'tuple', 转换为元组类型 class tuple(object) | tuple() -> empty tuple | tuple(iterable) -> tuple in ...

  3. 第十五篇 .NET高级技术之正则表达式

    正则表达式 正则表达式是对字符串进行匹配的语法,像name like '%李%'一样,定义了一些特殊的“元字符”,用来判断一个字符串是否满足某个规则.正则表达式非常深,编译器都是基于正则表达式,掌握基 ...

  4. (二)SpringBoot整合常用框架Druid连接池

    一,在Pom.xml文件加入依赖 找到<dependencies></dependencies>标签,在标签中添加Druid依赖 <dependency> < ...

  5. Reference for shell scripting

    ${var} 和 $var的区别 http://stackoverflow.com/questions/8748831/when-do-we-need-curly-braces-in-variable ...

  6. servlet基础概念

    一.servlet是什么? 运行在Web服务器上(如:tomcat),作为浏览器请求与数据库或其他应用程序之间的中间层 二.servlet主要任务: 1.读取浏览器发送的显式数据(如:html表单)隐 ...

  7. [转]List of Visual Studio Project Type GUIDs

    本文转自:http://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs There isn' ...

  8. 虚方法(virtual)

    虚方法(virtual) Virtual 关键字用于修饰方法.属性.索引器或事件声明,并且允许在派生类中重写这些对象. 看一段代码: using System ; class A { public v ...

  9. Dom 获取、Dom动态创建节点

    一.Dom获取 1.全称:Document     Object     Model 文档对象模型 2.我们常用的节点类型 元素(标签)节点.文本节点.属性节点(也就是标签里的属性). 3.docum ...

  10. WARN警告:Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended

    使用Apache HttpClient发送请求,有大量WARN警告:Going to buffer response body of large or unknown size. Using getR ...