In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to build a high-performance load balancing cluster in Nginx+Tomcat. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
The editor is going to build two sets of Tomcat and one set of nginx services on the same server.
II. Objectives
Tomcat clusters that achieve high performance load balancing:
1. Install nginx
Components required to compile the source code
Lib libraries required by 1.zlib ngix
2.pcre nginx rewrite rewriting is used to support regular expressions
3.openssl supports the use of sites with security protocols
1) Media download
Download address of the library:
Source code download address zlib
Http://www.zlib.net/
PCRE-support for regular expressions
Http://www.pcre.org/
Opensll installation (optional), sites that support security protocols
Http://www.openssl.org/
Nginx download
Http://nginx.org/en/download.html
2) upload media to linux platform and decompress
3) compile and install
4) modify the configuration file
1. Compile zlib
Tar xvf zlib-1.2.8.tar.gz
. / configure-static-prefix=/usr/local/libs/zlib
Make
Make install
two。 Compile openssl
Tar xvf openssl-1.0.le.tar.gz
. / config-- prefix=/usr/local/openssl
Make
Make install
3. Compile pcre
Tar xvf pcre-8.33.tar.gz
. / configure-- prefix=/usr/local/pcre
Make
Make install
4. Compile ngnix
Useradd nginx
Tar xvf nginx-1.5.4.tar.gz
/ configure-- user=nginx-- group=nginx-- prefix=/usr/local/nginx-- with-debug-- with-openssl=/soft/openssl-1.0.le-- with-zlib=/soft/zlib-1.2.8-- with-pcre=/soft/pcre-8.33-- with-http_stub_status_module-- with-http_gzip_static_module-- with-http_ssl_module
Make
Make install
Remarks:-- with-openssl-- with-zlib-- with-pcre these three paths are their corresponding source paths.
Start the nginx service
Cd / usr/local/nginx
. / nginx
Check whether the nginx process is working properly
Ps-ef | grep nginx
2. Install tomcat
Download tomcat media on the tomcat official website
Upload the Linux server to extract and modify the configuration file
[root@mysql tomcat] # pwd
/ usr/local/tomcat
[root@mysql tomcat1] # pwd
/ usr/local/tomcat1
Modify tomcat configuration file
First set of tomcat
The second set of tomcat modifications:
Start two sets of tomcat
Modify nginx configuration file
The configuration is as follows (only a simple configuration has been made here, and the actual production environment can be configured in more detail):
Vi tomcat_fzjh.conf
[html] view plain copy
The number of worker_processes # processes is generally the same as the number of cpu cores of the computer.
Events {
Worker_connections 1024 + # maximum number of connections per process (maximum number of connections = number of connections * number of processes)
}
Http {
Include mime.types; # File extension and File Type Mapping Table
Default_type application/octet-stream;# default file type
Sendfile on;# enables efficient file transfer mode. The sendfile instruction specifies whether nginx calls the sendfile function to output files. For common applications, set it to on. If it is used for downloading and other application disk IO heavy-load applications, it can be set to off to balance the processing speed of disk and network Ibano and reduce the load of the system. Note: if the picture does not display properly, change this to off.
Keepalive_timeout 65; # persistent connection timeout (in seconds)
Gzip on;# enables Gizp compression
# Cluster of servers
Upstream netitcast.com {# Server Cluster name
Server 127.0.0.1 weight 18080 server configuration weight means weight, the greater the weight, the greater the probability of allocation.
Server 127.0.0.1:28080 weight=2
}
# configuration of the current Nginx
Server {
Listen 80th # listens to port 80, which can be changed to other ports
Domain name of the current service of server_name localhost;#
Location / {
Proxy_pass http://netitcast.com;
Proxy_redirect default
}
Error_page 500 502 503 504 / 50x.html
Location = / 50x.html {
Root html
}
}
}
Start the nginx service
/ usr/local/nginx/sbin/nginx-c / usr/local/nginx/config/tomcat_fzjh.conf
This is the end of how to build a high-performance load balancer cluster in Nginx+Tomcat. I hope the above content can be of some help and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.