rocky linux 配置 yum 源
时间: 2023-11-12 15:08:02 浏览: 44
可以为您提供 Rocky Linux 配置 yum 源的步骤:
1. 打开 /etc/yum.repos.d 目录,创建一个新的 .repo 文件。命名可以是任意的,这里以 rocky.repo 为例。
2. 在 .repo 文件中输入以下内容:
[rocky]
name=Rocky Linux $releasever - BaseOS
baseurl=http://mirror.rockylinux.org/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
3. 保存该文件并退出。
4. 运行以下命令,更新 yum 缓存:
sudo yum makecache
现在您可以使用 yum 命令安装软件包了。
相关问题
rocky9配置yum源
非常感谢您的提问。关于您提到的"rocky9配置yum源",我可以为您提供以下步骤:
1. 首先,在终端中登录您的 Rocky Linux 9 操作系统。
2. 接着,检查当前系统中是否已经存在 yum 配置文件,您可以通过执行如下命令进行检查:
```bash
ls /etc/yum.repos.d/
```
如果输出中已经存在其他的配置文件,您可以选择直接修改现有文件,或者使用新的配置文件。下面将分别介绍这两种方式。
3. 如果您希望修改已有的配置文件,请先备份配置文件,以防修改错误导致系统无法使用。备份命令如下:
```bash
cp /etc/yum.repos.d/原文件名.repo /etc/yum.repos.d/原文件名.repo.bak
```
4. 然后,打开编辑器,比如使用 vi、nano 等,编辑需要修改的配置文件。以 Centos-Base.repo 文件为例,命令如下:
```bash
vi /etc/yum.repos.d/Centos-Base.repo
```
如果您是首次编辑该文件,可以直接输入以下内容:
```
[base]
name=CentOS-9 - Base
#mirrorlist=http://mirrorlist.centos.org/?release=9&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirrors.163.com/rocky/9/BaseOS/x86_64/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-9
enabled=1
skip_if_unavailable=0
[appStream]
name=CentOS-9 - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=9&arch=$basearch&repo=appstream&infra=$infra
baseurl=http://mirrors.163.com/rocky/9/AppStream/x86_64/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-9
enabled=1
skip_if_unavailable=0
[extras]
name=CentOS-9 - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=9&arch=$basearch&repo=extras&infra=$infra
baseurl=http://mirrors.163.com/rocky/9/extras/x86_64/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-9
enabled=1
skip_if_unavailable=0
```
上述配置使用了网易镜像的地址,您也可以替换为其他您熟悉的镜像源地址。
5. 编辑完成后,保存并退出编辑器。
6. 最后,执行以下命令更新 yum 缓存并测试新的配置:
```bash
yum clean all
yum makecache
yum repolist
```
如果命令执行成功并输出类似于以下信息,则说明 yum 源配置成功:
```
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.huaweicloud.com
repo id repo name status
base/9/x86_64 CentOS-9 - Base 7,492
extras/9/x86_64 CentOS-9 - Extras 727
updates/9/x86_64 CentOS-9 - Updates 2,150
repolist: 10,369
```
希望这些步骤对您有所帮助。如果您还有其他问题,可以继续向我提问。
rocky8.6 配置yum源多种方法
1. 使用官方源
在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/official.repo,然后将以下内容复制到该文件中:
[official]
name=Official CentOS $releasever Base
baseurl=http://mirror.centos.org/$contentdir/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/$contentdir/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever
保存文件后,使用命令 yum update 来检查更新。
2. 使用第三方源
许多第三方源可供选择。以下是一些示例:
- EPEL (Extra Packages for Enterprise Linux) 源:
在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/epel.repo,然后将以下内容复制到该文件中:
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7
保存文件后,使用命令 yum update 来检查更新。
- RPM Fusion 源:
在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/rpmfusion.repo,然后将以下内容复制到该文件中:
[rpmfusion-free]
name=RPM Fusion for Fedora $releasever - Free
baseurl=https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/free/fedora/releases/$releasever/Everything/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever-$basearch
[rpmfusion-nonfree]
name=RPM Fusion for Fedora $releasever - Nonfree
baseurl=https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/nonfree/fedora/releases/$releasever/Everything/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever-$basearch
保存文件后,使用命令 yum update 来检查更新。
3. 使用国内镜像源
许多国内镜像源可供选择。以下是一些示例:
- 清华大学开源软件镜像站:
在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/tuna.repo,然后将以下内容复制到该文件中:
[tuna]
name=tuna
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=0
保存文件后,使用命令 yum update 来检查更新。
- 阿里云开源镜像站:
在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/aliyun.repo,然后将以下内容复制到该文件中:
[aliyun]
name=aliyun
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=0
保存文件后,使用命令 yum update 来检查更新。