k8s二进制安装01-基础环境设定
设置网卡IP
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <
设置主机名称
hostnamectl set-hostname m01
设定hosts文件,用于主机名解析
cat >> /etc/hosts <
安装需要的软件和工具
yum install -y wget tree bash-completion jq psmisc vim net-tools telnet git lrzsz epel-release conntrack ntpdate ntp jq curl
禁止防火墙
systemctl disable --now firewalld
禁止selinux
setenforce 0
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
禁止swap分区
swapoff -a && sysctl -w vm.swappiness=0
vim /etc/fstab
# /dev/mapper/centos-swap swap swap defaults 0 0
禁止NetworkManager服务并启用network
systemctl disable --now NetworkManager
systemctl start network && systemctl enable network
如果是Centos8,不需要禁用NetworkManager服务
设置ntp服务
## 方法一:ntpdate
## 下载ntp包并安装
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
yum -y install ntpdate
## 同步
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo 'Asia/Shanghai' >/etc/timezone
## 从阿里云同步时间
ntpdate ntp.aliyun.com
## 设定每5分钟同步一次时间
crontab -e
crontab -l
*/5 * * * * ntpdate ntp.aliyun.com
## 方法二:chrony
## 服务端
yum install chrony -y
vim /etc/chrony.conf
cat /etc/chrony.conf | grep -v "^#" | grep -v "^$"
pool ntp.aliyun.com iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
allow 192.168.10.0/24
local stratum 10
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
systemctl restart chronyd
systemctl enable chronyd
客户端
yum install chrony -y
vim /etc/chrony.conf
cat /etc/chrony.conf | grep -v "^#" | grep -v "^$"
pool 192.168.10.51 iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
systemctl restart chronyd
systemctl enable chronyd
## 使用客户端进行验证
chronyc sources -v
配置unlimit
ulimit -SHn 65535
cat <
配置免密登陆
## 生成秘钥文件,输入以下命令后,直接按2次回车键
ssh-keygen -t rsa
## 将秘钥文件拷贝需要免密登陆的主机
for i in m01 m02 m03 w01;do ssh-copy-id -i ${HOME}/.ssh/id_rsa.pub $i;done
更新系统(跳过内核)
yum update -y --exclude=kernel*
单独升级内核至4.18版本以上
cd /root/
wget http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-4.19.12-1.el7.elrepo.x86_64.rpm
wget http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpm
yum -y localinstall kernel-ml*
grub2-set-default 0 && grub2-mkconfig -o /etc/grub2.cfg && grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
reboot
uname -r
for i in m01 m02 m03 w01; do \
scp kernel-ml-* $i:/root/; \
done
安装ipvsadmin
yum install -y ipvsadm ipset sysstat conntrack libseccomp
cat > /etc/modules-load.d/ipvs.conf <
修改内核参数
cat > /etc/sysctl.d/95-k8s-sysctl.conf <