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

How to achieve Tomcat High availability through keepalive on CentOS7.4

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

This article mainly introduces "how to achieve high availability of Tomcat through keepalive on CentOS7.4". In daily operation, I believe that many people have doubts about how to achieve high availability of Tomcat through keepalive on CentOS7.4. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "how to achieve high availability of Tomcat through keepalive on CentOS7.4". Next, please follow the editor to study!

1. Background introduction of the project

As an internal IT service department, it is our consistent aim to provide users with stable, efficient and secure services. IT operation and maintenance management is particularly important, its most direct effect to users is to improve the service capability of IT system, service interruption time is reduced, availability is improved, then users' business flow based on IT system will be more smooth. To this end, choosing the appropriate IT operation and maintenance management software can maintain the high availability of the service.

two。 Architecture introduction

This chapter mainly describes the characteristics of the current department system application services, and provides an effective framework.

Architecture diagram:

Description:

1. Node Node An acts as the primary node in the dual-machine hot standby environment, and node Node B acts as the secondary node. When the primary node fails, the secondary node will automatically take over the role of the primary node to ensure the normal operation of the application.

two。 Node NFS is used to store Tomcat data

3. 192.168.1.210 is the virtual address provided to the application service, and the user accesses the application service through this virtual address, instead of accessing the system addresses of nodes Node An and Node B.

3. Keepalive introduction

The main function of Keepalived is to prevent a single point of failure, which means that once a point of failure occurs, it will lead to the unavailability of the entire system architecture, so as to achieve high availability and hot backup. At the beginning of its birth, the purpose of it is to be able to independently call ipvsadm to generate rules, and can automatically transfer the address accessed by users to other nodes. Keepalived: the core contains a core module and two checkers and VRRP protocols. Core module is the core of keepalived, which is responsible for the startup and maintenance of the main process as well as the loading and parsing of global configuration files. Checkers: if the check service checks the health of the reserved, you can also check the health of the service itself based on the script. This is the implementation of ipvs back-end health detection. VRRP (Virtual Router Redundancy Protocol, Virtual routing redundancy Protocol) is a fault-tolerant protocol, which ensures that when the host's next-hop router fails, another router will replace the failed router to work, thus maintaining the continuity and reliability of network communication. Each node in VRRP has a priority between each node. The higher the number, the higher the priority. (0255 has special use). Keepalived is based on the VRRP protocol, that is, N routers that provide the same function form a router group, which has a master node and multiple backup nodes. There is a vip providing services on the Master node (the default route of other machines in the local area network of the router is the vip). The master will send multicast. When the backup cannot receive the vrrp packet, it will think that the master has been down. In this case, you need to choose a backup as the master according to the priority of the VRRP. In this way, the high availability of the router can be ensured.

4. Scheme verification

This chapter will detail the construction process of the whole environment from hardware to software, so that readers can have a more intuitive and profound understanding of the configuration and working principle of Keepalive.

Hardware environment planning:

Select three Lenovo xSeries 3650 M4s and initialize them as shown in the table:

Description: 1. The performance and stability of xSeries 3650 M4 server meet the basic requirements of the project.

2. IMM (Integrated Management Module) provides remote management

3. The first network card Eth0 integrated on the motherboard is used to configure the IP address of the system.

4. The second network card Eth2 integrated on the motherboard is used to connect with NFS. Configure the private network address.

System and software environment planning:

Details of the system, software, and network are shown in the table:

Build:

1. Install CentOS 7.4 64-bit in mini mode on both the Node A Node B and NFS nodes, and configure the IP address according to the plan.

two。 Add the same content to the / etc/hosts file of nodes Node An and Node B, as follows:

192.168.1.198 NodeA.xx.xxx.com NodeA

10.10.10.11 NodeA.xx.xxx.com NodeA

192.168.1.199 NodeB.xx.xxx.com NodeB

10.10.10.12 NodeB.xx.xxx.com NodeB

3. Install Tomcat 7 and Keepalive 1.3.5 on nodes Node An and Node B

# yum install tomcat

# yum install keeplived

4. Configure the storage path of Tomcat data on the node NFS

5. Configure keeplive on node Node A

Edit the keepalive configuration file / etc/keepalived/keepalived.conf and modify it as follows:

Vrrp_instance VI_1 {state MASTER # set Node Node A for the MASTER role interface enp11s0f0 # Network Card enp11s0f0 configures the system IP address of node Node A virtual_router_id 51 # two systems guarantee that the same number, the larger the number, the higher the level, the advert_int 1authentication {auth_type PASS # vrrp protocol, ensure that the settings of the two systems are consistent auth_pass 1111} virtual_ipaddress {192.168.1.210 # virtual service address provided to Tomcat applications}

6. Configure keeplive on node Node B

Edit the keepalive configuration file / etc/keepalived/keepalived.conf and modify it as follows:

Vrrp_instance VI_1 {state BACKUP # set Node Node B for the BACKUP role interface enp11s0f0 # Network Card enp11s0f0 configures the system IP address of node Node B virtual_router_id 51 # two systems guarantee that this number is the same priority 90 # digital ratio MASTER can advert_int 1authentication {auth_type PASS # vrrp protocol, ensure that the settings of the two systems are consistent auth_pass 1111} virtual_ipaddress {192.168.1.210 # virtual service address provided to Tomcat applications}

7. Start keepalive

# systemctl start keepalived#systemct enable keepalived# setting Boot self-start

8. Verify the keepalive service

9. Verify the virtual network service address of node Node A

Description: by default, the virtual network service address 192.168.1.210 and the primary node system IP address 192.168.1.198 are bound to the same network card interface to indicate that they are operating normally.

10. Verify the network address of node Node B

Note: the secondary node Node B does not see the virtual network service address and has been verified by the virtual network service address of the primary node, indicating that the keepalive service has been running normally in the dual-machine hot backup environment.

11. Verify that Tomcat web portal is running properly

Description: the Tomcat service guaranteed by dual-server hot backup architecture is running normally.

twelve。 Verify that when the keepalive service of the primary node Node An is shut down or down, the secondary node Node B can take over and ensure that the Tomcat application will not be affected.

a. View the network address of the secondary node Node B

Note: the virtual network service address 192.168.1.210 and the secondary node system IP address 192.168.1.199 are bound to the same network card interface, indicating that the secondary node Node B has successfully taken over the responsibility of the primary node Node A.

b. Verify that Tomcat web portal is still running properly

Note: when the primary node Node A fails, the secondary node ensures the normal operation of the business through keepalive services.

At this point, the study on "how to achieve high availability of Tomcat through keepalive on CentOS7.4" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Network Security

Wechat

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

12
Report