目录
随着互联网的发展,越来越多的企业开始使用Tomcat作为其应用服务器。然而,单一的Tomcat实例已经无法满足高并发、高性能的需求,因此,我们需要通过集群的方式来提高系统的整体性能和可用性。
您可以快速配置Tomcat集群,实现应用的负载均衡和故障转移。在实际应用中,您还需要根据具体需求进行相应的调整和优化。希望这篇博客能够帮助您快速上手Tomcat集群配置,提高系统的整体性能和可用性。
tar -zxvf apache-tomcat-8.5.20.tar.gz
cp -r apache-tomcat-8.5.20/ apache-tomcat-8.5.20_8081/
#第2个修改的配置如下
1. 远程停服务端口,默认8005,如下改为8006
2.HTTP端口,默认8080,如下改为808
3.AJP端口,默认8009,如下改,8010
小编有单独的博客用于nginx安装
nignx安装https://blog.csdn.net/lz17267861157/article/details/135473906
Nginx的默认端口是80,由于HTTP协议的默认端口也是80,因此我们直接在浏览器上输入:http://ip即可访问到Ngxin服务器;
?
直接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;
# }
#}
}