Using OpenNJet HA Copilot to achieve high availability deployment (1)

NGINX evolves to cloud native, All in OpenNJet


1. Introduction to HA

When deploying server applications, in order to achieve high availability of the service, a common solution is to additionally install Keepalived, monitor the running status of the server application through Keepalived, and set up a virtual IP (VIP). The client accesses the server through VIP. Example. Taking the open source Nginx as an example, the diagram is as follows:
 
Keepalived is based on the VRRP protocol, which stands for Virtual Router Redundancy Protocol. The virtual routing redundancy protocol can be considered as a protocol to achieve high availability of routers. N routers that provide the same functions are formed into a router group. This group has a master and multiple backups. The master has a VIP (VIP) that provides services to the outside world. Virtual IP Address) (the default route of other machines in the LAN where the router is located is VIP), the master will send multicast, and when the backup cannot receive the VRRP packet, it will consider the master to be down. At this time, it is necessary to prioritize the VRRP level to elect a backup as master. In this way, the high availability of the router can be ensured.
In order to simplify deployment and configuration, NJet implements the HA module of the VRRP protocol through the Copilot extension mechanism. As long as HA Copilot is loaded and the corresponding configuration file is provided, the high availability function can be achieved. The schematic diagram is as follows:

2. Configuration instructions

To enable the HA function, you need to add the following instructions in the main block of njet.conf
helper ha modules/njt_helper_ha_module.so conf/vrrp.conf;
And provide the vrrp configuration file in the conf directory. The description of the configuration items is as follows.
 
Configuration items
Required
Configuration instructions
vrrp_instance
yes
The string of vrrp_instance is the set VRRP instance name.
state
yes
Set the initialization status of the current node, the status is MASTER or BACKUP
interface
yes
You can bind the VIP interface name, such as eth0, bond0, br0.
View your network card information through IP -a
nopreempt
no
Set whether to preempt the virtual IP. If added, it will not preempt.
virtual_router_id
yes
Set the unique ID of the virtual router, range: 0-255. Multiple njet nodes belonging to the same cluster have the same ID. The value must be different in different njet clusters. Be sure to confirm that this value must be unique in the same network.
priority
yes
Set the priority of the current njet node, range: [1-254], the larger the value, the higher the priority.
virtual_ipaddress
yes
Set the subnet mask corresponding to the virtual IP
For configuration sample files, see the test verification chapter below.

3. Test verification

  • Configure three server test machines, the IPs are:
  1. 192.168.40.157
  2. 192.168.40.158
  3. 192.168.40.149
  • Use virtual IP:
  1. 192.168.40.50
The 192.168.40.157 server vrrp.conf configuration is as follows:
vrrp_instance m{
    state MASTER
    interface eth192
    virtual_router_id 32 
    priority 200 
    virtual_ipaddress {
         192.168.40.50/24 
    }
}
 
The 192.168.40.158 server vrrp.conf configuration is as follows:
vrrp_instance m{
    state BACKUP
    interface eth192
    virtual_router_id 32 
    priority 100 
    virtual_ipaddress {
          192.168.40.50/24 
    }
}
The 192.168.40.149 server vrrp.conf configuration is as follows:
vrrp_instance m{
    state BACKUP
    interface eth192
    virtual_router_id 32 
    priority 10 
    virtual_ipaddress {
        192.168.40.50/24 
    }
}

When NJet is started on all three servers , since 40.157 is the MASTER , the host will obtain the VIP :

 
 
 
After stopping the NJet instance on the 40.157 host, since the priority of the 40.158 host is higher, 40.158 will get the VIP:
 
 
 
After restarting the NJet instance on the 40.157 host, 40.157 will regain the VIP.

OpenNJet was first based on the basic fork of NGINX1.19 and evolved independently. It has the characteristics of high performance, stability, and easy expansion. It also solves the long-standing problems of NGINX such as difficulty in dynamic configuration and management functions affecting business.
Alibaba Cloud suffered a serious failure and all products were affected (restored). Tumblr cooled down the Russian operating system Aurora OS 5.0. New UI unveiled Delphi 12 & C++ Builder 12, RAD Studio 12. Many Internet companies urgently recruit Hongmeng programmers. UNIX time is about to enter the 1.7 billion era (already entered). Meituan recruits troops and plans to develop the Hongmeng system App. Amazon develops a Linux-based operating system to get rid of Android's dependence on .NET 8 on Linux. The independent size is reduced by 50%. FFmpeg 6.1 "Heaviside" is released
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/6606114/blog/10143305