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. linux 下python进程查看及关闭

    查看进程 ps -ef |grep python 关闭进程 kill -9 26879 其中26879为进程号. linux下后台执行某个python脚本 nohup python -u xxx.py ...

  2. 写出一条SQL语句:取出表A中第31到40行记录(SQLserver,以自增长的ID作为主键,注意: 一条Sql语句:取出表A中第31到第40记录

    解1: select top 10 * from A where id not in (select top 30 id from A) 解2: select top 10 * from A wher ...

  3. Go程序的一生是怎样的?

    Go 程序是怎样跑起来的 原创: 饶全成 码农桃花源  刚开始写这篇文章的时候,目标非常大,想要探索 Go 程序的一生:编码.编译.汇编.链接.运行.退出.它的每一步具体如何进行,力图弄清 Go 程序 ...

  4. mitmproxy修改二级代理

    第一步 mitmweb --mode upstream:http://114.240.101.242:5672 -s server.py 第二步 def request(self, flow: mit ...

  5. shell 从键盘读取输入时删除输入的字符

    [参考文章]:stty命令的用法全解 [参考文章]:shell——read时退格异常(shell修改删除符) stty srase ^h read  -p  "请输入参数信息" 在 ...

  6. laravel 链式组合查询数据

    laravel 链式组合查询数据 一.总结 一句话总结: - 就是链式操作的基本操作,因为返回的都是一直可以进行链式操作的对象,所以我们接收返回的对象即可 - $result = DB::table( ...

  7. VS2015编译cef3-2357

    1.会遇到把警告当错误的情况 按照如下设置即可 2. 错误 C2334 “:”的前面有意外标记:跳过明显的函数体 (编译源文件 E:\cef_binary_3.2357.1271.g8e0674e_w ...

  8. 宝塔安装Nextcloud,挂载在阿里云oss上,打造个人/企业高效私有云盘

    如下未完整整理,看懂看不懂随缘.... 准备条件: 1.阿里云oss 2.阿里云ecs 3.环境:centos7.x 步骤: 1.centos中安装宝塔面板 2.下载NextCloud安装包,上传到宝 ...

  9. 使用IEDriverServer.exe驱动IE,实现自动化测试

    1. 下载IEDriverServer: https://www.nuget.org/packages?q=IEDriver 2. 解压缩得到IEDriverServer.exe和IEDriverSe ...

  10. COALESCE关键字的使用

    COALESCE是sql标准里面的一个关键字,我们可以和聚合函数sum,count,max等一起使用完成一些特殊的功能. 以下sql语句基于mysql 1.查询某一个列总和,如果没有数据或者NULL返 ...