redhat7.2修改yum源

可以用百度网盘下载需要的安装包

  • 链接:https://pan.baidu.com/s/1oAl3Okq
  • 密码:hfma

1.Uninstall yum


rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa | grep python-iniparse | xargs rpm -e --nodeps
rpm -qa | grep python-urlgrabber | xargs rpm -e --nodeps

2.Download yum repo


# 如果没有wget这个命令,可到百度云中下载安装包

# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.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 
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-25.el7.x86_64.rpm

3.Install the rpm package


# rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm
# rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
# rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
# rpm -ivh yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

在安装yum和yum-plugin-fastestmirror时会提示rpm的版本不符合需求,需安装指定版本的rpm包

[root@hostname ~]# rpm -ivh yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
warning: yum-3.4.3-154.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
    rpm >= 0:4.11.3-22 is needed by yum-3.4.3-154.el7.centos.noarch

安装yum软件需要的rpm版本

# 参数nodeps:忽略软件包的依赖关系强行安装
# 参数force:忽略软件包及文件的冲突

# rpm -ivh rpm-4.11.3-25.el7.x86_64.rpm --nodeps --force

4. Modify yum repo


cd /etc/yum.repos.d/
rm rhel.repo

# download repos according the redhat version in http://mirrors.163.com/.help/centos.html

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

# modify the repo file: replace $releasever to 7, open the file using vim first
    :%s/$releasever/7/g

5.Import the key


rpm --import http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

你可能感兴趣的:(redhat7.2修改yum源)