kstrive
发布于 2023-11-09 / 46 阅读
0

Centos系统优化

CentOS7 系统优化

关闭 SELinux

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

关闭防火墙

systemctl stop firewalld systemctl disable firewalld

安装常用软件

yum install -y epel-release yum install -y wget vim htop telnet net-tools

设置系统语言为简体中文

localectl set-locale LANG=zh_CN.utf8

优化系统内核参数

echo "net.ipv4.tcp_fin_timeout = 30" >> /etc/sysctl.conf echo "net.ipv4.tcp_max_syn_backlog = 8192" >> /etc/sysctl.conf echo "net.core.netdev_max_backlog = 16384" >> /etc/sysctl.conf echo "net.core.somaxconn = 2048" >> /etc/sysctl.conf echo "vm.swappiness = 10" >> /etc/sysctl.conf sysctl -p

设置系统时区为东八区

timedatectl set-timezone Asia/Shanghai

调整 ssh 链接超时时间

echo "ClientAliveInterval 60" >> /etc/ssh/sshd_config echo "ClientAliveCountMax 3" >> /etc/ssh/sshd_config systemctl reload sshd

修改默认 ulimit 等

echo "* soft nofile 65535" >> /etc/security/limits.conf echo "* hard nofile 65535" >> /etc/security/limits.conf

修改 ssh 端口号

sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config

重新启动 ssh 服务

systemctl restart sshd

结束

echo "优化配置完成!"