Kubernetes安装之centos7系统配置

1. 关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

2. 关闭selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
setenforce 0 

3. 网桥过滤

vi /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 1 
net.bridge.bridge-nf-call-iptables = 1 
net.bridge.bridge-nf-call-arptables = 1 
net.ipv4.ip_forward=1 
net.ipv4.ip_forward_use_pmtu = 0

生效命令

sysctl --system

查看效果

sysctl -a|grep "ip_forward"

net.ipv4.ip_forward = 1
net.ipv4.ip_forward_use_pmtu = 0
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.docker0.stable_secret"
sysctl: reading key "net.ipv6.conf.docker_gwbridge.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.veth3a04b25.stable_secret"
sysctl: reading key "net.ipv6.conf.veth661171f.stable_secret"
sysctl: reading key "net.ipv6.conf.vethb287b07.stable_secret"
sysctl: reading key "net.ipv6.conf.vethf431ca8.stable_secret"

4. 开启IPVS

安装IPVS

yum -y install ipset ipvsdm

编辑ipvs.modules文件

vi /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

赋予权限并执行

chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules &&lsmod | grep -e ip_vs -e nf_conntrack_ipv4

重启电脑,检查是否生效

reboot

[root@rpp ~]# lsmod | grep ip_vs_rr
ip_vs_rr               12600  6 
ip_vs                 145458  13 ip_vs_rr,ip_vs_sh,xt_ipvs,ip_vs_wrr

5. 同步时间

安装软件

yum -y install ntpdate

向阿里云服务器同步时间

ntpdate time1.aliyun.com

删除本地时间并设置时区为上海

rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

查看时间

date -R || date

Thu, 03 Dec 2020 14:16:47 +0800

6. 命令补全

安装bash-completion

yum -y install bash-completion bash-completion-extras

使用bash-completion

source /etc/profile.d/bash_completion.sh

7. 关闭swap分区

临时关闭:

swapoff -a 

永久关闭:

vi /etc/fstab 

将文件中的/dev/mapper/centos-swap这行代码注释掉
#/dev/mapper/centos-swap swap swap defaults 0 0

确认swap已经关闭:若swap行都显示 0 则表示关闭成功

[root@rpp ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           3.5G        1.0G        291M        784K        2.3G        2.3G
Swap:            0B          0B          0B
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值