rpm -Uvh
# 安装完成后检查 /boot/grub2/grub.cfg 中对应内核 menuentry 中是否包含 initrd16 配置,如果没有,再安装
一次!
yum --enablerepo=elrepo-kernel install -y kernel-lt
# 设置开机从新内核启动
grub2-set-default "CentOS Linux (4.4.248-1.el7.elrepo.x86_64) 7 (Core)"
CentOS Linux (4.4.248-1.el7.elrepo.x86_64) 7 (Core)
# 重启后安装内核源文件
yum --enablerepo=elrepo-kernel install kernel-lt-devel-$(uname -r) kernel-lt-headers-$(uname -r)
关闭 NUMA
cp /etc/default/grub{,.bak}
vim /etc/default/grub # 在 GRUB_CMDLINE_LINUX 一行添加 `numa=off` 参数,如下所示:
diff /etc/default/grub.bak /etc/default/grub
< GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rhgb quiet"
cp /boot/grub2/grub.cfg{,.bak}
grub2-mkconfig -o /boot/grub2/grub.cfg
------------------------------
所有节点
kube-proxy开启ipvs的前置条件
modprobe br_netfilter
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
yum-config-manager \
--add-repo
安装 Docker 软件
yum install -y yum-utils device-mapper-persistent-data lvm2
yum update -y && yum install -y docker-ce
reboot
grub2-set-default "CentOS Linux (4.4.248-1.el7.elrepo.x86_64) 7 (Core)"
reboot
## 创建 /etc/docker 目录
mkdir /etc/docker
# 配置 daemon.
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
}
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
# 重启docker服务
systemctl daemon-reload && systemctl restart docker && systemctl enable docker
master1:
在主节点启动 Haproxy 与 Keepalived 容器
导入脚本 > 运行 > 查看可用节点
mkdir -p /usr/local/kubernetes/install
cd !$
yum install lrzsz -y
导入
haproxy.tar
keepalived.tar
kubeadm-basic.images.tar.gz
load-images.sh
start.keep.tar.gz
tar zxvf kubeadm-basic.images.tar.gz
cat load-images.sh
#!/bin/bash
cd /usr/local/kubernetes/install/kubeadm-basic.images
ls /usr/local/kubernetes/install/kubeadm-basic.images | grep -v load-images.sh > /tmp/k8s-images.txt
for i in $( cat /tmp/k8s-images.txt )
do
docker load -i $i
done
rm -rf /tmp/k8s-images.txt
chmod a+x load-images.sh
./load-images.sh
docker load -i haproxy.tar
docker load -i keepalived.tar
tar zxvf start.keep.tar.gz
修改haproxy配置文件
vim data/lb/etc/haproxy.cfg
确保先负载到第一个上,就先填写一个IP ,之后再加全
vim data/lb/start-haproxy.sh