Linux CentOS stream9配置本地yum源

在Linux系统中,yum源配置是一个重要的环节。把系统安装时配置的国外yum源转换为国内yum源,能够帮助系统快速安装软件包。对于网络环境不稳定或无法联网的系统,配置本地yum源,可以让用户在离线状态下也能进行软件包的安装,十分重要。

一、国内源

在使用Linux的日常工作中,经常会遇到缺少包的情况,而当我们单独下载缺少的包进行安装时,大多都会因为依赖或版本与操作系统版本不兼容的问题,这个时候配置yum就显得很有必要

配置yum源一般分两种情况,网络yum源和本地iyum源。

1.网络yum源

网络yum源通常在能连接互联网的服务器上进行配置,配置简单,可选择性强,能获取的包也更多;用国内yum源替换系统自带的yum源,对于本版本的设置,可参考《Linux CentOS7 yum仓库》。

主要配置文件:

a. centos.repo

[baseos]

name=CentOS Stream $releasever - BaseOS

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/$basearch/os

# metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

countme=1

enabled=1

[baseos-debuginfo]

name=CentOS Stream $releasever - BaseOS - Debug

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/$basearch/debug/tree/

# metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-debug-$stream&arch=$basearch&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

enabled=0

[baseos-source]

name=CentOS Stream $releasever - BaseOS - Source

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/source/tree/

# metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-source-$stream&arch=source&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

enabled=0

[appstream]

name=CentOS Stream $releasever - AppStream

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/$basearch/os

# metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream&arch=$basearch&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

countme=1

enabled=1

[appstream-debuginfo]

name=CentOS Stream $releasever - AppStream - Debug

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/$basearch/debug/tree/

# metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-debug-$stream&arch=$basearch&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

enabled=0

[appstream-source]

name=CentOS Stream $releasever - AppStream - Source

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/source/tree/

# metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-source-$stream&arch=source&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

enabled=0

[crb]

name=CentOS Stream $releasever - CRB

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/$basearch/os

# metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

countme=1

enabled=1

[crb-debuginfo]

name=CentOS Stream $releasever - CRB - Debug

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/$basearch/debug/tree/

# metalink=https://mirrors.centos.org/metalink?repo=centos-crb-debug-$stream&arch=$basearch&protocol=https,http

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

gpgcheck=1

repo_gpgcheck=0

metadata_expire=6h

enabled=0

[crb-source]

name=CentOS Stream $releasever - CRB - Source

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/source/tree/

# metalink=https://mirrors.centos.org/metalink?repo=centos-crb-source-$stream&arch=

CentOS 8 Stream 是一个滚动更新的发行版,它提供最新的软件和技术预览版本。如果你想要添加或配置 YUM(Yellowdog Updater, Modified)源来安装额外的软件包,你需要按照以下步骤操作: 1. **启用 EPEL (Extra Packages for Enterprise Linux)**: CentOS 8 Stream 提供了官方的 EPEL仓库,用于获得更多第三方软件支持。首先,你需要从 https://dl.fedoraproject.org/pub/epel/ 获取对应版本的 GPG 密钥并导入到系统中: ``` curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-epel-$releasever https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-epel-$releasever rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-epel-$releasever ``` 接着,编辑 `/etc/yum.repos.d/epel.repo` 文件,替换 `$releasever` 为实际版本,添加或修改内容: ```bash [epel] name=Extra Packages for Enterprise Linux $releasever baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/ gpgcheck=1 gpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-epel-$releasever enabled=1 ``` 2. **添加其他仓库**: 如果你还想添加其他的YUM源(如阿里云、腾讯云等),可以在 `/etc/yum.repos.d/` 目录下创建新的 `.repo` 文件,填写相应的URL、名称和GPG密钥。 3. **刷新缓存**: 完成上述设置后,运行 `yum makecache fast` 来更新本地的元数据缓存。 4. **安装软件**: 使用 `yum install <package_name>` 来安装特定的软件包。如果需要安装自定义的软件列表,可以将它们写入一个文本文件(`.list` 或 `.txt`),然后用 `-y` 标志一次性安装所有列出的包: ``` yum install -y $(cat mysoftware.list) ``` 记得检查网络连接,并根据实际情况调整源地址(如国内镜像)。同时,请注意及时备份数据,在安装非官方软件时谨慎操作,以防潜在的风险。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_36142959

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值