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

你可能感兴趣的:(Linux,linux,运维,服务器)