redhat7.4 使用centos yum源

 

新安装了redhat7.4安装后,登录系统,使用yum update 更新系统。提示:

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

无法更新。

redhat 默认自带的 yum 源需要注册,才能更新。我们想不花钱也可以更新,需要替换掉redhat的yum源。

 

1.检查是否安装yum包

查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:

[root@bogon ~]# rpm -qa |grep yum
yum-3.4.3-154.el7.noarch
yum-rhn-plugin-2.0.1-9.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64

 

2 删除redhat自带的yum包

卸载上面显示的所有yum包:

[root@bogon ~]# rpm -qa |grep yum | xargs rpm -e --nodeps

再检查

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

 

查看,无信息显示表示已经卸载完成。

 

3.下载新的yum包。使用Centos7的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-3.4.3-158.el7.centos.noarch.rpm
 wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
 wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
 wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
 wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/wget-1.14-15.el7_4.1.x86_64.rpm

 

安装yum软件包

注意:单个的安装包可能会依赖其它包(例如yum和yum-fastestmirror会相互依赖),所以我们可以把所有这些包放在一起,用一行命令将它们同时安装即可:

 

rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm  --replacefiles

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

 

4.更换yum源。使用本地源

[root@bogon ~]# cat /etc/yum.repos.d/client.repo 
[bash]
name=centos7
baseurl=http://192.168.238.128:81
enabled=1
gpgcheck=0
gpgkey=http://192.168.238.128:81/RPM-GPG-KEY-CentOS-7


第四步:运行yum makecache生成缓存
yum clean all
yum makecache

 

yum安装软件,报错

** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
rhn-check-2.0.2-17.el7.noarch has missing requires of yum-rhn-plugin >= ('0', '1.6.4', '1')

 

解决办法

首先安装 yum-utils 套件
  

yum install yum-utils

执行 clean duplicate package

 

posted @ 2018-08-17 10:28  fengjian1585  阅读(1293)  评论(0编辑  收藏  举报