LVS+keepalived DR mode configuration to achieve high availability cluster

1. Configure VIP

# cd /etc/sysconfig/network-scripts/

# mv ifcfg-enp2s0  ifcfg-eth0

Please note the name change here:

vim /etc/default/grub (back up before modification)
GRUB_CMDLINE_LINUX This statement adds the following two parameters
net.ifnames=0 biosdevname=0

Add 2 parameters to the GRUB_CMDLINE_LINUX variable (net.ifnames=0 biosdevname=0), the modification is completed as follows:

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap net.ifnames=0 biosdevname=0 rhgb quiet" 
Note that there are spaces before and after.

Rebuild the grub configuration file
and execute the command: grub2-mkconfig -o /boot/grub2/grub.cfg

Modify /etc/sysconfig/network-scripts/ifcfg-ens33
to change the file name to ifcfg-eth0
to open the file, and change the NAME and DEVICE parameters to eth0.

reboot the system

ifconfig, found that the modification has been completed

 

# cp ifcfg-eth0  ifcfg-eth0:0

# vim ifcfg-eth0:0 set the virtual IP to 200

IPADDR=10.66.1.200

# service network restart

[root@localhost network-scripts]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.66.1.128  netmask 255.255.255.0  broadcast 10.66.1.255
        inet6 fe80::17e3:3e0:f300:7d56  prefixlen 64  scopeid 0x20<link>
        ether 44:8a:5b:50:13:1f  txqueuelen 1000  (Ethernet)
        RX packets 586319  bytes 35633730 (33.9 MiB)
        RX errors 0  dropped 962  overruns 0  frame 0
        TX packets 4607  bytes 377345 (368.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 6

eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.66.1.200  netmask 255.255.255.0  broadcast 10.66.1.255
        ether 44:8a:5b:50:13:1f  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 84  bytes 7248 (7.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 7248 (7.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2. Install ipvsadm

yum -y install ipvsadm

# ipvsadm -A -t 10.66.1.128:80 -s rr

# ipvsadm -a -t 10.66.1.128:80 -r 10.66.1.123 -g

# ipvsadm -a -t 10.66.1.128:80 -r 10.66.1.223 -g

[root@localhost ~]# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.66.1.128:80 rr
  -> 10.66.1.123:80               Route   1      0          0         
  -> 10.66.1.223:80               Route   1      0          0         
[root@localhost ~]#

# cp ifcfg-lo ifcfg-lo:1

# vim ifcfg-lo:1

# echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore

# echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce

continue tomorrow

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325261203&siteId=291194637