高可用架构二基于HAProxy+Keepalived高可用负载均衡web服务的搭建
Posted python运维实践
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了高可用架构二基于HAProxy+Keepalived高可用负载均衡web服务的搭建相关的知识,希望对你有一定的参考价值。
一.高可用
1.1.什么是高可用?
计算机系统的可用性(availability)是通过系统的可靠性(reliability)和可维护性(maintainability)来度量的。 工程上通常用平均无故障时间(MTTF)来度量系统的可靠性,用平均维修时间(MTTR)来度量系统的可维护性。 于是可用性被定义为: MTTF/(MTTF+MTTR)*100%
2)HA的容错备援运作过程自动侦测(Auto-Detect)阶段 由主机上的软件通过冗余侦测线,经由复杂的监听程序。逻辑判断,来相互侦测对方运行的情况,所检查的项目有:主机硬件(CPU和周边)、主机网络、主机操作系统、数据库引擎及其它应用程序、主机与磁盘阵列连线。为确保侦测的正确性,而防止错误的判断,可设定安全侦测时间,包括侦测时间间隔,侦测次数以调整安全系数,并且由主机的冗余通信连线,将所汇集的讯息记录下来,以供维护参考。 自动切换(Auto-Switch)阶段 某一主机如果确认对方故障,则正常主机除继续进行原来的任务,还将依据各种容错备援模式接管预先设定的备援作业程序,并进行后续的程序及服务。 自动恢复(Auto-Recovery)阶段 在正常主机代替故障主机工作后,故障主机可离线进行修复工作。在故障主机修复后,透过冗余通讯线与原正常主机连线,自动切换回修复完成的主机上。整个回复过程完成由EDI-HA自动完成,亦可依据预先配置,选择回复动作为半自动或不回复。
1.2.HA三种工作方式:
(1)主从方式 (非对称方式)工作原理:主机工作,备机处于监控准备状况;当主机宕机时,备机接管主机的一切工作,待主机恢复正常后,按使用者的设定以自动或手动方式将服务切换到主机上运行,数据的一致性通过共享存储系统解决。(2)双机双工方式(互备互援)工作原理:两台主机同时运行各自的服务工作且相互监测情况,当任一台主机宕机时,另一台主机立即接管它的一切工作,保证工作实时,应用服务系统的关键数据存放在共享存储系统中。(3)集群工作方式(多服务器互备方式)工作原理:多台主机一起工作,各自运行一个或几个服务,各为服务定义一个或多个备用主机,当某个主机故障时,运行在其上的服务就可以被其它主机接管。
二.集群
2.1 什么是集群?
简单的说,集群(cluster)就是一组计算机,它们作为一个整体向用户提供一组网络资源。这些单个的计算机系统就是集群的节点(node)。 更详细的说,集群(一组协同工作的计算机)是充分利用计算资源的一个重要概念,因为它能够将工作负载从一个超载的系统(或节点)迁移到集群中的另一个系统上。其处理能力是与专用计算机(小型机,大型机)可相比,但其性价比高于专用计算机. 常见的硬件有:结点,网络,存储,软件有:机群系统,节点系统,应用支撑软件。 Cluster集群技术可如下定义:一组相互独立的服务器在网络中表现为单一的系统,并以单一系统的模式加以管理。此单一系统为客户工作站提供高可靠性的服务。大多数模式下,集群中所有的计算机拥有一个共同的名称,集群内任一系统上运行的服务可被所有的网络客户所使用。Cluster必须可以协调管理各分离的组件的错误和失败,并可透明地向Cluster中加入组件。一个Cluster包含多台(至少二台)拥有共享数据存储空间的服务器。任何一台服务器运行一个应用时,应用数据被存储在共享的数据空间内。每台服务器的操作系统和应用程序文件存储在其各自的本地储存空间上。Cluster内各节点服务器通过一内部局域网相互通讯。当一台节点服务器发生故障时,这台服务器上所运行的应用程序将在另一节点服务器上被自动接管。当一个应用服务发生故障时,应用服务将被重新启动或被另一台服务器接管。当以上的任一故障发生时,客户都将能很快连接到新的应用服务上。
2.2 集群系统的主要优点:
(1)高可扩展性:
(2)高可用性HA:集群中的一个节点失效,它的任务可传递给其他节点。可以有效防止单点失效。
(3)高性能:负载平衡集群允许系统同时接入更多的用户。
(4)高性价比:可以采用廉价的符合工业标准的硬件构造高性能的系统。
2.3 集群系统的分类
虽然,根据集群系统的不同特征可以有多种分类方法,但是一般把集群系统分为两类:
(1)高可用(High Availability)集群,简称HA集群。 这类集群致力于提供高度可靠的服务。就是利用集群系统的容错性对外提供7*24小时不间断的服务,如高可用的文件服务器、数据库服务等关键应用。 负载均衡集群:使任务可以在集群中尽可能平均地分摊不同的计算机进行处理,充分利用集群的处理能力,提高对任务的处理效率。 在实际应用中这几种集群类型可能会混合使用,以提供更加高效稳定的服务。如在一个使用的网络流量负载均衡集群中,就会包含高可用的网络文件系统、高可用的网络服务。
(2)、性能计算(High Perfermance Computing)集群,简称HPC集群,也称为科学计算集群。 在这种集群上运行的是专门开发的并行应用程序,它可以把一个问题的数据分布到多台的计算机上,利用这些计算机的共同资源来完成计算任务,从而可以解决单机不能胜任的工作(如问题规模太大,单机计算速度太慢)。 这类集群致力于提供单个计算机所不能提供的强大的计算能力。如天气预报、石油勘探与油藏模拟、分子模拟、生物计算等。
三.Keepalived
3.1简介
Keepalived的作用是检测服务器的状态,如果有一台web服务器宕机,或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替该服务器的工作,当服务器工作正常后Keepalived自动将服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人工做的只是修复故障的服务器。
3.2原理
3.3作用
主要用作RealServer的健康状态检查以及LoadBalance主机和BackUP主机之间failover的实现。
四.实现架构
场景说明:
1.服务器操作系统
5台服务器均为centos7.3操作系统
2.应用软件
[root@node01 ~]# rpm -qa | grep haproxy
haproxy-1.5.18-7.el7.x86_64
[root@node01 /]# rpm -qa | grep keepalived
keepalived-1.3.5-6.el7.x86_64
[root@node01 /]#
[root@web01 ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Apr 20 2018 18:10:38
3.服务器IP规划
负载均衡器2台: 192.168.150.71/24 192.168.150.72/24 虚拟IP: 192.168.150.70/24 Web服务器3台: 192.168.150.73/24 192.168.150.74/24 192.168.150.75/24
五.系统软件安装与部署
本次主要配置haproxy+keepalived实现高可用负载均衡的功能。 2台haproxy提供负载均衡和应用代理服务。 其中node01作为主服务器MASTER,node02作为备份服务器BACKUP。 对外表现为一个虚拟IP,主服务器会发送特定的消息给备份服务器,当备份服务器收不到这个消息的时候,即主服务器宕机的时候,备份服务器就会接管虚拟IP,继续提供服务,从而保证了高可用性。Keepalived是VRRP的完美实现。
1.安装前的准备工作
[root@node01 ~]# systemctl disable firewalld
[root@node01 ~]# systemctl stop firewalld
[root@node01 ~]#
[root@node01 ~]# vi /etc/sysconfig/selinux
This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
在备份节点上node02进行同样的操作。
2.yum方式安装haproxy和keepalived软件
在两台负载均衡服务器node01和node02上安装:
[root@node01 /]# yum install haproxy keepalived -y
已加载插件:fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
updates/7/x86_64/primary_db | 2.0 MB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
软件包 haproxy-1.5.18-7.el7.x86_64 已安装并且是最新版本
软件包 keepalived-1.3.5-6.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@node01 /]#
3.配置keepalived主节点和备份节点及通知脚本
1)主节点配置文件
[root@node01 keepalived]# pwd
/etc/keepalived
[root@node01 keepalived]# cat keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id node01
vrrp_macst_group4 224.0.100.19
}
vrrp_instance http {
state MASTER
interface enp2s0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass haopython
}
virtual_ipaddress {
192.168.150.70/24 dev enp2s0
}
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
[root@node01 keepalived]#
2)备份节点配置文件:
[root@node02 keepalived]# pwd
/etc/keepalived
[root@node02 keepalived]# ls
keepalived.conf notify.sh
[root@node02 keepalived]# cat keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id inode2
vrrp_macst_group4 224.0.100.19
}
vrrp_instance http {
state BACKUP
interface enp2s0
virtual_router_id 51
priority 98
advert_int 1
authentication {
auth_type PASS
auth_pass haopython
}
virtual_ipaddress {
192.168.150.70/24 dev enp2s0
}
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
[root@node02 keepalived]#
3)编写通知脚本 在主备份服务器上编写如下脚本 主备一样:
[root@node01 keepalived]# cat notify.sh
#!/bin/bash
#
contact='root@localhost'
notify() {
mailsubject="$(hostname) to be $1, vip floating"
mailbody="$(date +'%F %T'): vrrp transition, $(hostname) changed to be $1"
echo "$mailbody" | mail -s "$mailsubject" $contact
}
case $1 in
master)
notify master
;;
backup)
notify backup
;;
fault)
notify fault
;;
*)
echo "Usage: $(basename $0) {master|backup|fault}"
exit 1
;;
esac
[root@node01 keepalived]#
备份节点
[root@node02 keepalived]# cat notify.sh
#!/bin/bash
#
contact='root@localhost'
notify() {
mailsubject="$(hostname) to be $1, vip floating"
mailbody="$(date +'%F %T'): vrrp transition, $(hostname) changed to be $1"
echo "$mailbody" | mail -s "$mailsubject" $contact
}
case $1 in
master)
notify master
;;
backup)
notify backup
;;
fault)
notify fault
;;
*)
echo "Usage: $(basename $0) {master|backup|fault}"
exit 1
;;
esac
[root@node02 keepalived]# pwd
/etc/keepalived
[root@node02 keepalived]#
4.配置haproxy
Node01和node02两个节点的配置是一样的
[root@node01 haproxy]# pwd
/etc/haproxy
[root@node01 haproxy]# cat haproxy.cfg
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /etc/haproxy/haproxy.cfg
maxconn 4000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend web *:80
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static1 192.168.150.73:80 check
server static2 192.168.150.74:80 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 192.168.150.73:80 check
server app2 192.168.150.74:80 check
listen stats
bind :10086
stats uri /admin?stats
stats auth admin:admin
stats admin if TRUE
[root@node01 haproxy]#
六.启动服务
[root@node01 /]# systemctl start haproxy
[root@node01 /]# systemctl start keepalived
[root@node01 /]#
[root@node02 /]# systemctl start haproxy
[root@node02 /]# systemctl start keepalived
[root@node02 /]#
七.测试服务启动情况
Node01节点:
[root@node01 /]# systemctl start keepalived
[root@node01 /]# systemctl status -l keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
Active: active (running) since 二 2018-05-29 08:49:17 CST; 55min ago
Process: 27208 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 27211 (keepalived)
CGroup: /system.slice/keepalived.service
├─27211 /usr/sbin/keepalived -D
├─27212 /usr/sbin/keepalived -D
└─27213 /usr/sbin/keepalived -D
5月 29 08:49:18 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:18 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:18 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:18 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
[root@node01 /]#
NODE02节点:
[root@node02 /]# systemctl status -l keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
Active: active (running) since 六 2018-05-26 10:26:44 CST; 2 days ago
Process: 3143 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 3144 (keepalived)
CGroup: /system.slice/keepalived.service
├─3144 /usr/sbin/keepalived -D
├─3145 /usr/sbin/keepalived -D
└─3146 /usr/sbin/keepalived -D
5月 29 08:48:36 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:48:41 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:48:41 node02 Keepalived_vrrp[3146]: VRRP_Instance(http) Sending/queueing gratuitous ARPs on enp2s0 for 192.168.150.70
5月 29 08:48:41 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:48:41 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:48:41 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:48:41 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:17 node02 Keepalived_vrrp[3146]: VRRP_Instance(http) Received advert with higher priority 100, ours 98
5月 29 08:49:17 node02 Keepalived_vrrp[3146]: VRRP_Instance(http) Entering BACKUP STATE
5月 29 08:49:17 node02 Keepalived_vrrp[3146]: VRRP_Instance(http) removing protocol VIPs.
[root@node02 /]#
NODE01节点:
[root@node01 /]# systemctl status -l haproxy
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
Active: active (running) since 二 2018-05-29 08:49:08 CST; 58min ago
Main PID: 27195 (haproxy-systemd)
CGroup: /system.slice/haproxy.service
├─27195 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
├─27197 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
└─27199 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
5月 29 08:49:08 node01 systemd[1]: Started HAProxy Load Balancer.
5月 29 08:49:08 node01 systemd[1]: Starting HAProxy Load Balancer...
5月 29 08:49:08 node01 haproxy-systemd-wrapper[27195]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
[root@node01 /]#
NODE02节点:
[root@node02 /]# systemctl status -l haproxy
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
Active: active (running) since 二 2018-05-29 08:46:45 CST; 1h 2min ago
Main PID: 8945 (haproxy-systemd)
CGroup: /system.slice/haproxy.service
├─8945 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
├─8946 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
└─8947 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
5月 29 08:46:45 node02 systemd[1]: Started HAProxy Load Balancer.
5月 29 08:46:45 node02 systemd[1]: Starting HAProxy Load Balancer...
5月 29 08:46:45 node02 haproxy-systemd-wrapper[8945]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
[root@node02 /]#
下面停掉NODE01节点,然后在NODE02上查看NODE02的状态变化
[root@node01 /]# systemctl stop haproxy
[root@node01 /]# systemctl stop keepalived
[root@node01 /]#
[root@node02 /]# systemctl status -l keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
Active: active (running) since 六 2018-05-26 10:26:44 CST; 2 days ago
Process: 3143 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 3144 (keepalived)
CGroup: /system.slice/keepalived.service
├─3144 /usr/sbin/keepalived -D
├─3145 /usr/sbin/keepalived -D
└─3146 /usr/sbin/keepalived -D
5月 29 10:00:52 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:52 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:52 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:52 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:57 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:57 node02 Keepalived_vrrp[3146]: VRRP_Instance(http) Sending/queueing gratuitous ARPs on enp2s0 for 192.168.150.70
5月 29 10:00:57 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:57 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:57 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:57 node02 Keepalived_vrrp[3146]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
[root@node02 /]#
[root@node02 /]#
[root@node02 /]# systemctl status -l haproxy
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
Active: active (running) since 二 2018-05-29 08:46:45 CST; 1h 14min ago
Main PID: 8945 (haproxy-systemd)
CGroup: /system.slice/haproxy.service
├─8945 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
├─8946 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
└─8947 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
5月 29 08:46:45 node02 systemd[1]: Started HAProxy Load Balancer.
5月 29 08:46:45 node02 systemd[1]: Starting HAProxy Load Balancer...
5月 29 08:46:45 node02 haproxy-systemd-wrapper[8945]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
[root@node02 /]#
Node01节点:
[root@node01 /]# systemctl status -l keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
Active: inactive (dead)
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 08:49:23 node01 Keepalived_vrrp[27213]: Sending gratuitous ARP on enp2s0 for 192.168.150.70
5月 29 10:00:51 node01 Keepalived[27211]: Stopping
5月 29 10:00:51 node01 systemd[1]: Stopping LVS and VRRP High Availability Monitor...
5月 29 10:00:51 node01 Keepalived_vrrp[27213]: VRRP_Instance(VI_1) sent 0 priority
5月 29 10:00:51 node01 Keepalived_vrrp[27213]: VRRP_Instance(VI_1) removing protocol VIPs.
5月 29 10:00:52 node01 Keepalived_vrrp[27213]: Stopped
5月 29 10:00:52 node01 Keepalived[27211]: Stopped Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2
5月 29 10:00:52 node01 systemd[1]: Stopped LVS and VRRP High Availability Monitor.
[root@node01 /]#
八.在浏览器中查看和修改haproxy的相关参数
学习|生活|分享|积累|永不停步
请留下你指尖的温度
让太阳拥抱你
微信ID:goodpython
以上是关于高可用架构二基于HAProxy+Keepalived高可用负载均衡web服务的搭建的主要内容,如果未能解决你的问题,请参考以下文章
RabbitMQ---集群,Haproxy+Keepalive 实现高可用负载均衡,Federation Exchange和Federation Queue
keepalive高可用haproxy实现URL资源的动静分离
实现基于Haproxy+Keepalived负载均衡高可用架构