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. 纯拓扑排序一搞poj2367

    /* author: keyboarder time : 2016-05-18 12:21:26 */ #include<cstdio> #include<string.h> ...

  2. 移动端rem.js的使用方法

    下面的代码一是我根据rem的使用经验,自己写的一个rem.js,发现很好用,能适用所有移动端h5页面的自适应需求: 代码一: window.onload = function(){ /*720代表设计 ...

  3. AtCoder Grand Contest 008 D - K-th K

    题目传送门:https://agc008.contest.atcoder.jp/tasks/agc008_d 题目大意: 给你一个长度为\(N\)的序列\(A\),请你构造一个长度为\(N^2\)的序 ...

  4. Hdu 2089 不要62 (数位dp入门题目)

    题目链接: Hdu 2089 不要62 题目描述: 给一个区间 [L, R] ,问区间内不含有4和62的数字有多少个? 解题思路: 以前也做过这个题目,但是空间复杂度是n.如果数据范围太大就GG了.今 ...

  5. bzoj2301 [HAOI2011]Problem b【莫比乌斯反演 分块】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2301 很好的一道题.首先把每个询问转化为4个子询问,最后的结果就是这四个子询问的记过加加减减 ...

  6. Educational Codeforces Round 19 C

    Description Petya recieved a gift of a string s with length up to 105 characters for his birthday. H ...

  7. Mysql查询语句的 where子句、group by子句、having子句、order by子句、limit子句

    Mysql的各个查询语句 一.where子句   语法:select *|字段列表 from 表名 where 表达式.where子句后面往往配合MySQL运算符一起使用(做条件判断) 作用:通过限定 ...

  8. Lock wait timeout exceeded; try restarting transaction linux设置mysql innodb_lock_wait_timeout

    root权限下: vi /etc/my.cnf 在[mysqld]配置下面加入 innodb_lock_wait_timeout=value # value是你想设置的值 重启mysql /etc/i ...

  9. php输出中文字符

    中文字符不可以使用imagettftext()函数在图片中直接输出,如果要输出中文字符,需要先使用iconv()函数对中文字符进行编码,语法格式如下:string iconv ( string $in ...

  10. 关于web中的路径

    做了许多Demo发现,浏览器解析的路径和服务器解析的路径是不同的.我们知道,路径加上/的时候,表示的是绝对路径的意思,而如果是服务器解析的话,这个/相对的是我们的web应用,即相对于http://19 ...