It is very easy to use Keepalived for dual-host hot backup. It is often used with LVS to achieve high-availability load balancing.
1. Master/Slave
First, prepare two test servers and a virtual IP address.
Server A: 192.168.1.10 (master Server)
Server B: 192.168.1.20
Virtual IP: 192.168.1.100
Test Service: Install Nginx on the two servers respectively, and modify the default index.html file to display the IP address of the current server for identification.
1. Install keepalived on the two servers respectively.
$ Sudo apt-get install keepalived
2. Add a configuration file.
Server
$ Sudo vim/etc/keepalived. conf
Global_defs {
Router_id LVS_DEVEL
}
Vrrp_instance VI_1 {
State MASTER
Interface eth0
Virtual_router_id 51 # Keep Master/Slave servers consistent
Priority 100 # priority (master server)
Advert_int 1 # Heartbeat broadcast interval (seconds)
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
192.168.1.100/24 # multiple virtual IP addresses.
}
}
Server B
$ Sudo vim/etc/keepalived. conf
Global_defs {
Router_id LVS_DEVEL
}
Vrrp_instance VI_1 {
State BACKUP
Interface eth0
Virtual_router_id 51
Priority 99
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
192.168.1.100/24
}
}
Note: In Server B configuration, the state must be changed to BACKUP and the priority must be lowered.
- Four pages in total:
- Previous Page
- 1
- 2
- 3
- 4
- Next Page