CentOS7(Linux)网络yum源配置
CentOS国内YUM源及配置
阿里巴巴开源镜像站
网易开源镜像站
华为开源镜像站
搜狐开源镜像站
RHEL使用CentOS源
重建本地YUM缓存
CentOS Mirror Status
发表评论
阿里巴巴开源镜像站
Page:https://opsx.alibaba.com/mirror
使用说明
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
网易开源镜像站
Page:http://mirrors.163.com/.help/
使用说明
a. 首先备份/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
b. 下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
CentOS6:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS7:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
华为开源镜像站
Page:https://mirrors.huaweicloud.com/
使用说明
CentOS的镜像地址为:https://mirrors.huaweicloud.com/centos/
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://mirrors.huaweicloud.com@g” /etc/yum.repos.d/CentOS-Base.repo
搜狐开源镜像站
Page:http://mirrors.sohu.com/
使用说明
CentOS的镜像地址为:http://mirrors.sohu.com/centos/
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.sohu.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@http://mirrors.sohu.com@g” /etc/yum.repos.d/CentOS-Base.repo
RHEL使用CentOS源
※ 免责声明:业务系统慎用!
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步骤。
重建本地YUM缓存
yum clean all && yum makecache
CentOS Mirror Status
http://mirror-status.centos.org/
从镜像状态统计来看,“华为开源镜像站、搜狐开源镜像站”实时更新良好。
原文链接:https://blog.csdn.net/WFeng_csdn/article/details/107585655