Redhat 7自带的yum源需要付费注册,未注册情况下会报如下错误
一般更换yum源都是网易、清华、阿里;也可以在这个网站上下载免费源http://vault.centos.org/
卸载原有的yum源
#sudo rpm -qa|grep yum
yum-utils-1.1.31-34.el7.noarch
yum-3.4.3-132.el7.centos.0.1.noarch
PackageKit-yum-1.0.7-5.el7.centos.x86_64
yum-langpacks-0.4.2-4.el7.noarch
yum-plugin-fastestmirror-1.1.31-34.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
#rpm -qa|grep yum|xargs rpm -e --nodeps
安装相应的yum工具
#sudo wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
#sudo wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
#sudo wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
#sudo wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
#sudo wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
(1)#sudo rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
Preparing… ################################# [100%]
package python-iniparse-0.4-9.el7.noarch is already installed
(2)#sudo rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm #安装时报错,提示系统上已经安装了一个版本,需要卸载之前的
Preparing… ################################# [100%]
file /usr/lib/python2.7/site-packages/urlgrabber/grabber.py from install of python-urlgrabber-3.10-8.el7.noarch conflicts with file from package python-urlgrabber-3.10-7.el7.noarch
file /usr/lib/python2.7/site-packages/urlgrabber/grabber.pyc from install of python-urlgrabber-3.10-8.el7.noarch conflicts with file from package python-urlgrabber-3.10-7.el7.noarch
file /usr/lib/python2.7/site-packages/urlgrabber/grabber.pyo from install of python-urlgrabber-3.10-8.el7.noarch conflicts with file from package python-urlgrabber-3.10-7.el7.noarch
#rpm -qa python-urlgrabber python-urlgrabber-3.10-7.el7.noarch
#rpm -e python-urlgrabber --nodeps
#sudo rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm #安装成功
Preparing… ################################# [100%]
Updating / installing…
1:python-urlgrabber-3.10-8.el7 ################################# [100%]
(3)#sudo rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
(4)#sudo rpm -ivh yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm yum-3.4.3-158.el7.centos.noarch.rpm #提示rpm包太低,需要升级
error: Failed dependencies:
rpm >= 0:4.11.3-22 is needed by yum-3.4.3-158.el7.centos.noarch
#sudo wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/rpm-4.11.3-32.el7.x86_64.rpm
#rpm -Uvh rpm-4.11.3-32.el7.x86_64.rpm --nodeps
#sudo rpm -ivh yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm yum-3.4.3-158.el7.centos.noarch.rpm
Preparing… ################################# [100%]
Updating / installing…
1:yum-3.4.3-158.el7.centos ################################# [ 50%]
2:yum-plugin-fastestmirror-1.1.31-4################################# [100%]
运行查看yum版本
#yum -v
下载Centos7 repo模板
#cd /etc/yum.repos.d/
#mv * /tmp/ 先把原来的做备份
#sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#修改这个模板的内容 如下:
[base]
name=CentOS- r e l e a s e v e r − B a s e b a s e u r l = h t t p : / / v a u l t . c e n t o s . o r g / 7.5.1804 / o s / releasever - Base baseurl=http://vault.centos.org/7.5.1804/os/ releasever−Basebaseurl=http://vault.centos.org/7.5.1804/os/basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS- r e l e a s e v e r − U p d a t e s b a s e u r l = h t t p : / / v a u l t . c e n t o s . o r g / 7.5.1804 / u p d a t e s / releasever - Updates baseurl=http://vault.centos.org/7.5.1804/updates/ releasever−Updatesbaseurl=http://vault.centos.org/7.5.1804/updates/basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/7.5.1804//os/x86_64/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS- r e l e a s e v e r − E x t r a s b a s e u r l = h t t p : / / v a u l t . c e n t o s . o r g / 7.5.1804 / / e x t r a s / / releasever - Extras baseurl=http://vault.centos.org/7.5.1804//extras// releasever−Extrasbaseurl=http://vault.centos.org/7.5.1804//extras//basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS- r e l e a s e v e r − P l u s b a s e u r l = h t t p : / / v a u l t . c e n t o s . o r g / 7.5.1804 / c e n t o s p l u s / / releasever - Plus baseurl=http://vault.centos.org/7.5.1804/centosplus// releasever−Plusbaseurl=http://vault.centos.org/7.5.1804/centosplus//basearch/
gpgcheck=1
enabled=0
#sudo yum clean all && yum makecache yum就可以使用了
#yum -y install lrzsz