目录
3.1、配置l(b110.10.10.60)的HAProxy()
3.11、lb1的/etc/haproxy/haproxy.cfg
3.2配置l(b2 10.10.10.70)的HAProxy
3.21、lb2的/etc/haproxy/haproxy.cfg
3.3配置(lb1:10.10.10.60)的Keepalived
3.3.1、lb1的/etc/keepalived/keepalived.conf
3.4、配置l(b2:10.10.10.70)的Keepalived
3.4.1、lb2的/etc/keepalived/keepalived.conf
0、设置hosts
echo -e "10.10.10.60 lb1\n10.10.10.70 lb2\n10.10.10.88 kube-apiserver-1\n10.10.10.89 kube-apiserver-2\n10.10.10.90 kube-apiserver-3\n10.10.10.91 worker1\n10.10.10.92 worker2\n" >>/etc/hosts
0、1设置hostname
hostnamectl set-hostname 名称
1、yum源设置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum clean all && yum makecache
yum install net-tools -y
systemctl stop firewalld
systemctl disable firewalld
sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
yum install -y vim wget git
2、Yum 安装 Keepalived + HAProxy
在主机为 lb1 和 lb2 中部署 Keepalived + HAProxy 即 IP 为10.10.10.60
与10.10.10.70
的服务器上安装部署 HAProxy 和 psmisc。
安装命令
yum install keepalived haproxy psmisc -y
3、 配置Keepalived 和 HAProxy
3.1、配置l(b110.10.10.60)的HAProxy()
3.11、lb1的/etc/haproxy/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.