优化CentOS Minimal系统可以从多个方面入手,包括系统更新、内核参数优化、文件描述符优化、SSH服务优化等。以下是具体的优化步骤:
yum update -y
yum install -y epel-release curl wget vim htop net-tools telnet iftop iotop lsof traceroute
/etc/sysctl.d/99-optimized.conf
文件,添加或修改以下内核参数:net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
sysctl -p /etc/sysctl.d/99-optimized.conf
/etc/security/limits.conf
文件,设置文件描述符限制:* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
/etc/ssh/sshd_config
文件,进行以下优化:sed -i 's/#port 22/port 2222/' /etc/ssh/sshd_config
sed -i 's/#logingracetime 2m/logingracetime 1m/' /etc/ssh/sshd_config
systemctl restart sshd
请注意,上述步骤可能需要根据具体的系统版本和需求进行调整。在进行任何配置更改之前,建议备份相关配置文件,以防万一需要恢复。