RHEL7.4 更换CentOS7的yum源

         由于红帽系统的原yum源需要注册激活系统才可以使用,报错为:This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.为了方便使用,我们将原有的yum更改为CentOS7的yum。

  1. 查询并删除原有yum:
    [root@localhost ~]# rpm -qa | grep yum
    //查询原有yum
    [root@localhost ~]# rpm -qa | grep yum|xargs rpm -e --nodeps
    //删除原有yum   --nodeps意思为忽略依赖关系
    [root@localhost ~]# rpm -qa | grep yum
    //删除后再次检查,结果为空即删除成功
    原有的yum
    原有的yum
  2. 下载所需的.rpm包:
    由于没有激活系统,也就无法下载wget,没有wget也就无法直接从服务器上下载.rpm包。所以我们要使用其他系统或设备访问网易开源镜像站 ,下载我们所需的.rpm包。(附件于页眉处下载)

            所需包名如下:

    所需的rpm包

    下载完成后,使用命令:mkdir /home/yum/  新建一个目录,使用U盘挂载复制或FTP上传的形式,将文件放在/home/yum/目录下。
     

  3. 执行.rpm包和修改配置文件:

    [root@localhost ~]#cd /home/yum
    //进入/home/yum/目录下,也就是我们存放rpm包的目录
    [root@localhost yum]#rpm -ivh *.rpm
    //执行该目录下所以的.rpm文件

    执行完成后,进入/etc/yum.repos.d/目录下,删除redhat.repo文件,新建一个名为“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
  4. 清除并重新生成yum缓存:

    [root@localhost ~]#yum clean all && yum makecache

  5. 安装应用测试yum是否替换成功:
    这里是我原来测试是否能安装应用时安装的vim,如果安装成功的话应该和下面的图差不多一样

    Complete!

    emmm,好像上传的文件还要核审,现在还没有核实通过...

发布了12 篇原创文章 · 获赞 7 · 访问量 7516

猜你喜欢

转载自blog.csdn.net/weixin_44210782/article/details/101521272
今日推荐