Get the App
SLTechnology News&Howtos  ›  Servers  › 

45.Keepalived High availability Cluster

Shulou Source: shulou.com Published: 2022-06-03 08:18:14 12月06日 Update

Keepalived High availability Cluster

Keepalived uses VRRP hot backup protocol to realize the multi-computer hot backup function of linux server in a software way. When one party fails, it automatically switches the backup server to work.

Keepalived deployment environment: one master scheduling server, one slave scheduling server, and multiple node servers

Keepalived deployment steps:

V install support components

# yum-y install kernel-devel openssl-devel popt-devel ipvsadm

V source code installation keepalived tool

# tar xzvf keepalived-1.2.13.tar.gz

# cd keepalived-1.2.13

#. / configure-prefix=/-with-kernel-dir=/usr/src/kernels/2.6.32-431.e16.x86_64

# make & & make install

V configure the main scheduler

# vim / etc/keepalived/keepalived.conf

Modify the relevant content:

Global_defs {

Name of the router_id R1 master scheduler

}

Vrrp_instance VI_1 {

Hot standby status of state MASTER master scheduler

The lower interface of interface eth0 master scheduler

Virtual_router_id 1 group number

Priority 100priority

Advert_int 1

Authentication {Master-Slave Hot standby Authentication Information

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {Cluster virtual IP address

1.1.1.100

}

Virtual_server 1.1.1.100 80 {Virtual Service address Port

Interval between delay_loop 6 health check-ups

Scheduling algorithm for lb_algo rr polling

Cluster operation mode of lb_kind DR direct routing

! Persistence_timeout 50 hold time

Protocol TCP protocol

Real_server 1.1.1.1 80 {Real Server address Port

Weight 1 weight

TCP_CHECK {Health check method

Connect_port 80 checks the target port

Connect_timeout 3 connection timeout

Number of nb_get_retry 3 retries

Delay_before_retry 3 retry interval

}

}

}

V restart the keepalived service

# Service keepalived restart

V verify that the configuration file is in effect

# ip addr to see if a virtual cluster IP has been created automatically

V configure slave scheduler

# vim / etc/keepalived/keepalived.conf

Modify the content:

Global_defs {

Router_id R2 slave scheduler name

}

Vrrp_instance VI_1 {

State BACKUP slave hot standby status of the scheduler

Interface eth0 from the lower interface of the scheduler

Virtual_router_id 1 group number

Priority 99 priority

. Other contents are the same.

V restart the keepalived service

# Service keepalived restart

V configure node server

# ifconfig lo:0 1.1.1.100/32

# route add-host 1.1.1.100 dev lo:0

# vim / etc/sysctl.conf

Add content:

Net.ipv4.conf.all.arp_ignore = 1

Net.ipv4.conf.all.arp_announce = 2

Net.ipv4.conf.lo.arp_ignore = 1

Net.ipv4.conf.lo.arp_announce = 2

Net.ipv4.conf.default.arp_ignore = 1

Net.ipv4.conf.default.arp_announce = 2

# sysctl-p

Tags: Scheduling service server content configuration address port check health priority name backup interface mode time status node work same one party Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple macOS Microsoft Xiaomi