1.安装Tomcat

进入 /usr/local/ 目录 cd /usr/local

下载 wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.22/bin/apache-tomcat-9.0.22.tar.gz

解压 tar -zxvf apache-tomcat-9.0.22.tar.gz

新建文件夹 mkdir tomcat-9.0.22

重命名 mv ./apache-tomcat-9.0.22 ./tomcat-9.0.22/tomcat1

解压 tar -zxvf apache-tomcat-9.0.22.tar.gz

重命名 mv ./apache-tomcat-9.0.22 ./tomcat-9.0.22/tomcat2

2.配置Tomcat

添加环境变量 vim /etc/profile 

export CATALINA_HOME=/usr/local/tomcat-9.0.21/tomcat1
export CATALINA_BASE=/usr/local/tomcat-9.0.21/tomcat1
export TOMCAT_HOME=/usr/local/tomcat-9.0.21/tomcat1 export CATALINA_2_HOME=/usr/local/tomcat-9.0.21/tomcat2
export CATALINA_2_BASE=/usr/local/tomcat-9.0.21/tomcat2
export TOMCAT_2_HOME=/usr/local/tomcat-9.0.21/tomcat2

打开tomcat2/bin下的catalina.sh文件vim /usr/local/tomcat-9.0.22/tomcat2/bin/catalina.sh,在# OS specific support.  $var _must_ be set to either true or false.下增加

export CATALINA_BASE=$CATALINA_2_BASE
export CATALINA_HOME=$CATALINA_2_HOME

打开tomcat2/conf下的server.xml文件vim /usr/local/tomcat-9.0.22/tomcat2/conf/server.xml,修改端口,避免启动服务器端口冲突

  

  用一张png图片替换tomcat1/webapps/ROOT/下的tomcat.png图片,以区分两个服务器

  分别启动两个tomcat,

cd /usr/local/tomcat-9.0.22/tomcat1/bin/

./startup.sh

cd /usr/local/tomcat-9.0.22/tomcat2/bin/

./startup.sh

请求测试对应的服务器

tomcat1:

tomcat2:

3.安装Nginx

yum install nginx

4.配置Nginx

vim /etc/nginx/nginx.conf

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ 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 1024;
} 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;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
#include /etc/nginx/conf.d/*.conf; upstream tomcat9{
server IP地址:8080 weight=2;
server IP地址:9080 weight=2;
} server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 请求地址;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
proxy_pass http://tomcat9;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}

启动Nginx

cd /bin

./systemctl strat nginx

腾讯云CentOS 7搭建简单Tomcat+nginx集群的更多相关文章

  1. CentOS中搭建Redis伪分布式集群【转】

    解压redis 先到官网https://redis.io/下载redis安装包,然后在CentOS操作系统中解压该安装包: tar -zxvf redis-3.2.9.tar.gz 编译redis c ...

  2. Tomcat集群,Nginx集群,Tomcat+Nginx 负载均衡配置,Tomcat+Nginx集群

    Tomcat集群,Nginx集群,Tomcat+Nginx 负载均衡配置,Tomcat+Nginx集群 >>>>>>>>>>>> ...

  3. Redis+Tomcat+Nginx集群实现Session共享,Tomcat Session共享

    Redis+Tomcat+Nginx集群实现Session共享,Tomcat Session共享 ============================= 蕃薯耀 2017年11月27日 http: ...

  4. 搭建简单的hadoop集群(译文)

    本文翻译翻译自http://hadoop.apache.org/docs/r2.8.0/hadoop-project-dist/hadoop-common/ClusterSetup.html 具体的实 ...

  5. Tomcat学习总结(8)——Tomcat+Nginx集群解决均衡负载及生产环境热部署

    近日,为解决生产环境热部署问题,决定在服务器中增加一个tomcat组成集群,利用集群解决热部署问题. 这样既能解决高并发瓶颈问题,又能解决热部署(不影响用户使用的情况下平滑更新生产服务器)问题. 因为 ...

  6. 腾讯云CentOS系统配置apache和tomcat

    本文使用yum软件包管理工具基于CentOS7.2版本配置apache和tom. 云服务器选购完毕后,安装Xshell软件,输入用户名密码即可远程登陆登录(centos用户名默认是root). 1,下 ...

  7. 基于腾讯云CLB实现K8S v1.10.1集群高可用+负载均衡

    概述: 最近对K8S非常感兴趣,同时对容器的管理等方面非常出色,是一款非常开源,强大的容器管理方案,最后经过1个月的本地实验,最终决定在腾讯云平台搭建属于我们的K8S集群管理平台~ 采购之后已经在本地 ...

  8. [置顶] 搭建apache+tomcat+memcached集群环境

    一.搭建apache server服务器 1.apache server图示:(加载图片要一张一张,所以可以到下面网站下载带图片的word) http://download.csdn.net/user ...

  9. 使用kubeadm在CentOS上搭建Kubernetes1.14.3集群

    练习环境说明:参考1 参考2 主机名称 IP地址 部署软件 备注 M-kube12 192.168.10.12 master+etcd+docker+keepalived+haproxy master ...

随机推荐

  1. switch语句分析

    1.关于switch语句 如果if语句中表达式是判断是否等于一个常量时,可以用switch语句来代替 if(表达式 == 常量1)                        {          ...

  2. 使用StringBuilder写XML遭遇UTF-16问题

     http://www.cnblogs.com/jans2002/archive/2007/08/05/843843.html

  3. 【HTTP】无状态无连接的含义

    无连接:服务器处理完客户的请求,并收到客户的应答后,即断开连接. 早期这么做的原因是HTTP协议产生于互联网,因此服务器需要处理同时面向全世界数十万.上百万客户端的网页访问,但每个客户端(即浏览器)与 ...

  4. 【csp模拟赛1】T1 心有灵犀

    [题目描述] 爱玩游戏的小 Z 最近又换了一个新的游戏.这个游戏有点特别,需要两位玩 家心有灵犀通力合作才能拿到高分. 游戏开始时,两位玩家会得到同一个数字 N,假设这个数字共有 t 位数码, 然后两 ...

  5. 【CUDA 基础】6.0 流和并发

    title: [CUDA 基础]6.0 流和并发 categories: - CUDA - Freshman tags: - 流 - 事件 - 网格级并行 - 同步机制 - NVVP toc: tru ...

  6. 【洛谷4001】 [ICPC-Beijing 2006]狼抓兔子(最小割)

    传送门 洛谷 Solution 直接跑最小割板子就好了. 代码实现 #include<stdio.h> #include<stdlib.h> #include<strin ...

  7. MAC下STF安装及踩坑

    [Mac OS X]brew: command not found ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebr ...

  8. qt 元对象系统

    元对象系统 Qt中的元对象系统是用来处理对象间通讯的信号/槽机制.运行时的类型信息和 动态属性系统. 它基于下列三类: QObject类: 类声明中的私有段中的Q_OBJECT宏: 元对象编译器(mo ...

  9. django-admin 配置

    本节讲django-admin配置方法: 1.在工程配置文件中(settings.py)中启用admin组件.确保有如下两行配置: 2.执行数据库迁移的命令,确保对应的表在数据库中已经添加了 #pyt ...

  10. 【Makefile】Makefile中的常用函数简介

    1. subst函数 格式:$(subst <from>, <to>, <text>)功能:把字串<text>中的<from>字符串替换成& ...