server 1 master ens33 192.168.10.200
server 2 backup ens33 192.168.10.252
virtual ip : 192.168.10.100
< server 1 >
[root@server1 ~]# cat /etc/sysctl.conf
net.ipv4.ip_forward = 1
[root@server1 ~]# sysctl -p
net.ipv4.ip_forward = 1
[root@server1 ~]# dnf -y install keepalived
[root@server1 ~]# mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.old
[root@server1 ~]# vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id cluster1
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 10
priority 200
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.100/24
}
}
[root@server1 ~]# systemctl start keepalived
[root@server1 ~]# systemctl enable keepalived
[root@server1 ~]# systemctl status keepalived
[root@server1 ~]# ip a
....
inet 192.168.10.200/24 brd 192.168.10.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.10.100/24 scope global secondary ens33
....
< server2 >
[root@server2 ~]# cat /etc/sysctl.conf
net.ipv4.ip_forward = 1
[root@server2 ~]# sysctl -p
net.ipv4.ip_forward = 1
[root@server2 ~]# dnf -y install keepalived
[root@server2 ~]# mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.old
[root@server2 ~]# vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id cluster2
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 10
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.100/24
}
}
[root@server2 ~]# systemctl start keepalived
[root@server2 ~]# systemctl enable keepalived
[root@server2 ~]# systemctl status keepalived
[root@server2 ~]# ip a
....
inet 192.168.10.252/24 brd 192.168.10.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.10.100/24 scope global secondary ens33
....
<test>
외부에서 ping 192.168.10.100 -t 로 핑 날리면서 확인
server1 power off 시킴 -- priority가 높은쪽
그러면 ping이 몇초간 끊겼다가 다시 살아남
'linux' 카테고리의 다른 글
centos 8 - drbd 설치 (0) | 2021.01.04 |
---|---|
centos 8 - pacemaker (0) | 2021.01.03 |
centos - multipath + iscsi 설정 (0) | 2021.01.02 |
centos - vlan 설정 (0) | 2020.12.31 |
centos teaming 티밍 - activebackup (0) | 2020.12.31 |