温馨提示×

centos stream8如何配置

小樊
37
2026-07-20 04:57:08
栏目: 智能运维

CentOS Stream 8 已于 2024-05-31 正式 EOL(停止维护),官方仓库已下线,因此**必须切换到归档源(vault)**才能继续安装和更新软件。

下面给你一套当前可用的完整配置方案,包括:

  • 系统源(BaseOS / AppStream)
  • EPEL 源
  • 常用优化建议

一、确认系统版本

cat /etc/os-release

应看到:

NAME="CentOS Stream"
VERSION="8"

二、修复官方 YUM 源(关键步骤)

1️⃣ 备份原有 repo

mkdir -p /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/

2️⃣ 配置 CentOS Stream 8 Vault 源

/etc/yum.repos.d/CentOS-Stream-Vault.repo

[baseos]
name=CentOS Stream 8 - BaseOS
baseurl=http://vault.centos.org/8-stream/BaseOS/$basearch/os/
gpgcheck=0
enabled=1

[appstream]
name=CentOS Stream 8 - AppStream
baseurl=http://vault.centos.org/8-stream/AppStream/$basearch/os/
gpgcheck=0
enabled=1

[extras-common]
name=CentOS Stream 8 - Extras Common
baseurl=http://vault.centos.org/8-stream/extras/$basearch/extras-common/
gpgcheck=0
enabled=1

gpgcheck=0 是为了避免 GPG key 过期问题
✅ 使用 vault.centos.org 是目前唯一可用官方地址


3️⃣ 清空缓存并重建

dnf clean all
dnf makecache

测试:

dnf repolist

三、配置 EPEL 8 源(强烈推荐)

1️⃣ 安装 EPEL(使用 vault)

dnf install -y \
https://vault.centos.org/8-stream/extras/$basearch/extras-common/epel-release-8-18.el8.noarch.rpm

2️⃣ 修改 EPEL 为 vault 源

编辑:

vi /etc/yum.repos.d/epel.repo

改为:

[epel]
name=Extra Packages for Enterprise Linux 8
baseurl=https://vault.centos.org/8-stream/extras/$basearch/extras-common/
enabled=1
gpgcheck=0

四、系统基本配置(推荐)

✅ 关闭 SELinux(非必须)

setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

✅ 时间同步(chronyd)

dnf install -y chrony
systemctl enable --now chronyd
timedatectl

✅ 防火墙(firewalld)

systemctl enable --now firewalld
firewall-cmd --state

✅ 常用软件

dnf install -y \
vim wget curl net-tools lsof \
bash-completion rsync tar

五、升级系统(可选)

dnf update -y
reboot

六、重要提醒(⚠ 必须看)

❗ CentOS Stream 8 已 EOL

不再提供安全更新,建议:

场景 建议
新服务器 ✅ Rocky Linux 8 / AlmaLinux 8
老系统 ✅ 迁移到 Rocky / Alma
临时使用 ✅ 当前 vault 方案

迁移参考:

migrate2rocky -r

七、如果你告诉我用途,我可以给更精确配置

你可以直接说:

  • ✅ 用于 Docker / K8s
  • ✅ 用于 生产服务器
  • ✅ 用于 内网环境
  • ✅ 用于 编译 / 开发

我可以给你 最小化 / 安全 / 高性能 配置方案。

0