zoukankan      html  css  js  c++  java
  • redhat7 配置使用centos的yum源

    新安装了redhat7.安装后,登录系统,使用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@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 删除redhat自带的yum包

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

    [root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)

    再用

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

    [root@localhost ~]# 

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

    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     ( rpm -qa|grep python-urlgrabber|xargs rpm -e --nodeps )

    #如果链接不正确,请手工进阿里云根据路径前半段查找后半段新路径

    安装yum软件包

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

    rpm -ivh 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-158.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-45.el7.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
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    更改CentOS-Media.repo使其为不生效:
    enabled=0                                                             \如果找不到的话不用改也行
    第三步:1、修改/etc/yum.repos.d/CentOS-Base.repo文件中的$releasever全部替换为版本号7。
    2、修改/etc/yum.repos.d/CentOS-Base.repo文件中 $basearch 全部替换为 x86_64 \ 1,$s/"需要被替换的"/"替换值"/g........

    第四步:运行yum makecache生成缓存
    yum clean all
    yum makecache
    yum update
  • 相关阅读:
    C#数据结构与算法系列(十三):递归——迷宫问题
    C#数据结构与算法系列(十二):递归(Recursion)
    C#数据结构与算法系列(十一):中缀表达式转后缀表达式
    C#数据结构与算法系列(十):逆波兰计算器——逆波兰表达式(后缀表达式)
    Quartz.Net系列(八):Trigger之CalendarIntervalScheduleBuilder详解
    Quartz.Net系列(七):Trigger之SimpleScheduleBuilder详解
    C#数据结构与算法系列(九):栈实现综合计算器(中缀表达式)
    Redis系列(五):数据结构List双向链表源码解析和API实现
    Quartz.Net系列(六):Quartz五大构件Trigger之TriggerBuilder解析
    C#数据结构与算法系列(八):栈(Stack)
  • 原文地址:https://www.cnblogs.com/chenxuf/p/9126433.html
Copyright © 2011-2022 走看看