CentOS系统优化

1、内核优化

ECHOSTR='net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_keepalive_time =600
net.ipv4.ip_local_port_range = 4000    65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.tcp_max_orphans = 16384
net.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_tcp_timeout_established = 180
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120'
echo "$ECHOSTR" >> /etc/sysctl.conf &&\
modprobe ip_conntrack && modprobe bridge
echo "modprobe ip_conntrack" >> /etc/rc.local
echo "modprobe bridge" >> /etc/rc.local
/sbin/sysctl -p

2、文件描述符

/etc/security/limits.conf
*                hard    nofile          65535
*                soft    nofile          65535
*                hard    noproc          65535
*                soft    noproc          65535

3、更新yum源,安装epel源

vi /etc/yum.repo.d/CentOS-Base.repo 略
 yum install epel-release -y

4、系统时钟同步

yum -y install ntp ntpdate
ntpdate 0.asia.pool.ntp.org
hwclock --systohc       
systemctl enable ntpd         
systemctl start ntpd
systemctl status ntpd

关闭SELinux和防火墙


if [ -f /etc/selinux/config ]; then
  sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
  setenforce 0
fi

systemctl stop firewalld
systemctl disable firewalld

调整系统字符集


echo 'export LC_ALL=C'>> /etc/profile
echo 'export LANG=en_US.UTF-8' >> /etc/profile
source /etc/profile

安装基础工具

yum install vim wget net-tools telnet tree nmap sysstat lrzsz dos2unix -y
posted @   技术颜良  阅读(212)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
历史上的今天:
2019-01-18 “三次握手,四次挥手”你真的懂吗?
2018-01-18 ELK技术实战-安装Elk 5.x平台
点击右上角即可分享
微信分享提示