在 CentOS Minimal(通常是 CentOS 7/8 或 Stream)环境下,“提速”一般可以从 系统启动、软件安装、网络、磁盘 IO、服务精简 几个方面入手。下面按实用程度给你一份清单。
systemctl list-unit-files --type=service | grep enabled
常见可关(按需):
systemctl disable postfix
systemctl disable firewalld # 若不用防火墙(不推荐生产)
Minimal 本身已经很轻,但可禁用:
systemctl mask bluetooth
systemctl mask avahi-daemon
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
echo "max_parallel_downloads=10" >> /etc/dnf/dnf.conf
sysctl -w net.ipv6.conf.all.disable_ipv6=1
写入:
echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.conf
cat >> /etc/sysctl.conf <<EOF
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_tw_reuse=1
EOF
sysctl -p
编辑 /etc/fstab:
UUID=xxx / ext4 defaults,noatime 0 0
重新挂载:
mount -o remount /
systemctl enable fstrim.timer
yum install -y bash-completion vim net-tools
yum install -y zsh
chsh -s /bin/zsh
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
journalctl --vacuum-size=50M
yum install -y open-vm-tools # VMware
yum install -y qemu-guest-agent # KVM
Minimal 本身已经很快 真正的“慢”通常来自:
- 网络(镜像源)
- DNS 解析慢
- 不必要的服务
如果你能说明:
我可以给你 更针对性的加速方案。