reference:
https://www.cnblogs.com/yaboya/p/9107442.html
1. Preparations
(1) two servers
(2) are installed nginx
(3) are installed keepalived
yum install keepalived -y
2. Configure keepalived profile
Modify /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER #主服务其为MASTER,备用服务器为BACKUP
interface enp0s8
virtual_router_id 51
priority 100 #主服务优先级必须大于备用服务器
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.56.16
192.168.56.17
192.168.56.18
}
}
3. Start
(1) Start ngnix
(2) Start keepalived
systemctl start keepalived
4. Access virtual IP address
192.168.56.16
192.168.56.17
192.168.56.18
5. Close the master server (direct off)
Access the virtual IP address, you can still have access to nginx