1、环境说明(安装时配置IP及主机名)
序号 主机IP 主机名 系统 备注
1 192.168.3.114 master rockylinux8.6最小化安装 控制节点
2 192.168.3.115 node1 rockylinux8.6最小化安装 工作节点
3 192.168.3.116 node2 rockylinux8.6最小化安装 工作节点
2、关闭selinux,firewalld及swap分区(在三台设备上执行)
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
systemctl disable firewalld
swapoff -a
reboot
注:swapoff -a 为临时关闭swap分区。永久关闭swap分区,vi /etc/fstab 注释swap分区一行
3、修改/etc/hosts文件,增加如下三行(三台设备)
192.168.3.114 master
192.168.3.115 node1
192.168.3.116 node2
4、更改yum源为阿里云(三台设备执行)
yum install dnf #安装dnf
sed -e ‘s|^mirrorlist=|#mirrorlist=|g’
-e ‘s|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g’
-i.bak
/etc/yum.repos.d/Rocky-*.repo
dnf makecache
5、配置命令补全及vim工具(三台设备执行)
dnf install -y wget bash-completion vim
6、配置免密登录(master上执行,可省)
ssh-keygen
ssh-copy-id node1
yes
ssh-copy-id node2
yes
7、配置时间同步(三台设备执行)
dnf install -y chrony
更改 /etc/chrony.conf 配置文件
将pool 2.pool.ntp.org iburst
改为
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp1.tencent.com iburst
server ntp2.tencent.com iburst
systemctl enable --now chronyd
chronyc sources
date
8、修改内核参数(三台设备上执行)
modprobe br_netfilter
lsmod | grep br_netfilter
cat > /etc/sysctl.d/k8s.conf <<EOF