Redhat7.x 修改阿里云yum源
1. 删除已安装的yum包
将linux自带的yum源删除
rpm -qa | grep yum | xargs rpm -e --nodeps
cd /etc/rpm/
rm -rf ./m*
2. 下载centos的yum包
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-52.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
如果出现404错误,请去https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/搜索关键词查询最新rpm包的链接。
3. 强制安装rpm包
--force --nodeps为忽略依赖检测的强制安装
rpm -ivhpython-urlgrabber-3.10-9.el7.noarch.rpm --force --nodeps
rpm -ivh yum* --force --nodeps
4. 查看yum包是否安装好
rpm -qa |grep yum
yum-metadata-parser-1.1.4-10.el7.x86_64
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
5. 修改repo
下载源文件
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
需要把Centos-7.repo文件中的$releasever全部替换为7
cd /etc/yum.repos.d/
ls
vim CentOS-Base.repo
在vim中执行:%s/$releasever/7/g快速替换。保存退出。
6. 清空重载yum
yum clean all
yum update
# 最后查看一下yum列表
yum list