温馨提示×

centos minimal如何提速

小樊
48
2026-09-08 19:53:42
栏目: 智能运维

CentOS Minimal(通常是 CentOS 7/8 或 Stream)环境下,“提速”一般可以从 系统启动、软件安装、网络、磁盘 IO、服务精简 几个方面入手。下面按实用程度给你一份清单。


一、系统启动提速(减少开机时间)

1. 关闭不必要服务

systemctl list-unit-files --type=service | grep enabled

常见可关(按需):

systemctl disable postfix
systemctl disable firewalld   # 若不用防火墙(不推荐生产)

2. 使用轻量 init 行为

Minimal 本身已经很轻,但可禁用:

systemctl mask bluetooth
systemctl mask avahi-daemon

二、软件安装 / 更新提速(yum/dnf)

1. 使用国内镜像(非常重要)

CentOS 官方源在国内很慢。

CentOS 7

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache

CentOS 8 / Stream

dnf install -y dnf-plugin-fastestmirror
dnf config-manager --set-enabled powertools

2. 并行下载

echo "max_parallel_downloads=10" >> /etc/dnf/dnf.conf

三、网络提速

1. 关闭 IPv6(如不用)

sysctl -w net.ipv6.conf.all.disable_ipv6=1

写入:

echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.conf

2. 优化 TCP

cat >> /etc/sysctl.conf <<EOF
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_tw_reuse=1
EOF
sysctl -p

四、磁盘 & IO 提速

1. 使用 noatime

编辑 /etc/fstab

UUID=xxx / ext4 defaults,noatime 0 0

重新挂载:

mount -o remount /

2. 如果是 SSD

systemctl enable fstrim.timer

五、Shell & 命令提速

1. 安装常用工具

yum install -y bash-completion vim net-tools

2. 使用更快的 shell(可选)

yum install -y zsh
chsh -s /bin/zsh

六、系统资源占用优化

1. 关闭 SELinux(仅测试环境)

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

2. 限制日志

journalctl --vacuum-size=50M

七、如果是虚拟机(KVM / VMware)

  • 安装:
yum install -y open-vm-tools   # VMware
yum install -y qemu-guest-agent # KVM
  • 使用 virtio 网卡 / 磁盘

八、终极建议(很重要)

Minimal 本身已经很快 真正的“慢”通常来自:

  • 网络(镜像源)
  • DNS 解析慢
  • 不必要的服务

如果你能说明:

  • CentOS 版本
  • 物理机 / 虚拟机
  • 主要用途(服务器 / 开发 / 容器)

我可以给你 更针对性的加速方案

0