准备环境
IP | 主机名 | 系统 |
---|---|---|
192.168.101.10 | master | centos7.9 |
192.168.101.9 | node1 | centos7.9 |
192.168.101.8 | node2 | centos7.9 |
系统初始化 (所有机器都执行)
# 1、关闭所有swap
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
# 2、关闭当前的selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
#注意:在一些云主机上,比如腾讯云,阿里云,修改过selinux且ssh端口改成非 22 后可能会导致登录不了。需要先做以下操作
# 3、关闭防火墙
iptables -F
iptables -X
iptables -Z
systemctl stop firewalld
systemctl disable firewalld
# 4、修改内核参数
echo vm.max_map_count=262144 >> /etc/sysctl.conf
echo net.ipv6.conf.all.disable_ipv6 = 1 >> /etc/sysctl.conf
echo net.ipv6.conf.default.disable_ipv6 = 1 >> /etc/sysctl.conf
echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
sysctl -p
# 5. 增加hosts
cat >> /etc/hosts