前置环境准备
文件系统环境要求
文件系统环境所要求的扇区必须为512bytes,查看方法如下:
[root@devops-core-highapp3-b-32 ~]#df -h /apps/
[root@devops-core-highapp3-b-32 ~]#ll /dev/mapper/vg--docker-lvapp
[root@devops-core-highapp3-b-32 ~]#fdisk -l /dev/dm-2
注意:如上图所示,Sector size 为扇区的大小,必须是512 bytes。
系统环境优化
检查root 是否禁止登录
以root 用户执行
vi /etc/ssh/sshd_config
PermitRootLogin yes
如果没有这条参数,请添加,如果 PermitRootLogin 的值不是yes,请改为 yes(请预留其他账号可以登录,否则可能会造成系统无法登录问题)。
检查kernel 版本
注意:BC-Linux 7.6 版本内核建议为3.10.0-957.el7.x86_64,BC-Linux 7.8 版本根据测试也
满足安装要求,内核版本建议为4.19.25-204.el7.bclinux.x86_64。
cat /etc/redhat-release
uname -r
关闭selinux
修改 /etc/selinux/config 文件
vim /etc/selinux/config
修改内容:
SELINUX=disabled
# 关闭selinux
setenforce 0
关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
设置字符集
修改 /etc/profile 文件
vim /etc/profile
文件中新增一下内容(如果已存在新增的内容请作修改)
export LANG=en_US.UTF-8
关闭swap 交换内存
swapoff -a
内核参数优化
修改文件:/etc/sysctl.conf
vi /etc/sysctl.conf
修改或增加一下内容:
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1 #根据操作系统内核版本设置,参见如下注意
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.ipv4.ip_local_port_range = 26000 65535
kernel.sem = 250 6400000 1000 25600
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 52805669 #根据实际情况进行计算
kernel.shmmax = 18446744073692774399 #根据实际情况进行计算
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
vm.swappiness = 0
修改完成之后请执行以下命令让其生效
sysctl -p
注意:
1)kernel.shmall 和kernel.shmmax 需根据主机操作系统的内存配置进行自定义调整,一般
shmmax 建议设置为主机物理内存的60%,shmall >= shmmax/4096。例如主机100G 内存,
shmmax=100G60%102410241024= 64424509440 , shmall= 64424509440/4096=
15728640。
2)如果使用BC-Linux 7.6 版本(内核为3.10.0-957.el7.x86_64),net.ipv4.tcp_tw_recycle =
1 参数可以设置;如果使用BC-Linux 7.8 版本(内核为4.19.25-204.el7.bclinux.x86_64),
net.ipv4.tcp_tw_recycle = 1 参数需删除。
配置资源限制
修改文件 /etc/security/limits.