zoukankan      html  css  js  c++  java
  • 【Linux】RedHat换源(转)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

    原本链接:https://blog.csdn.net/otmqixi/article/details/81564515

    我们安装好RHEL的Linux后,执行yum命令安装软件,如果是未注册的肯定会出现This system is not registered with an entitlement server. You can use subscription-manager to register. 类似这样的问题

    具体如下图:

    这是因为红帽的企业版Linux系统RHEL是收费的,必须要注册才可正常使用。

    这时我们就得想办法了。替换掉原版的yum,安装一个免费的yum源-->CentOS(CentOS已经被红帽收购,且跟RHEL系统没多大区别,最主要还是可以免费使用)

    我们将RHEL7的yum源更换为CentOS7的!

    具体流程:

    1.检查并删除原有的yum源

    2.下载安装CentOS的yum相关软件包

    3.配置repo文件

    1.检查并删除原有的yum源

    检查yum源:rpm -qa | grep yum

    删除原有的yum源: rpm -qa|grep yum|xargs rpm -e --nodeps

    2.下载安装CentOS的yum源

    网上找的这几个可以下载的网站

      阿里云网络源地址:https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/ 

      网易163网络源地址:http://mirrors.163.com/ 

      CentOS网络源地址:http://centos.ustc.edu.cn/centos/ 

    我这里用了网易的。

    ①点击centos进入

    ②找到7.5版本的

    ③依此进入到os/x86_64/Packages中

     

     

     ④Ctrl+F搜索yum-->找到下面几个-->点击鼠标右键-->复制链接地址

      http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm

      http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rp

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

     

     ⑤在终端中通过wget指令下载(确保联网,可通过ping一下百度服务器看看联网没,Crtl+c终止命令)

    •  wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
    • wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    • wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

    ⑥为了防止几个包安装时有互相依赖,使用 rpm -ivh yum-* 命令一次性安装三个包

     ⑦使用第一条命令检查yum是否安装成功:rpm -qa |grep yum

    3.配置repo文件(关键!前面的能不能起作用就看这一步了)

    ①在/etc目录下重命名备份原来的repo:mv yum.repos.d yum.repos.d.backup

     ②建一个新的yum.repos.d目录(确保在/etc目录下)

     ③下载一个CentOS的repo(我们可以在网易镜像站的centos使用帮助中下载学习)

     

     和下载软件包一样下载CentOS7的repo

     通过 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo 下载

     ④通过vim打开并编辑repo

    打开如下样子

     将所有的$releasever全部替换成版本号-->7.5.1804:

    shift+: 编辑 输入下面的指令

    %s/$releasever/7.5.1804/g

    # 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.5.1804 - Base - 163.com
    
    #mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=os
    
    baseurl=http://mirrors.163.com/centos/7.5.1804/os/$basearch/
    
    gpgcheck=1
    
    gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
    
     
    
    #released updates
    
    [updates]
    
    name=CentOS-7.5.1804 - Updates - 163.com
    
    #mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=updates
    
    baseurl=http://mirrors.163.com/centos/7.5.1804/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.5.1804 - Extras - 163.com
    
    #mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=extras
    
    baseurl=http://mirrors.163.com/centos/7.5.1804/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.5.1804 - Plus - 163.com
    
    baseurl=http://mirrors.163.com/centos/7.5.1804/centosplus/$basearch/
    
    gpgcheck=1
    
    enabled=0
    
    gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

    wq保存退出

    ⑥根据使用说明文档,我们要清除缓存

    yum clean all  ##清理缓存

     yum makecache  ##重新生成缓存

     这一步可能还会出现未注册的提示,我们不用在意

    ⑦使用yum repolist all查看是否成功

     ⑧安装一个mysql试试

    ————————————————

    版权声明:本文为CSDN博主「学编程的鹿」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

    原文链接:https://blog.csdn.net/otmqixi/article/details/81564515

  • 相关阅读:
    Linux 分区与挂载
    Linux Shell 编程总结
    Java AtomicIntegerFieldUpdater 抽象类
    Java 内部类加载顺序
    Java AtomicIntegerArray 类
    Java AtomicInteger 类
    Java ReentrantLock 类
    Java Runnable 接口
    Java Supplier 接口
    Java Consumer 接口
  • 原文地址:https://www.cnblogs.com/jxd283465/p/11598662.html
Copyright © 2011-2022 走看看