Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to the setting method of load Cluster of Tomcat as an Application Server

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The following is an introduction to Tomcat as a load cluster setting method for application Cloud Virtual Machine. I hope it can bring some help to you in practical application. Load Balancer involves many things, but there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to make an answer.

Case Study; Often, a Tomcat site cannot be used in a production environment alone due to problems such as a single point of failure and an inability to cope with complex and diverse requests from too many customers, so we need a more reliable solution to complete the web site architecture.

Nginx is a very good http Cloud Virtual Machine software, it can support up to 50000 concurrent connection response, has a strong static resource processing capacity, stable operation, and memory, CPU and other system resources consumption is very low. At present, many large websites apply Nginx server as a reverse proxy and Load Balancer for backend website programs to improve the load concurrency capability of the entire site.

This case explains how to set up a load cluster using Nginx as a Load Balancer and Tomcat as an application server. The topology of the website is as shown in the figure;

Case environment;1) Nginx server IP address 192.168.30.55 Install software nginx-1. 12.0.tar.gz2) Tomcat server 1 IP address 192.168.30.15 install software jdk-8u91-linux-x64.tar.gz apache-tomcat-8.5.16.tar.gz3) Tomcat server 2 IP address 192.168.30.99 install software jdk-8u91-linux-x64.tar.gz apache-tomcat-8.5.16.tar.gz Get free source package links;

https://pan.baidu.com/s/1SWGJ0jS3PJlWYHvBhrvjZg

https://pan.baidu.com/s/18wIP0vQFSESFc80yMb4n7A

https://pan.baidu.com/s/1VCKDfOWZ1vGIywahc_OSPQ

Case implementation;

Tomcat two server configuration,

(1) Close firewall, install JDK, configure java environment,

(2) Install configuration Tomcat, edit different test pages

(3) Start Tomcat, and the browser accesses the test webpage.

JDK must be installed and java environment configured before tomcat service can be installed. Tomcat runs on port 8080 by default. Prepare JDK and tomcat in advance.

Use the source command to import the java.sh script into the system environment variables and make it take effect.

After the java environment is installed, start installing the tomcat package.

Visit tomcat server website in browser, you can see tomcat official website home page content. Tomcat runs on port 8080 by default, indicating that tomcat has been configured to start successfully.

tomcat service default home page site directory is webapps/ROOT/, default home page document is index.jsp. Edit a home page test document respectively.

Tomcat Server 1 test page content

Visit tomcat server 2's website in your browser and you'll see the edited test page content.

Tomcat Server 2 test page content

Visit tomcat server 2's website in your browser and you'll see the edited test page content.

Installation Configuration of Reverse Proxy Server nginx

(1) Compile and install nginx

Install package nginx-1 prepared beforehand. 12.0.tar.gz for decompression

Install the dependency packages of nginx and prepare to compile the installation environment. The operation of nginx requires the support of software packages such as pcer zlib. Therefore, the development packages of these software should be installed in advance before configuring, compiling and installing, so as to provide the corresponding libraries and header files to ensure the smooth installation of nginx.

Create running users, groups. Configure to enable http_stub_status_module to support status statistics. compile and install

In order to make the Nginx service run more conveniently, you can create a link file for the main program nginx for easy management. Use the nginx command to start the service

Enter the nginx URL in the browsing area to visit, you can see the official home page of nginx, indicating that nginx is already running.

Set the main configuration file of nginx. The main configuration file of nginx is/usr/local/nginx/conf/nginx.conf Add the reverse proxy setting parameter upstream server pool name {} to the configuration file to configure the backend server pool to provide response data. The parameter weight indicates the weight value. The higher the weight value, the greater the probability of being assigned. In order to make the test effect more obvious, we set the weight value to the same value. upstream tomcat_server {

server 192.168.30.15:8080 weight=1;

server 192.168.30.99:8080 weight=1;

}proxy_pass http://tomcat_server; Configure a server proxy that forwards access requests to the backend server pool tomcat_server.

Proxy nginx's default site to the configured tomcat_server Load Balancer server group via proxy_pass method.

To test the Load Balancer effect, open the browser and visit http://192.168.30.55. Keep refreshing the browser test. You can see that due to the same weight, the page will switch between the following two pages repeatedly. Load Balancer successfully built, nginx reverse proxy successfully backend tomcat server group.

Turn off one of the tomcat services and refresh the browser several times. At this time, only the web page of the other tomcat service will be displayed.

After reading the above introduction on Tomcat as an application server load cluster setting method, if you still have anything to know, you can find what you are interested in the industry information or find our professional 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report