Rocky Linux 更新本地镜像源

Rocky Linux 更新本地镜像源

Rocky Linux 更新本地镜像源
要将 Rocky Linux 的本地镜像源更新为阿里云,你可以按照以下步骤进行操作:

  1. 打开终端或 SSH 连接到 Rocky Linux 的服务器。

  2. 进入 /etc/yum.repos.d/ 目录,该目录包含 Rocky Linux 的 yum 配置文件。

    cd /etc/yum.repos.d/
    
  3. 备份当前的 yum 配置文件,以防万一需要还原。

    sudo cp *.repo *.repo.bak
    
  4. 使用文本编辑器(如 vinano)打开 Rocky Linux 的 yum 配置文件。

    sudo vi Rocky.repo
    

    如果你使用的是 Rocky Linux 8,那么配置文件的名称可能是 rocky8.repo

  5. 在打开的文件中,找到以 [base] 开头的部分,通常是一个名为 rocky-base.repo 或类似的节。

  6. 在该节中,找到 baseurl 行,并将其注释掉(在行前面添加 #)。

    # baseurl=http://...
    
  7. 在注释掉的 baseurl 行下方添加阿里云的镜像源地址。你可以根据你所在的地区选择合适的镜像源地址。以下是一些常用的阿里云镜像源地址:

    • 阿里云中国大陆镜像源:

      baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
      

    请注意,上述地址中的 $releasever$basearch 是变量,会被实际的版本号和架构替换。

  8. 保存并关闭文件。

  9. 清除 yum 缓存。

    sudo yum clean all
    
  10. 更新 yum 缓存并安装软件包。

    sudo yum update
    
  11. 参考文件

这是我的文件

# rocky.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client.  You should use this for Rocky updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
# baseurl line instead.

[baseos]
name=Rocky Linux $releasever - BaseOS
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
countme=1
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[baseos-debug]
name=Rocky Linux $releasever - BaseOS - Debug
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever-debug$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=0
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[baseos-source]
name=Rocky Linux $releasever - BaseOS - Source
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=source&repo=BaseOS-$releasever-source$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=0
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[appstream]
name=Rocky Linux $releasever - AppStream
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=AppStream-$releasever$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
countme=1
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[appstream-debug]
name=Rocky Linux $releasever - AppStream - Debug
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=AppStream-$releasever-debug$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=0
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[appstream-source]
name=Rocky Linux $releasever - AppStream - Source
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=source&repo=AppStream-$releasever-source$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=0
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[crb]
name=Rocky Linux $releasever - CRB
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=CRB-$releasever$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=0
countme=1
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[crb-debug]
name=Rocky Linux $releasever - CRB - Debug
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=CRB-$releasever-debug$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=0
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

[crb-source]
name=Rocky Linux $releasever - CRB - Source
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=source&repo=CRB-$releasever-source$rltype
#baseurl=http://mirrors.aliyun.com/rocky/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=0
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值