CentOS国内YUM源及配置

文章目录

  1. 阿里巴巴开源镜像站

  2. Page:https://developer.aliyun.com/mirror/

    使用说明
    CentOS旧版本镜像地址为:https://mirrors.aliyun.com/centos-vault/
    a. 备份配置文件:
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    b. 下载新的CentOS-Base.repo 到/etc/yum.repos.d/
    CentOS6:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
    CentOS7:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

  3. 华为开源镜像站

  4. Page:https://mirrors.huaweicloud.com/

    使用说明
    CentOS旧版本镜像地址为:https://repo.huaweicloud.com/centos-vault/
    a. 备份配置文件:
    cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
    b. 修改CentOS-Base.repo文件,取消baseurl开头的行的注释,并增加mirrorlist开头的行的注释。将文件中的http://mirror.centos.org替换成https://mirrors.huaweicloud.com,可以参考如下命令:
    sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo
    sed -i "s/mirrorlist=http/#mirrorlist=http/g" /etc/yum.repos.d/CentOS-Base.repo
    sed -i "s@http://mirror.centos.org@https://repo.huaweicloud.com@g" /etc/yum.repos.d/CentOS-Base.repo

  5. 清华大学开源镜像站

  6. Page:https://mirrors.tuna.tsinghua.edu.cn/

    使用说明
    CentOS旧版本镜像地址为:https://mirrors.tuna.tsinghua.edu.cn/centos-vault/
    a. 备份配置文件:
    cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
    b. 修改CentOS-Base.repo文件,取消baseurl开头的行的注释,并增加mirrorlist开头的行的注释。将文件中的http://mirror.centos.org替换成http://mirrors.tuna.tsinghua.edu.cn,可以参考如下命令:
    sed -i "s|#baseurl|baseurl|g" /etc/yum.repos.d/CentOS-Base.repo
    sed -i "s|^mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-Base.repo
    sed -i "s|http://mirror.centos.org|https://mirrors.tuna.tsinghua.edu.cn|g" /etc/yum.repos.d/CentOS-Base.repo

  7. RHEL使用CentOS源

  8. ※ 免责声明:业务系统慎用!
    a. 删除RedHat自带的yum源
    查看:rpm -qa | grep ^yum
    删除:rpm -qa | grep yum | xargs rpm -e --nodeps
    b. 下载CentOS镜像的yum包
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    c. 安装yum包提示“rpm >= 0:4.11.3-22 is needed by yum-3.4.3-158.el7.centos.noarch”
    rpm -qa | grep ^rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-32.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-libs-4.11.3-32.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-32.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-32.el7.x86_64.rpm
    rpm -Uvh rpm-*.rpm
    d. 安装CentOS镜像的yum包
    rpm -ivh yum-*.rpm
    e. 替换.repo文件中的$releasever版本为7
    sed -i "s/\$releasever/7/g" /etc/yum.repos.d/CentOS-Base.repo
    f. 安装EPEL源
    yum install epel-release
    g. 检查yum源可用性
    yum repolist && yum list all
    h. yum update提示"Error: initscripts conflicts with redhat-release-server"
    yum check-update && yum update --skip-broken

    吐槽:在RHEL 7.3系统上仅执行e,g,h步骤可以使用yum update,重装与不重装yum包都会提示“This system is not registered to Red Hat Subscription Management.”(CentOS 7.5 YUM源),可以跳过a,b,c,d步骤。

  9. 重建本地YUM缓存

  10. 附:centos6-aliyun.repo | centos6-huaweicloud.repo | centos7-epel-aliyun.repo | centos7-epel-huaweicloud.repo
    yum clean all && yum makecache

  11. CentOS Mirror Status

  12. http://mirror-status.centos.org/

    从镜像状态统计来看,“华为开源镜像站阿里巴巴开源镜像站”实时更新良好。

发表评论

电子邮件地址不会被公开。 必填项已用*标注