Redhat7 configures the yum source using centos

Newly installed redhat7. After installation, log in to the system and use yum update to update the system. Tip:

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Unable to update.

The yum source that comes with redhat by default needs to be registered before it can be updated. We want to update without spending money, we need to replace the yum source of redhat.



1. Check whether the yum package is installed

Check RHEL has yum installed, and if so, what yum packages are there:

[root@syq yum.repos.d]# rpm -qa |grep yum
yum-3.4.3-118. el7.noarch
yum-utils-1.1.31-24.el7.noarch
yum-rhn-plugin-2.0.1-4.el7.noarch
PackageKit-yum-0.8.9-11.el7.x86_64
yum-langpacks-0.4. 2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64

2 Delete the yum package that comes with redhat

Uninstall all the yum packages shown above:

[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps (do not check dependencies, delete the rpm package directly) and use it

again

[root@localhost ~]# rpm -qa |grep yum

[root@localhost ~]#View

, if no information is displayed, it means that the uninstallation has been completed.

3. Download the new yum package. Use Centos7's yum package

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-3.4.3-150.el7.centos.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/ yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-40.el7. noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm ( rpm -qa|grep python-urlgrabber|xargs rpm - e --nodeps )

install the yum package

Note: A single installation package may depend on other packages (e.g. yum and yum-fastestmirror depend on each other), so we can put all these packages together and install them at the same time with one command:

rpm -ivh python-urlgrabber -3.10-8.el7.noarch.rpm
Note: This may conflict with the existing version of the system: the error is as follows:
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-4.el7.noarch

Solution: Install
rpm by overwriting -ivh --replacefiles python-urlgrabber-3.10-8.el7.noarch.rpm


rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-150.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch .rpm

4. Replace the yum source. Use Alibaba Cloud's source

 Step 1: Back up your original image file so that it can be restored after an error.

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
Step 2: Download the new CentOS-Base.repo to /etc/yum.repos .d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6
wget -O /etc/yum.repos.d/ CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com /repo/Centos-7.repo
Change CentOS-Media.repo to make it ineffective:
enabled=0
Step 3: Modify $releasever in the CentOS-Base.repo file and replace it with version number 7.

Step 4: Run yum makecache generates cache
yum clean all
yum makecache
yum update

This article is transferred from: http://www.cnblogs.com/syqlp/p/6555524.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326292814&siteId=291194637