redhat7 配置使用centos的yum源

新安裝了redhat7.安裝後,登陸系統,使用yum update 更新系統。提示:html

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

沒法更新。python

redhat 默認自帶的 yum 源須要註冊,才能更新。咱們想不花錢也能夠更新,須要替換掉redhat的yum源。vim

 

1.檢查是否安裝yum包centos

查看RHEL是否安裝了yum,如果安裝了,那麼又有哪些yum包:緩存

[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_64less

2 刪除redhat自帶的yum包this

卸載上面顯示的全部yum包:阿里雲

[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不檢查依賴,直接刪除rpm包)url

再用

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

[root@localhost ~]# 

查看,無信息顯示錶示已經卸載完成。

3.下載新的yum包。使用Centos7的yum包

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

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm

 wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-32.el7.x86_64.rpm

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

安裝yum軟件包

注意:單個的安裝包可能會依賴其它包(例如yum和yum-fastestmirror會相互依賴),因此咱們能夠把yum-plugin-fastestmirror強制安裝

rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm   rpm -Uvh rpm-4.11.3-32.el7.x86_64.rpm --nodeps   rpm -Uvh yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm --nodeps  rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm  rpm -ivh yum-utils-1.1.31-45.el7.noarch.rpm   rpm -ivh yum-3.4.3-158.el7.centos.noarch.rpm

4.更換yum源。使用阿里雲的源

 第一步:備份你的原鏡像文件,以避免出錯後能夠恢復。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:下載新的CentOS-Base.repo 到/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
http://mirrors.aliyun.com/repo/Centos-7.repowget -O /etc/yum.repos.d/CentOS-Base.repo
更改CentOS-Media.repo使其爲不生效:

enabled=0
或者用163.com我是用的163.com的方法,

# 寫 yum 配置文件

vim /etc/yum.repos.d/CentOS-Base.repo

*********************************************************************

#CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$7 - Base - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os

baseurl=http://mirrors.163.com/centos/7/os/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#released updates

[updates]

name=CentOS-$7 - Updates - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates

baseurl=http://mirrors.163.com/centos/7/updates/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#additional packages that may be useful

[extras]

name=CentOS-$7 - Extras - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras

baseurl=http://mirrors.163.com/centos/7/extras/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$7 - Plus - 163.com

baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

*********************************************************************

yum clean all

 
第三步:修改CentOS-Base.repo文件中的$releasever所有替換爲版本號7.

第四步:運行yum makecache生成緩存
yum clean all
yum makecacheyum update注本文來源於https://www.cnblogs.com/syqlp/p/6555524.html 博主用的阿里雲yum源   我用的是163.com
相關文章
相關標籤/搜索