Keepalived实现LVS高可用

news2024/9/24 17:15:53

6.1 Keepalived+LVS集群介绍

  • Keepalived和LVS共同构建了一个高效的负载均衡和高可用性解决方案:LVS作为负载均衡器,负责在集群中的多个服务器间分配流量,以其高性能和可扩展性确保应用程序能够处理大量的并发请求;而Keepalived则作为高可用性保证,通过VRRP协议监控LVS服务的状态并在主服务器发生故障时自动进行故障转移,确保服务的持续可用性和无感知切换。这种结合利用了两者的优势,为关键的网络服务提供了一个稳定、可靠且高效的运行环境。

image-20240506100440332

机器名称IP地址子网掩码说明
Keepalived-01192.168.110.31255.255.255.0负载均衡+高可用
Keepalived-02192.168.110.32255.255.255.0负载均衡+高可用
RS1192.168.110.33255.255.255.0真实服务器1
RS2192.168.110.34255.255.255.0真实服务器2
Client192.168.110.35255.255.255.0客户端

6.2 后端RS配置

  • 配置系统服务脚本

[root@LVS-RS1 ~]# vim /etc/init.d/LVS_RS
#!/bin/bash
​
# Startup script to handle the initialisation of LVS
# chkconfig: - 28 72
# description: Initialise the Linux Virtual Server for DR
# Provides: ipvsadm
# Required-Start: $local_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Short-Description: Initialise the Linux Virtual Server
# Description: The Linux Virtual Server is a highly scalable and highly
# available server built on a cluster of real servers, with the load
# balancer running on Linux.LOCK=/var/lock/ipvsadm.lock
VIP=192.168.110.10
​
. /etc/rc.d/init.d/functions
​
start() {
    PID=`ifconfig | grep lo:20 | wc -l`
    if [ $PID -ne 0 ]; then
        echo "The LVS-DR-RIP Server is already running !"
    else
        /sbin/ifconfig lo:20 $VIP netmask 255.255.255.255 broadcast $VIP up
        /sbin/route add -host $VIP dev lo:20
        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
        /bin/touch $LOCK
        echo "starting LVS-DR-RIP server is ok !"
    fi
}
​
stop() {
    /sbin/route del -host $VIP dev lo:20
    /sbin/ifconfig lo:20 down >/dev/null
    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
    rm -rf $LOCK
    echo "stopping LVS-DR-RIP server is ok !"
}
​
status() {
    if [ -e $LOCK ]; then
        echo "The LVS-DR-RIP Server is already running !"
    else
        echo "The LVS-DR-RIP Server is not running !"
    fi
}
​
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    status)
        status
        ;;
    *)
        echo "Usage: $1 {start|stop|restart|status}"
        exit 1
esac
exit 0
​
[root@LVS-RS1 ~]# chmod +x /etc/init.d/LVS_RS 
[root@LVS-RS1 ~]# chkconfig --add LVS_RS 
[root@LVS-RS1 ~]# systemctl start LVS_RS.service 
[root@LVS-RS1 ~]# scp /etc/init.d/LVS_RS 192.168.110.34:/etc/init.d/   #发给另一台RS
​
[root@LVS-RS2 ~]# chmod +x /etc/init.d/LVS_RS 
[root@LVS-RS2 ~]# chkconfig --add LVS_RS 
[root@LVS-RS2 ~]# systemctl start LVS_RS.service 

6.3 Keepalived配置

6.3.1 基于TCP的健康检测

6.3.1.1 Keepalived-01配置
[root@Keepalived-01 ~]# cp /etc/keepalived/keepalived.conf{,.bak}
[root@Keepalived-01 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
​
global_defs {
   router_id LVS_node1
}
​
vrrp_instance LVS {
    state MASTER
    interface ens160
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.110.10
    }
}
​
virtual_server 192.168.110.10 80 {
    delay_loop 6  
    lb_algo rr
    lb_kind DR
    protocol TCP
​
        real_server 192.168.110.33 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
        real_server 192.168.110.34 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}
​
​
[root@Keepalived-01 ~]# systemctl start keepalived.service
[root@Keepalived-01 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.33:80            Route   1      0          0         
  -> 192.168.110.34:80            Route   1      0          0 
6.3.1.2 Keepalived-02配置
[root@Keepalived-02 ~]# cp /etc/keepalived/keepalived.conf{,.bak}
[root@Keepalived-02 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
​
global_defs {
   router_id LVS_node2
}
​
vrrp_instance LVS {
    state MASTER
    interface ens160
    virtual_router_id 51
    priority 80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.110.10
    }
}
​
virtual_server 192.168.110.10 80 {
    delay_loop 6  
    lb_algo rr
    lb_kind DR
    protocol TCP
​
        real_server 192.168.110.33 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
        real_server 192.168.110.34 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}
​
[root@Keepalived-02 ~]# systemctl start keepalived.service
[root@Keepalived-02 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.33:80            Route   1      0          0         
  -> 192.168.110.34:80            Route   1      0          0         
6.3.1.3 访问测试
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
6.3.1.4 模拟故障转移
[root@Keepalived-01 ~]# systemctl stop keepalived.service
​
[root@Keepalived-02 ~]# ip address show ens160   #VIP漂移到Keepalived-02
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b0:0d:30 brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.110.32/24 brd 192.168.110.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 192.168.110.10/32 scope global ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feb0:d30/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
​
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done  #访问正常
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
​
[root@Keepalived-01 ~]# systemctl start keepalived.service
[root@Keepalived-01 ~]# ip address show ens160     #恢复后回来
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:d1:a9:eb brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.110.31/24 brd 192.168.110.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 192.168.110.10/32 scope global ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fed1:a9eb/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
6.3.1.5 后端服务器故障
[root@LVS-RS1 ~]# systemctl stop nginx.service
​
[root@Keepalived-02 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.34:80            Route   1      0          9   
  
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done    #访问正常
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2

6.3.2 基于HTTP的健康检测

6.3.2.1 生成远程网页的MD5哈希值
  • genhash 是一个命令行工具,用于生成远程网页的MD5哈希值。它可以用于监控HTTP和HTTPS服务,特别是在Keepalived配置中,用于健康检查。genhash 可以通过HTTP或HTTPS连接到网页,并生成页面数据的MD5哈希值,该哈希值可以在Keepalived配置文件中使用。

[root@Keepalived-01 ~]# genhash -s 192.168.110.33 -p 80 -u /index.html
MD5SUM = fd0508d1ccc6c66c14977e54ffc7faef
​
[root@Keepalived-01 ~]# genhash -s 192.168.110.34 -p 80 -u /index.html
MD5SUM = 0632aaa5fb77608b1a4736d47aacb62c
​
[root@Keepalived-02 ~]# genhash -s 192.168.110.33 -p 80 -u /index.html
MD5SUM = fd0508d1ccc6c66c14977e54ffc7faef
​
[root@Keepalived-02 ~]# genhash -s 192.168.110.34 -p 80 -u /index.html
MD5SUM = 0632aaa5fb77608b1a4736d47aacb62c
6.3.2.2 Keepalived-01配置
[root@Keepalived-01 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
​
global_defs {
   router_id LVS_node1
}
​
vrrp_instance LVS {
    state MASTER
    interface ens160
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.110.10
    }
}
virtual_server 192.168.110.10 80 {
    delay_loop 6  
    lb_algo rr
    lb_kind DR
    protocol TCP
​
        real_server 192.168.110.33 80 {
        weight 1
​
        HTTP_GET {
        url {
                path /index.html
                digest fd0508d1ccc6c66c14977e54ffc7faef
        }
        connect_timeout 3
        nb_get_retry 3
        delay_before_retry 3
        }
    }
        real_server 192.168.110.34 80 {
        weight 1
        HTTP_GET {
        url {
                path /index.html
                digest 0632aaa5fb77608b1a4736d47aacb62c
​
        }
        connect_timeout 3
        nb_get_retry 3
        delay_before_retry 3
        }
    }
}
​
[root@Keepalived-01 ~]# systemctl start keepalived.service
[root@Keepalived-01 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.33:80            Route   1      0          0         
  -> 192.168.110.34:80            Route   1      0          0     
6.3.2.3 Keepalived-02配置
[root@Keepalived-02 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
​
global_defs {
   router_id LVS_node2
}
​
vrrp_instance LVS {
    state MASTER
    interface ens160
    virtual_router_id 51
    priority 80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.110.10
    }
}
virtual_server 192.168.110.10 80 {
    delay_loop 6  
    lb_algo rr
    lb_kind DR
    protocol TCP
​
        real_server 192.168.110.34 80 {
        weight 1
​
        HTTP_GET {
        url {
                path /index.html
                digest fd0508d1ccc6c66c14977e54ffc7faef
        }
        connect_timeout 3
        nb_get_retry 3
        delay_before_retry 3
        }
    }
        real_server 192.168.110.34 80 {
        weight 1
        HTTP_GET {
        url {
                path /index.html
                digest 0632aaa5fb77608b1a4736d47aacb62c
​
        }
        connect_timeout 3
        nb_get_retry 3
        delay_before_retry 3
        }
    }
}
​
​
[root@Keepalived-02 ~]# systemctl start keepalived.service
[root@Keepalived-02 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.33:80            Route   1      0          0         
  -> 192.168.110.34:80            Route   1      0          0     
6.3.2.4 访问测试
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
6.3.2.5 模拟故障转移
[root@Keepalived-01 ~]# systemctl stop keepalived.service
​
[root@Keepalived-02 ~]# ip address show ens160   #VIP漂移到Keepalived-02
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b0:0d:30 brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.110.32/24 brd 192.168.110.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 192.168.110.10/32 scope global ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feb0:d30/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
​
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done  #访问正常
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
​
[root@Keepalived-01 ~]# systemctl start keepalived.service
[root@Keepalived-01 ~]# ip address show ens160     #恢复后回来
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:d1:a9:eb brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.110.31/24 brd 192.168.110.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 192.168.110.10/32 scope global ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fed1:a9eb/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
6.3.2.6 后端服务器故障
[root@LVS-RS1 ~]# systemctl stop nginx.service
​
[root@Keepalived-01 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.34:80            Route   1      0          6  
  
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2

6.3.3 Keepalived健康检查(MISC方式)

6.3.3.1 编写健康脚本
[root@Keepalived-01 ~]# vim /etc/keepalived/chk_web.sh
#!/bin/bash
  
# 检查传入的参数数量是否正确
if [ $# -ne 2 ]; then
    echo "Error, Parameter error"
    exit 1
else
    # 使用 nmap 进行端口扫描,获取端口状态
    n=$(nmap -Pn -p$2 -sS -vv $1 | grep "^$2" | awk '{print $2}')
​
    # 判断端口是否开放
    if [ "$n" = "open" ]; then
        exit 0
    else
        exit 1
    fi
fi
​
[root@Keepalived-01 ~]# chmod +x /etc/keepalived/chk_web.sh 
[root@Keepalived-01 ~]# scp /etc/keepalived/chk_web.sh 192.168.110.32:/etc/keepalived/
6.3.3.2 keepalived-01配置
[root@Keepalived-01 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
​
global_defs {
   router_id LVS_node1
}
​
vrrp_instance LVS {
    state MASTER
    interface ens160
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.110.10
    }
}
​
virtual_server  192.168.110.10  80 {
    delay_loop  6
    lb_algo rr
    lb_kind DR
    protocol TCP
​
    real_server  192.168.110.33  80 {
        weight  1
        MISC_CHECK {
            misc_path "/etc/keepalived/chk_web.sh  192.168.110.33  80"
            misc_timeout  3
        }
    }
​
    real_server  192.168.110.34  80 {
        weight  1
        MISC_CHECK {
            misc_path "/etc/keepalived/chk_web.sh  192.168.110.34  80"
            misc_timeout  3
        }
    }
}
​
​
[root@Keepalived-01 ~]# systemctl start keepalived.service
[root@Keepalived-01 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.33:80            Route   1      0          0         
  -> 192.168.110.34:80            Route   1      0          0  
6.3.3.3 keepalived-02配置
[root@Keepalived-02 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
​
global_defs {
   router_id LVS_node2
}
​
vrrp_instance LVS {
    state MASTER
    interface ens160
    virtual_router_id 51
    priority 80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.110.10
    }
}
​
virtual_server  192.168.110.10  80 {
    delay_loop  6
    lb_algo rr
    lb_kind DR
    protocol TCP
​
    real_server  192.168.110.33  80 {
        weight  1
        MISC_CHECK {
            misc_path "/etc/keepalived/chk_web.sh  192.168.110.33  80"
            misc_timeout  3
        }
    }
​
    real_server  192.168.110.34  80 {
        weight  1
        MISC_CHECK {
            misc_path "/etc/keepalived/chk_web.sh  192.168.110.34  80"
            misc_timeout  3
        }
    }
}
​
[root@Keepalived-02 ~]# systemctl start keepalived.service 
6.3.3.4 访问测试
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
6.3.3.5 模拟故障转移
[root@Keepalived-01 ~]# systemctl stop keepalived.service
​
[root@Keepalived-02 ~]# ip address show ens160   #VIP漂移到Keepalived-02
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b0:0d:30 brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.110.32/24 brd 192.168.110.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 192.168.110.10/32 scope global ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feb0:d30/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
​
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done  #访问正常
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.33  Host=LVS-RS1
This is LVS test IP=192.168.110.34  Host=LVS-RS2
​
[root@Keepalived-01 ~]# systemctl start keepalived.service
[root@Keepalived-01 ~]# ip address show ens160     #恢复后回来
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:d1:a9:eb brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.110.31/24 brd 192.168.110.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 192.168.110.10/32 scope global ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fed1:a9eb/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
6.3.3.6 后端服务器故障
[root@LVS-RS1 ~]# systemctl stop nginx.service
​
[root@Keepalived-01 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.110.10:80 rr
  -> 192.168.110.34:80            Route   1      0          6  
  
[root@Client ~]# for ((i=1;i<=6;i++)); do curl http://192.168.110.10; done
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2
This is LVS test IP=192.168.110.34  Host=LVS-RS2

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1644888.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

启发式算法解魔方——python

未完待续&#xff0c;填坑ing…… 魔方操作的表示——辛马斯特标记 辛马斯特标记&#xff08;Singmaster Notation&#xff09;是一种用于描述魔方和类似拼图的转动操作的标记系统。它以大卫辛马斯特&#xff08;David Singmaster&#xff09;的名字命名&#xff0c;辛马斯特…

商城数据库88张表结构完整示意图81~88及总览图(十六)

八十一&#xff1a; 八十二&#xff1a; 八十三&#xff1a; 八十四&#xff1a; 八十五&#xff1a; 八十六&#xff1a; 八十七&#xff1a; 八十八&#xff1a; 总览图&#xff1a;

JVM调优--理论篇

在对Java应用进行性能优化时&#xff0c;JVM的调优是一个绕不开的话题。本文重点介绍下如何对JVM进行调优&#xff0c;以期提高Java应用的性能、稳定性、响应时间等性能目标。JVM的调优过程符合Java应用的调优过程&#xff0c;主要分为三步&#xff1a;性能监控、性能分析、性能…

MES系统:优化生产执行,实现高效、灵活的制造管理

MES系统作为操作执行层可以缩短排产周期&#xff0c;解决紧急插单问题&#xff1b;通过计划、采集、管控等功能来改进生产执行&#xff1b;与实际生产即时接轨车间时间驱动上层的商务活动。 MES系统包含基础数据、物料和工艺管理、生产过程管理、APS排产、人员管理、设备与工具…

CPU炼丹——YOLOv5s

1.Anaconda安装与配置 1.1安装与配置 Anaconda3的安装看下面的教程&#xff1a; 最新Anaconda3的安装配置及使用教程&#xff08;详细过程&#xff09;http://t.csdnimg.cn/yygXD&#xff0c;接上面文章下载后&#xff0c;配置环境变量的时候记得在原来你装的Python更下面添…

详解LLMOps,将DevOps用于大语言模型开发

大家好&#xff0c;在机器学习领域&#xff0c;随着技术的不断发展&#xff0c;将大型语言模型&#xff08;LLMs&#xff09;集成到商业产品中已成为一种趋势&#xff0c;同时也带来了许多挑战。为了有效应对这些挑战&#xff0c;数据科学家们转向了一种新型的DevOps实践LLM-OP…

质因数分解(cpp实现)--一种快速求得一个数有多少个因子的黑魔法

前言 最近机试没少吃不会质因数分解的亏&#xff0c;用传统的求得因子个数只能过一点点…(ex, 20%) 质因数分解后&#xff0c;可以将因子问题转化为 集合的组合问题&#xff0c;因此会很快&#xff0c;目测是 l o g n log n logn (n是该整数的值)。 传统解法 假设输入整数的…

【JavaEE网络】从数据链路层到应用层的DNS

目录 数据链路层以太网 DNS 数据链路层 越往下与程序员越远 代表协议&#xff1a;以太网。平常用的网线也叫“以太网线”&#xff0c;平常用的交换机也叫“以太网交换机” 以太网 认识以太网 “以太网” 不是一种具体的网络&#xff0c;而是一种技术标准&#xff1b;既包含…

MySql#MySql安装和配置

目录 一、卸载不需要的环境 二、安装mysql yum 源 三、开始安装 四、如果保证安装成功呢&#xff1f; 五、MySql 启动&#xff01; 六、登录mysql 七、配置文件说明 八、设置开机启动&#xff01; 本次安装是在Linux环境在centos7中完成 首先先将自己切换成root 一、…

【EI会议|稳定检索】2024年能源资源与动力、控制工程国际会议(ICERPCE 2024)

2024 International Conference on Energy Resources and Power, Control Engineering 一、大会信息 会议名称&#xff1a;2024年能源资源与动力、控制工程国际会议 会议简称&#xff1a;ICERPCE 2024 收录检索&#xff1a;提交Ei Compendex,CPCI,CNKI,Google Scholar等 会议官…

深入解析算法效率核心:时间与空间复杂度概览及优化策略

算法复杂度&#xff0c;即时间复杂度与空间复杂度&#xff0c;衡量算法运行时资源消耗。时间复杂度反映执行时间随数据规模增长的关系&#xff0c;空间复杂度表明额外内存需求。优化策略&#xff0c;如选择合适数据结构、算法改进、循环展开等&#xff0c;对于提升程序效率、减…

【高阶数据结构(一)】并查集详解

&#x1f493;博主CSDN主页:杭电码农-NEO&#x1f493;   ⏩专栏分类:高阶数据结构专栏⏪   &#x1f69a;代码仓库:NEO的学习日记&#x1f69a;   &#x1f339;关注我&#x1faf5;带你学习更多Go语言知识   &#x1f51d;&#x1f51d; 高阶数据结构 1. 前言2. 并查集…

【vue+echarts】绘制中国地图,3D地图,省、市、县三级下钻以及回钻,南海诸岛小窗化显示,点位飞线图,点位名称弹窗轮播展示,及一些常见问题

先看效果展示图 目录 准备工作一, 绘制3D地图1,调用官网地址接口获取2,去官网下载中国地图的json数据到本地,本地引入 二, 南海诸岛小窗化显示1, 手动过滤掉,只保留小窗化的南海诸岛2, 代码层面过滤掉,只保留小窗化的南海诸岛 三, 省、市、县三级地图下钻及回钻1, 下钻2, 回钻…

深度学习 --- stanford cs231学习笔记(一)

stanford cs231学习笔记(一) 1&#xff0c;先是讲到了机器学习中的kNN算法&#xff0c;然后因为kNN分类器的一些弊端&#xff0c;引入了线性分类器。 kNN算法的三大弊端&#xff1a; (1)&#xff0c;计算量大&#xff0c;当特征比较多时表示性差 (2)&#xff0c;训练时耗时少…

C++初阶之模板初阶

一、泛型编程 如何实现一个通用的交换函数呢&#xff1f; void Swap(int& left, int& right) {int temp left;left right;right temp; } void Swap(double& left, double& right) {double temp left;left right;right temp; } void Swap(char& left,…

sql编写规范(word原件)

编写本文档的目的是保证在开发过程中产出高效、格式统一、易阅读、易维护的SQL代码。 1 编写目的 2 SQL书写规范 3 SQL编写原则 软件全套资料获取进主页或者本文末个人名片直接获取。

[Java、Android面试]_22_APP启动流程(中频问答)

欢迎查看合集&#xff1a; Java、Android面试高频系列文章合集 本人今年参加了很多面试&#xff0c;也有幸拿到了一些大厂的offer&#xff0c;整理了众多面试资料&#xff0c;后续还会分享众多面试资料。 整理成了面试系列&#xff0c;由于时间有限&#xff0c;每天整理一点&am…

偏微分方程算法之混合边界条件下的差分法

目录 一、研究目标 二、理论推导 三、算例实现 四、结论 一、研究目标 我们在前几节中介绍了Poisson方程的边值问题&#xff0c;接下来对椭圆型偏微分方程的混合边值问题进行探讨&#xff0c;研究对象为&#xff1a; 其中&#xff0c;为矩形区域&#xff0c;为上的连续函数…

毕业设计参考-PyQt5-YOLOv8-鱼头鱼尾鱼长测量程序,OpenCV、Modbus通信、YOLO目标检测综合应用

“PyQt5-YOLOv8-鱼头鱼尾鱼长测量程序”是一个特定的软件程序&#xff0c;用于通过图像处理和目标检测技术来测量鱼类的长度。 视频效果&#xff1a; 【毕业设计】基于yolo算法与传统机器视觉的鱼头鱼尾识别_哔哩哔哩_bilibili 这个程序结合了多种技术&#xff1a; 1. OpenCV…

【数据结构(邓俊辉)学习笔记】列表03——有序列表

文章目录 0. 概述1. 唯一化2. 查找2.1 实现2.2 顺序查找2.3 复杂度 0. 概述 介绍下有序列表。 若列表中所有节点的逻辑次序与其大小次序完全一致&#xff0c;则称作有序列表&#xff08;sorted list&#xff09;。为保证节点之间可以定义次序&#xff0c;依然假定元素类型T直接…