hostnamectl set-hostname master1
hostnamectl set-hostname node1
hostnamectl set-hostname node2
vim /etc/sysconfig/network- scripts/ifcfg-ens33
systemctl restart network
ip a s
vim /etc/hosts
cat /etc/hosts
关闭firewalld
systemctl stop firewalld
systemctl disable firewalld
firewall-cmd --state
SELINUX配置
[root@XXX ~]# sed -ri ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config
主机时间同步
yum -y install ntpdate crontab -l 0 */1 * * * ntpdate time1.aliyun.com
date
永久关闭swap分区
vim /etc/fstab #在swap文件系统对应的行,行首添加#表示注释。
cat /etc/fstab
添加网桥过滤及地址转发 [root@XXX ~]# cat /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1 vm.swappiness = 0 加载br_netfilter模块 [root@XXX ~]# modprobe br_netfilter 查看是否加载 [root@XXX ~]# lsmod | grep br_netfilter br_netfilter 22256 0 bridge 151336 1 br_netfilter 加载网桥过滤配置文件 [root@XXX ~]# sysctl -p /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1 vm.swappiness = 0
安装ipset及ipvsadm
yum -y install ipset ipvsadm
在所有节点执行如下脚本
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
授权、运行、检查是否加载
[root@XXX ~]# chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
检查是否加载 [root@XXX ~]# lsmod | grep -e ipvs -e nf_conntrack_ipv4