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