RedHat更换阿里云CentOS的yum源
2018-10-22 本文已影响0人
早就是优势
一、卸载自带软件包
rpm -qa | grep yum | xargs rpm -e --nodeps
二、保证上网正常
ping www.baidu.com
三、进入以下网站下载对应的包
1、阿里云网络源地址:https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
2、网易163网络源地址:http://mirrors.163.com/
3、CentOS网络源地址:http://centos.ustc.edu.cn/centos/
使用CTRL+F输入关键字查找对应的安装包即可。
四、找到安装包后下载下来
若出现404错误去重新查询最新rpm包的链接
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
五、强制安装rpm包
--force --nodeps忽略依赖检测的强制安装
rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm --force --nodeps
rpm -ivh yum-3.4.3-158.el7.centos.noarch.rpm --force --nodeps
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --force --nodeps
rpm -ivh yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm --force --nodeps
rpm -ivh yum-utils-1.1.31-45.el7.noarch.rpm --force --nodeps
六、查看yum相关的包是否已安装
[root@localhost ~]# rpm -qa |grep yum
yum-utils-1.1.31-45.el7.noarch
yum-3.4.3-158.el7.centos.noarch
yum-plugin-fastestmirror-1.1.31-45.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
[root@localhost ~]# rpm -qa |grep python-urlgrabber
python-urlgrabber-3.10-8.el7.noarch
七、修改repo
1、下载源文件
curl -o /etc/yum.repos.d/CentOS-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2、需要把CentOS-7.repo文件中的$releasever全部替换为7
cd /etc/yum.repos.d/
vim CentOS-7.repo
3、在vim中执行:%s/$releasever/7/g快速替换。保存退出。
:%s/$releasever/7/g
八、清空重载yum
yum clean all
yum update
参考链接:
https://blog.csdn.net/feng_zhiyu/article/details/80464336
https://www.jianshu.com/p/fd00c304ae5d