CentOS Stream 8 已经于 2024-05-31 正式 EOL(停止维护),官方不再提供安全更新和软件源支持。如果是生产环境,强烈建议迁移到 Rocky Linux 8/9、AlmaLinux 8/9 或 CentOS Stream 9。
如果你只是短期使用或实验环境,可以从以下几个层面优化性能:
systemctl list-unit-files --type=service | grep enabled
常见可关闭:
systemctl disable --now firewalld # 若使用云厂商安全组
systemctl disable --now postfix
systemctl disable --now bluetooth
# 文件句柄
fs.file-max = 1000000
# 网络
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
# 内存
vm.swappiness = 10
vm.dirty_ratio = 10
vm.dirty_background_ratio = 5
应用:
sysctl -p
/etc/security/limits.conf
* soft nofile 1000000
* hard nofile 1000000
yum install -y cpupowerutils
cpupower frequency-set -g performance
systemctl enable --now irqbalance
noatime,nodiratime
示例:
/dev/sda1 / ext4 defaults,noatime,nodiratime 0 0
SSD:
echo mq-deadline > /sys/block/sda/queue/scheduler
HDD:
echo bfq > /sys/block/sda/queue/scheduler
hugepages(数据库场景)TCP BBR(内核 ≥ 4.9)echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
CentOS Stream 8 已停止维护:
sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo
yum install -y htop iotop nload sysstat
常用:
top
iostat -x 1
vmstat 1
如果你能说明 使用场景(Web / 数据库 / 容器 / 虚拟化)和硬件配置,我可以给出更针对性的优化方案。