1.关闭firewalld

[root@master ~]# systemctl stop firewalld
[root@master ~]# systemctl disable firewalld

2.关闭selinux

sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

3.禁用swap分区

编辑配置文件/etc/fstab , 注释掉swap一行

# /dev/mapper/centos-swap swap                    swap    defaults        0 0

4.修改内核参数

添加网桥过滤和地址转发功能

[root@master ~]# vim /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forwad = 1

重新加载配置

[root@master ~]# sysctl -p

加载网桥过滤模块

[root@master ~]# modprobe br-netfilter

查看网桥过滤模块是否加载成功

[root@master ~]# lsmod |grep br_netfilter

5.配置ipvs功能

[root@master ~]# yum install ipset ipvsadm -y

添加需要加载的模块写入到脚本文件

[root@master ~]# vim /etc/sysconfig/modules/ipvs.modules 

#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4

执行脚本文件

[root@master ~]# bash /etc/sysconfig/modules/ipvs.modules 

查看对应模块是否加载成功

[root@master ~]# lsmod |grep -e ip_vs -e nf_conntrack_ipv4

nf_conntrack_ipv4      15053  2 
nf_defrag_ipv4         12729  1 nf_conntrack_ipv4
ip_vs_sh               12688  0 
ip_vs_wrr              12697  0 
ip_vs_rr               12600  0 
ip_vs                 145497  6 ip_vs_rr,ip_vs_sh,ip_vs_wrr
nf_conntrack          139224  7 ip_vs,nf_nat,nf_nat_ipv4,xt_conntrack,nf_nat_masquerade_ipv4,nf_conntrack_netlink,nf_conntrack_ipv4
libcrc32c              12644  4 xfs,ip_vs,nf_nat,nf_conntrack

6.重启服务器

Last modification:March 18th, 2021 at 11:31 am
If you think my article is useful to you, please feel free to appreciate