In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you how to use Nginx to achieve load balancing Tomcat cluster, hoping to give you some help in practical application, load balancing involves more things, there are not many theories, there are many books online, today we use the accumulated experience in the industry to do an answer.
I. tools
Operating system: win7
Nginx-1.13.5
Apache-tomcat-7.0.57
II. Objectives
Tomcat Cluster with High performance load balancing
III. Steps
1. Download Nginx first, and download the stable version:
2. Then decompress the two Tomcat
3. Modify the startup ports of the two Tomcat to 8180 and 8280, respectively. Take modifying the first Tomcat as an example, open server.xml under the conf directory of Tomcat.
The two tomcat modifications are the same as above, note that the ports must be different, I use 81 … And 82...
Create a test.war file, write an index.jsp page, and place it in the webapps directory, as follows:
Tomcat A
SessionID
Createdon
Then start the two Tomcat and visit it to see if it is normal.
6. After the above steps are successful, we can now configure Nginx to achieve load balancing, but we need to modify the 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):
Add the following code to the http module:
Gzip on
Upstream clarck.com {
Server 127.0.0.1:8180 weight=1
Server 127.0.0.1:8280 weight=2
}
Server_name localhost
Modify location / statement block
Location / {
Proxy_pass http://clarck.com;
Proxy_redirectdefault
}
Now that the configuration is complete, let's demonstrate load balancing.
7. Start two Tomcat CVMs first, and then start Nginx
8. Then we can enter: localhost/Test/index.jsp to check the health status
So far, we have implemented a load-balanced Tomcat cluster using Nginx. We keep refreshing and find that the probability of accessing Tomcat7_82 is about twice that of Tomcat1. This is due to the role of the weight of the two Tomcat that we configured in Nginx.
Read the above about how to use Nginx to achieve load balancing Tomcat cluster, if there is anything else you need to know, you can find what you are interested in in the industry information or find our professional and technical engineers to answer, technical engineers have more than ten years of experience in the industry. Official website link www.yisu.com
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.