亲测国内可用
#[0. 准备工作]
# 配置主机名
hostnamectl set-hostname master01
hostnamectl set-hostname node01
hostnamectl set-hostname node02
bash
# 配置hosts文件
192.168.0.101 master01
192.168.0.102 node01
192.168.0.103 node02
sudo sh -c 'echo -e "192.168.0.101 master01\n192.168.0.102 node01\n192.168.0.103 node02" >> /etc/hosts'
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
# 关闭selinux
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
# 关闭swap
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
# 配置yum源
mv /etc/yum.repos.d/CentOS-*.repo /etc/yum.repos.d/backup/
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all
yum makecache
# 设置系统同步时间 chrony
yum install chrony -y
systemctl enable chronyd
systemctl start chronyd
# 修改 /etc/chrony.conf 文件
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp1.tencent.com iburst
server ntp2.tencent.com iburst
# 重启chronyd服务
systemctl restart chronyd
systemctl enable chronyd
chronyc sources
# 设置时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "Asia/Shanghai" > /etc/timezone
date
#[配置服务器互信]
# 生成公钥和私钥 所有服务器
ssh-keygen -t rsa
# master04
scp ~/.ssh/id_rsa.pub node02:~/.ssh/master01.pub
# node01
scp ~/.ssh/id_rsa.pub node02:~/.ssh/node01.pub
# node02:
cat ~/.ssh/master01.pu