LVS+Keepalived Highest Efficient Cluster (Actual)

LVS+Keepalived Cluster

Environmental preparation:

DR1 Main: 192.168.100.101---->CentOS 7-2

DR2 Preparation: 192.168.100.102---->CentOS 7-3

web1: 192.168.100.111---->CentOS 7-4

web1: 192.168.100.112---->CentOS 7-5

vip: 192.168.100.10

Client: 192.168.100.10

Prepare software installation for online yum source in advance:

CentOS 7-2: 
[root@localhost ~]# yum install ipvsadm keepalived -y
[root@localhost ~]# cd /etc/keepalived/
[root@localhost keepalived]# ls
keepalived.conf
//Verify that there is this master profile after installation is complete

CentOS 7-3: 
[root@localhost ~]# yum install ipvsadm keepalived -y
[root@localhost ~]# cd /etc/keepalived/
[root@localhost keepalived]# ls
keepalived.conf
//Verify that there is this master profile after installation is complete

CentOS 7-4: 
[root@localhost ~]# yum install httpd -y

CentOS 7-5: 
[root@localhost ~]# yum install httpd -y

Change all network cards to host-only mode, and modify the network card profile:

**CentOS 7-2: **
[root@localhost keepalived]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BROWSER_ONLY="no"
BOOTPROTO="static"      //Change dhcp to static
......Omit multiple lines here
ONBOOT="yes"
IPADDR=192.168.100.101  //Press o on the last line and insert the following below
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
//Input after modification: wq save exit
[root@localhost keepalived]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
[root@localhost keepalived]# service network restart 
Restarting network (via systemctl):                        [  Determine  ]
[root@localhost keepalived]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.101  netmask 255.255.255.0  broadcast 192.168.100.255
//Confirm that the modification of the network card is complete

**CentOS 7-3: **
[root@localhost keepalived]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BROWSER_ONLY="no"
BOOTPROTO="static"      //Change dhcp to static
......Omit multiple lines here
ONBOOT="yes"
IPADDR=192.168.100.102  //Press o on the last line and insert the following below
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
//Input after modification: wq save exit
[root@localhost keepalived]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
[root@localhost keepalived]# service network restart 
Restarting network (via systemctl):                        [  Determine  ]
[root@localhost keepalived]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.102  netmask 255.255.255.0  broadcast 192.168.100.255
//Confirm that the modification of the network card is complete

//At this point, you can test ping connection with the network segment to see if the address is valid:
[root@localhost keepalived]# ping 192.168.100.101
PING 192.168.100.101 (192.168.100.101) 56(84) bytes of data.
64 bytes from 192.168.100.101: icmp_seq=1 ttl=64 time=0.658 ms
64 bytes from 192.168.100.101: icmp_seq=2 ttl=64 time=1.21 ms
//At this point, the two dispatching hosts are connected to each other
**CentOS 7-4: **
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BROWSER_ONLY="no"
BOOTPROTO="static"      //Change dhcp to static
......Omit multiple lines here
ONBOOT="yes"
IPADDR=192.168.100.111  //Press o on the last line and insert the following below
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
//Input after modification: wq save exit
[root@localhost ~]# service network restart 
Restarting network (via systemctl):                        [  Determine  ]
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.111  netmask 255.255.255.0  broadcast 192.168.100.255
//Confirm that the modification of the network card is complete

**CentOS 7-5: **
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
BROWSER_ONLY="no"
BOOTPROTO="static"      //Change dhcp to static
......Omit multiple lines here
ONBOOT="yes"
IPADDR=192.168.100.112  //Press o on the last line and insert the following below
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
//Input after modification: wq save exit
[root@localhost ~]# service network restart 
Restarting network (via systemctl):                        [  Determine  ]
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.112  netmask 255.255.255.0  broadcast 192.168.100.255
//Confirm that the modification of the network card is complete

//At this point, you can test ping connection with the network segment to see if the address is valid:
[root@localhost ~]# ping 192.168.100.111
PING 192.168.100.111 (192.168.100.111) 56(84) bytes of data.
64 bytes from 192.168.100.111: icmp_seq=1 ttl=64 time=0.913 ms
64 bytes from 192.168.100.111: icmp_seq=2 ttl=64 time=0.830 ms
//At this point, the two node servers are connected to each other

Modifications on Dispatch Server CentOS 7-2:

[root@localhost keepalived]# vim /etc/sysctl.conf 
//Insert the following below the last line
net.ipv4.ip_forward=1       //Turn on routing forwarding
net.ipv4.conf.all.send_redirects = 0        //proc response turns off redirection
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0
//Input after modification: wq save exit
[root@localhost keepalived]# Sysctl-p //Effective
net.ipv4.ip_forward = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0

Create a virtual network card:

[root@localhost ens33]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33  ifdown-ppp       ifup-ib      ifup-Team
ifcfg-lo     ifdown-routes    ifup-ippp    ifup-TeamPort
ifdown       ifdown-sit       ifup-ipv6    ifup-tunnel
......Omit multiple lines here
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33:0
[root@localhost network-scripts]# vim ifcfg-ens33:0
//Delete everything by pressing 50dd before inserting the following
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.100.10
NETMASK=255.255.255.0
//Input after modification: wq save exit
[root@localhost network-scripts]# ifup ens33:0 //Enable Virtual Network Card
[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        ether 00:0c:29:c2:51:f6  txqueuelen 1000  (Ethernet)
//This is the inbound port for virtual IP and access

[root@localhost network-scripts]# cd /etc/init.d/
[root@localhost init.d]# vim dr.sh            
#!/bin/bash
GW=192.168.100.1
VIP=192.168.100.10
RIP1=192.168.100.111
RIP2=192.168.100.112 
case "$1" in
start)
        /sbin/ipvsadm --save > /etc/sysconfig/ipvsadm
        systemctl start ipvsadm
        /sbin/ifconfig ens33:0 $VIP broadcast $VIP netmask 255.255.255.255 broadcast $VIP up
        /sbin/route add -host $VIP dev ens33:0
        /sbin/ipvsadm -A -t $VIP:80 -s rr
        /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
        /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
        echo "ipvsadm starting ---------------------[ok]"
        ;;
        stop)
        /sbin/ipvsadm -C
        systemctl stop ipvsadm
        ifconfig ens33:0 down
        route del $VIP
        echo "ipvsadm stoped--------------------[ok]"
        ;;
        status)
        if [ ! -e /var/lock/subsys/ipvsadm ];then
        echo "ipvsadm stoped--------------"
        exit 1
                else
                echo "ipvsadm Runing-----------[ok]"
        fi
        ;;
        *)
        echo "Usage: $0 {start|stop|status}"
        exit 1
        ;;
        esac
        exit 0
//Input after modification: wq save exit
[root@localhost init.d]# chmod +x dr.sh 
[root@localhost init.d]# service dr.sh start
ipvsadm starting ---------------------[ok]
[root@localhost init.d]# systemctl stop firewalld.service 
[root@localhost init.d]# setenforce 0          

Operation of Node Server CentOS 7-4:

[root@localhost ~]# rpm -q httpd
httpd-2.4.6-90.el7.centos.x86_64
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# echo "this is accp web" > index.html
[root@localhost html]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33  ifdown-ppp       ifup-ib      ifup-Team
ifcfg-lo     ifdown-routes    ifup-ippp    ifup-TeamPort
[root@localhost network-scripts]# cp ifcfg-lo ifcfg-lo:0
[root@localhost network-scripts]# vim ifcfg-lo:0
//Delete everything you don't need and make the following changes
DEVICE=lo:0
IPADDR=192.168.100.10
NETMASK=255.255.255.0
ONBOOT=yes
//Input after modification: wq save exit
[root@localhost network-scripts]# cd /etc/init.d/
[root@localhost init.d]# vim web.sh
#!/bin/bash
VIP=192.168.100.10
case "$1" in
start)
    /sbin/ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP
    /sbin/route add -host $VIP dev lo:0
    echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
    echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
    sysctl -p >/dev/null 2>&1
    echo "RealServer Start OK"
    ;;
stop)
    /sbin/ifconfig lo:0 down
    /sbin/route del $VIP /dev/null 2>&1
    echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
    echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
    echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
    echo "RealServer Stoped"
    ;;
*)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac
exit 0
//Input after modification: wq save exit
[root@localhost init.d]# chmod +x web.sh 
[root@localhost init.d]# service web.sh start 
RealServer Start OK 
[root@localhost init.d]# ifup lo:0
[root@localhost init.d]# ifconfig
lo:0: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 192.168.100.10  netmask 255.255.255.0
        loop  txqueuelen 1  (Local Loopback)
//At this time, the above shows that the virtual network card is successfully enabled 

[root@localhost init.d]# firefox "http://127.0.0.1" &
[1] 8587    //Process Number Random
//Firefox browser in the background automatically executes, the process is 8587, the browser will automatically pop up, will display the web page content we wrote before

Restart script:

[root@localhost init.d]# service web.sh stop
SIOCDELRT: No such device
RealServer Stopd
[1]-  complete                  firefox "http://127.0.0.1"
[2]+  complete                  firefox "http://127.0.0.1"
[root@localhost init.d]# service web.sh start 
RealServer Start OK 

The first node server is now configured!

Operation of Node Server CentOS 7-5:

[root@localhost ~]# rpm -q httpd
httpd-2.4.6-90.el7.centos.x86_64
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost html]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33  ifdown-ppp       ifup-ib      ifup-Team
ifcfg-lo     ifdown-routes    ifup-ippp    ifup-TeamPort
[root@localhost network-scripts]# cp ifcfg-lo ifcfg-lo:0
[root@localhost network-scripts]# vim ifcfg-lo:0
//Delete everything you don't need and make the following changes
DEVICE=lo:0
IPADDR=192.168.100.10
NETMASK=255.255.255.0
ONBOOT=yes
//Input after modification: wq save exit
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# echo "this is benet web" > index.html
[root@localhost network-scripts]# cd /etc/init.d/
[root@localhost init.d]# vim web.sh
#!/bin/bash
VIP=192.168.100.10
case "$1" in
start)
    /sbin/ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP
    /sbin/route add -host $VIP dev lo:0
    echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
    echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
    sysctl -p >/dev/null 2>&1
    echo "RealServer Start OK"
    ;;
stop)
    /sbin/ifconfig lo:0 down
    /sbin/route del $VIP /dev/null 2>&1
    echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
    echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
    echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
    echo "RealServer Stoped"
    ;;
*)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac
exit 0
//Input after modification: wq save exit
[root@localhost init.d]# chmod +x web.sh 
[root@localhost init.d]# service web.sh start 
RealServer Start OK 
[root@localhost init.d]# ifup lo:0
[root@localhost html]# firefox "http://127.0.0.1" &
[1] 8767    //Process Number Random
//Firefox browser will automatically execute in the background, the process is 8767, the browser will automatically pop up, will show the content of the web page we wrote before          

!

Restart script:

[root@localhost init.d]# service web.sh stop
SIOCDELRT: No such device
RealServer Stopd
[1]+  complete                  firefox "http://127.0.0.1"
[root@localhost init.d]# service web.sh start 
RealServer Start OK 

Verify LVS using the win7-1 client:

Set the network card to host-only and bind the gateway ipv4 to a static address:

C:\Users\zhou>ping 192.168.100.10
 Ping 192.168.100.10 with 32 bytes of data:
Reply from 192.168.100.10: Byte=32 Time <1ms TTL=64
 Reply from 192.168.100.10: Byte=32 Time <1ms TTL=64
 Reply from 192.168.100.10: Byte=32 Time=1ms TTL=64
 Reply from 192.168.100.10: Byte=32 Time=1ms TTL=64

Ping statistics for 192.168.100.10:
    Packet: sent = 4, received = 4, lost = 0 (0% lost),
Estimated round-trip time in milliseconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

Test Dispatch Server CentOS 7-2 connectivity with two web servers:

[root@localhost init.d]# ping 192.168.100.111
PING 192.168.100.111 (192.168.100.111) 56(84) bytes of data.
64 bytes from 192.168.100.111: icmp_seq=1 ttl=64 time=0.433 ms
64 bytes from 192.168.100.111: icmp_seq=2 ttl=64 time=0.501 ms
64 bytes from 192.168.100.111: icmp_seq=3 ttl=64 time=1.10 ms
^C
--- 192.168.100.111 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.433/0.681/1.109/0.303 ms

[root@localhost init.d]# ping 192.168.100.112
PING 192.168.100.112 (192.168.100.112) 56(84) bytes of data.
64 bytes from 192.168.100.112: icmp_seq=1 ttl=64 time=0.885 ms
64 bytes from 192.168.100.112: icmp_seq=2 ttl=64 time=0.883 ms
64 bytes from 192.168.100.112: icmp_seq=3 ttl=64 time=0.973 ms
^C
--- 192.168.100.112 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.883/0.913/0.973/0.054 ms
//The status is reachable, indicating that the configuration is OK

In the browser for win7-1, type: http://192.168.100.10/this will be shown first is benet web, refreshing again will show this is accp web, at this time LVS load balancing is successful!


Schedule keepalived operations on server CentOS 7-2:

[root@localhost init.d]# cd /etc/keepalived/
[root@localhost keepalived]# ls
keepalived.conf
[root@localhost keepalived]# vim keepalived.conf 
//Above Omit Multiple Lines
smtp_server 127.0.0.1
router_id LVS_01        //Change to LVS_01

vrrp_instance VI_1 {
......Omit multiple lines here
        auth_pass abc123    //Change password to abc123 after
virtual_ipaddress {
        192.168.100.10
virtual_server 192.168.100.10 80 {      //Virtual Address plus Port
    delay_loop 6
    lb_algo rr
    lb_kind DR          //Change to DR here
    persistence_timeout 50
    protocol TCP        //Modify to TCP here

    real_server 192.168.100.111 80 {        //web1 address
        weight 1
        TCP_CHECK {
            connect_port 80
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
//Here 9yy is inserted downstream and then IP can be modified
    real_server 192.168.100.112 80 {        //web2 address
        weight 1
        TCP_CHECK {
            connect_port 80
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
//Input after modification: wq save exit
[root@localhost keepalived]# systemctl start keepalived

//View network card status    
[root@localhost keepalived]# ip add show dev ens33:0
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:c2:51:f6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.101/24 brd 192.168.100.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet 192.168.100.10/32 brd 192.168.100.10 scope global ens33:0
       valid_lft forever preferred_lft forever
    inet6 fe80::6a0c:e6a0:7978:3543/64 scope link 
       valid_lft forever preferred_lft forever

Modifications on Dispatch Server CentOS 7-3:

[root@localhost keepalived]# systemctl stop firewalld.service 
[root@localhost keepalived]# setenforce 0
[root@localhost keepalived]# vim /etc/sysctl.conf 
//Insert the following below the last line
net.ipv4.ip_forward=1       //Turn on routing forwarding
net.ipv4.conf.all.send_redirects = 0        //proc response turns off redirection
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0
//Input after modification: wq save exit
[root@localhost keepalived]# Sysctl-p //Effective
net.ipv4.ip_forward = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0
[root@localhost keepalived]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0

**Create a virtual network card:**
[root@localhost ens33]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33  ifdown-ppp       ifup-ib      ifup-Team
ifcfg-lo     ifdown-routes    ifup-ippp    ifup-TeamPort
ifdown       ifdown-sit       ifup-ipv6    ifup-tunnel
......Omit multiple lines here
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33:0
[root@localhost network-scripts]# vim ifcfg-ens33:0
//Delete everything by pressing 50dd before inserting the following
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.100.10
NETMASK=255.255.255.0
//Input after modification: wq save exit
[root@localhost network-scripts]# ifup ens33:0 //Enable Virtual Network Card
ERROR     : [/etc/sysconfig/network-scripts/ifup-eth] Error, some other host (00:0C:29:C2:51:F6) already uses address 192.168.100.10.
//There will be an error. As long as we restart the network service, we can start the virtual network card again.
[root@localhost network-scripts]# service network restart 
Restarting network (via systemctl):                        [  Determine  ]
[root@localhost network-scripts]# ifup ens33:0
[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        ether 00:0c:29:c2:51:f6  txqueuelen 1000  (Ethernet)
//This is the inbound port for virtual IP and access

[root@localhost network-scripts]# cd /etc/init.d/
[root@localhost init.d]# vim dr.sh            
#!/bin/bash
GW=192.168.100.1
VIP=192.168.100.10
RIP1=192.168.100.111
RIP2=192.168.100.112 
case "$1" in
start)
        /sbin/ipvsadm --save > /etc/sysconfig/ipvsadm
        systemctl start ipvsadm
        /sbin/ifconfig ens33:0 $VIP broadcast $VIP netmask 255.255.255.255 broadcast $VIP up
        /sbin/route add -host $VIP dev ens33:0
        /sbin/ipvsadm -A -t $VIP:80 -s rr
        /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
        /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
        echo "ipvsadm starting ---------------------[ok]"
        ;;
        stop)
        /sbin/ipvsadm -C
        systemctl stop ipvsadm
        ifconfig ens33:0 down
        route del $VIP
        echo "ipvsadm stoped--------------------[ok]"
        ;;
        status)
        if [ ! -e /var/lock/subsys/ipvsadm ];then
        echo "ipvsadm stoped--------------"
        exit 1
                else
                echo "ipvsadm Runing-----------[ok]"
        fi
        ;;
        *)
        echo "Usage: $0 {start|stop|status}"
        exit 1
        ;;
        esac
        exit 0
//Input after modification: wq save exit
[root@localhost init.d]# chmod +x dr.sh 
[root@localhost init.d]# service dr.sh start
ipvsadm starting ---------------------[ok]

[root@localhost init.d]# cd /etc/keepalived/
[root@localhost keepalived]# vim keepalived.conf
   smtp_server 127.0.0.1·   //Own
   router_id LVS_02         //Number 02
   vrrp_skip_check_adv_addr

    interface eth0
virtual_router_id 10    //Change id to 10
    priority 99             //Priority below 100
    advert_int 1
    authentication {
    auth_type PASS
    auth_pass abc123    //Change Password
virtual_ipaddress {
    192.168.100.10      //Delete the other three lines and modify the IP
virtual_server 192.168.100.10 80 {      //Modify IP and Port
    delay_loop 6
    lb_algo rr
    lb_kind DR      //NAT to DR
    persistence_timeout 50
    protocol TCP

    real_server 192.168.100.111 80 {        //web1 address
        weight 1
        TCP_CHECK {                         //The following 8dd deletes 8 lines
            connect_port 80                 //Add this line
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
//Here 9yy is inserted downstream and then IP can be modified
    real_server 192.168.100.112 80 {        //web2 address
        weight 1
        TCP_CHECK {
            connect_port 80
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
//Input after modification: wq save exit
[root@localhost keepalived]# systemctl start keepalived      

keepalived dual machine hot standby verification:

1. Shut down the dispatch server 1:CentOS 7-1 service: ifdown ens33:0

2. Return to the win7 client and use the cmd command prompt ping:192.168.100.10. If you can ping now, keep alived hot standby is on top

The test is successful at this time!

Tags: MySQL network CentOS vim Firefox

Posted on Thu, 28 Nov 2019 12:10:04 -0800 by chrisio