快速上手:Tomact集群配置(图文并茂)

简介: 快速上手:Tomact集群配置(图文并茂)

博客前言:

随着互联网的发展,越来越多的企业开始使用Tomcat作为其应用服务器。然而,单一的Tomcat实例已经无法满足高并发、高性能的需求,因此,我们需要通过集群的方式来提高系统的整体性能和可用性。您可以快速配置Tomcat集群,实现应用的负载均衡和故障转移。在实际应用中,您还需要根据具体需求进行相应的调整和优化。希望这篇博客能够帮助您快速上手Tomcat集群配置,提高系统的整体性能和可用性。

一.前期准备工作

1 .Tomcat集群架构图

  • 未搭建Tomcat集群架构图如下:

  • 搭建Tomcat集群架构图如下:

2. 准备工具

  • nginx:1.13.7
  • tomact:8.5.20

二·.配置集群

1.tomact配置

1.1首先解压一个tomact

tar -zxvf apache-tomcat-8.5.20.tar.gz

1.2 解压后再准备2个tomcat

cp -r apache-tomcat-8.5.20/ apache-tomcat-8.5.20_8081/

1.3修改第二个的端口号

#第2个修改的配置如下

1. 远程停服务端口,默认8005,如下改为8006

2.HTTP端口,默认8080,如下改为808

3.AJP端口,默认8009,如下改,8010

1.4修改默认页面

1.5启动8080的tomact

2.nginx 安装配置

2.1.安装

小编有单独的博客用于nginx安装

nignx安装

Nginx的默认端口是80,由于HTTP协议的默认端口也是80,因此我们直接在浏览器上输入:http://ip即可访问到Ngxin服务器;

 

2.2.修改配置文件

直接copy即可

 
#user  nobody;
worker_processes  1;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
 
  
  # 定义一个集群组
  upstream web_cluster{
    # 第一台机器的地址
    server 127.0.0.1:8080;
    
    # 第二台机器的地址
    server 127.0.0.1:9090;
  }
 
 
    include       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  logs/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
 
  
    server {
        listen       80;
        server_name  localhost;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}
    
    
    
    location / {
            proxy_pass http://web_cluster;
            index  index.html index.htm;
        }
    
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
 
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
 
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
}


相关文章
|
数据安全/隐私保护
vscode访问和编辑远程服务器文件
vscode访问和编辑远程服务器文件
360 0
vscode访问和编辑远程服务器文件
|
JSON fastjson Java
FastJson、JackJson 以及 Gson 的区别
FastJson、JackJson 以及 Gson 是 Java 生态圈中三种常用的 Json 解析器,它们均可将 Java 对象序列化为 Json 格式的字符串,也可将 Json 字符串反序列化为 Java 对象。下面我们讨论一下三者在序列化和反序列化操作中的一些区别。
1327 0
|
应用服务中间件 Apache Windows
Windows平台及服务器部署安装多个Tomcat服务(详细版)
Windows平台及服务器部署安装多个Tomcat服务(详细版)
746 0
Windows平台及服务器部署安装多个Tomcat服务(详细版)
|
存储 负载均衡 NoSQL
Tomcat 9.X(9.0.74)集群实现Session共享(基于redisson)
本文主要介绍了tomcat集群环境下基于redis+Redisson实现session共享,分享给大家,供广大从业者学习和参考。
12971 4
|
11月前
|
存储 JSON Java
ELK 圣经:Elasticsearch、Logstash、Kibana 从入门到精通
ELK是一套强大的日志管理和分析工具,广泛应用于日志监控、故障排查、业务分析等场景。本文档将详细介绍ELK的各个组件及其配置方法,帮助读者从零开始掌握ELK的使用。
|
11月前
|
负载均衡 监控 Dubbo
Dubbo 实现原理详解,一文吃透!
本文深入解析Dubbo的底层实现原理,涵盖远程方法调用、智能容错和负载均衡、服务注册和发现三大核心功能,详解其架构设计和调用流程。关注【mikechen的互联网架构】,10年+BAT架构经验倾囊相授。
Dubbo 实现原理详解,一文吃透!
|
10月前
|
缓存 API 开发工具
Qwen-coder方向-如果从0开始应用通义千问开源大模型
从0开始接触,带您全面了解Qwen2.5语言模型家族,包括其核心功能、微调方法以及具体应用场景。我们将通过一系列精心准备的应用demo和使用指南,帮助您掌握如何充分利用Qwen2.5的强大能力
1115 8
|
11月前
|
负载均衡 监控 算法
论负载均衡技术在Web系统中的应用
【11月更文挑战第4天】在当今高并发的互联网环境中,负载均衡技术已经成为提升Web系统性能不可或缺的一环。通过有效地将请求分发到多个服务器上,负载均衡不仅能够提高系统的响应速度和处理能力,还能增强系统的可扩展性和稳定性。本文将结合我参与的一个实际软件项目,从项目概述、负载均衡算法原理以及实际应用三个方面,深入探讨负载均衡技术在Web系统中的应用。
347 2
|
Java
(稳住心态的帖子)idea启动项目速度突然变慢
这是一篇偏向心态调整的帖子
386 0
|
存储 缓存 NoSQL
Redis深度解析:部署模式、数据类型、存储模型与实战问题解决
Redis深度解析:部署模式、数据类型、存储模型与实战问题解决