• Linux之RedHat7如何更换yum源


    目前,我们常见的系统大概就是Windows、Linux和Mac OS了。Windows系统应该是大部分人最早开始接触的系统,毕竟Windows系统使用起来相当方便,只需要点点鼠标,外加会简单的打字,一般看视频、听音乐、上网都是没问题的。追求完美体验的用户可能会更加喜欢Mac OS系统,相比Windows系统而言,Mac OS用户界面更加的华丽,设计很人性化,用户体验会好很多。至于Linux,则主要安装在服务器上,一般人基本不太会接触,但是对于运维、开发人员而言,可能是不得不掌握的一种操作系统。

    当然,随着信息技术的发展,全民素质的提高,越来越多的人开始了解Linux并尝试去使用Linux,Linux也逐渐进入了大家的视线。像Ubuntu、Debian、CentOS等Linux系统因为有着类似Windows的桌面和相对人性化的设计而在为人所熟知,大部分初学者基本会安装上述系统来体验一下所谓的Linux系统,如果你对Linux系统也有一定的兴趣,可以去看看《Linux就该这么学》这本书,是一本比较好的Linux入门书籍。

     

    今天,我在这里向大家介绍一下如何为RedHat7更换yum源。选择RedHat的原因很简单:1、RedHat的老板是红帽公司(全球最大的开源技术厂商);2、,RedHat是全世界内使用最广泛的Linux系统。3、RedHat系统具有极强的性能与稳定性,并且在全球范围内拥有完善的技术支持。当然,如果你想要享受红帽公司的技术支持,那是要收费的,如果你不用她的技术支持,那稍稍改变一下,就可以免费使用RedHat系统了,而这个改变就是更换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源了,下面就给大家介绍一下如果更换RedHat的yum源。

     

    第一步:检查是否安装yum软件包。

    首先,可以用rpm -qa |grep yum 命令来查看RHEL是否安装了yum,如果安装了,就会显示系统安装的那些yum包:

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

    yum-utils-1.1.31-24.el7.noarch

    yum-langpacks-0.4.2-3.el7.noarch

    yum-metadata-parser-1.1.4-10.el7.x86_64

    yum-rhn-plugin-2.0.1-4.el7.noarch

    PackageKit-yum-0.8.9-11.el7.x86_64

    yum-3.4.3-118.el7.noarch

    第二步: 卸载redhat自带的yum软件包。

    [root@linuxprobe ~]# rpm -e yum-3.4.3-118.el7.noarch --nodeps

    [root@linuxprobe ~]# rpm -e yum-utils-1.1.31-24.el7.noarch --nodeps

    [root@linuxprobe ~]# rpm -e yum-rhn-plugin-2.0.1-4.el7.noarch --nodeps

    [root@linuxprobe ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps

    [root@linuxprobe ~]# rpm -e yum-langpacks-0.4.2-3.el7.noarch --nodeps

    [root@linuxprobe ~]# rpm -e PackageKit-yum-0.8.9-11.el7.x86_64 --nodeps

    卸载完成后,再用命令 rpm -qa |grep yum 查看是否已经卸载完成,如果输入命令后,无信息显示表示已经卸载完成:

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

    [root@ linuxprobe ~]# 

    第三步.下载新的yum软件包。

    一般可以进入以下网站上面查看软件包的版本是否升级或者找到自己系统所对应的文件包版本更新;

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

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

    找到自己所需要的版本下载:

    [root@Linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm

    --2016-01-17 20:43:15--  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm

    Resolving mirrors.163.com (mirrors.163.com)... 123.58.173.185, 123.58.173.186

    Connecting to mirrors.163.com (mirrors.163.com)|123.58.173.185|:80... connected.

    HTTP request sent, awaiting response... 404 Not Found

    2016-01-17 20:43:15 ERROR 404: Not Found.   //如果找不到,是安装包更新了,你可以到这个网站http://mirrors.163.com/centos/7/os/x86_64/Packages/复制下载链接,然后再下载下来;

     

    [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm

    [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

    [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-34.el7.noarch.rpm

    [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-34.el7.noarch.rpm

    [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm

    第四步、安装yum软件包。

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

    [root@Linuxprobe ~]# rpm -ivh yum-*

    warning: yum-3.4.3-132.el7.centos.0.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY

    Preparing...                          ################################# [100%]

    Updating / installing...

    1:yum-metadata-parser-1.1.4-10.el7    ################################# [ 20%]

    2:yum-plugin-fastestmirror-1.1.31-3   ################################# [ 40%]

    3:yum-3.4.3-132.el7.centos.0.1        ################################# [ 60%]

    4:yum-updateonboot-1.1.31-34.el7      ################################# [ 80%]

    5:yum-utils-1.1.31-34.el7             ################################# [100%]

    第五步、新建repo 配置文件。

    [root@linuxprobe ~]# 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 makecache命令生成缓存。

     

    [root@linuxprobe ~]# yum clean all

    [root@linuxprobe ~]# yum makecache
    [root@linuxprobe ~]# yum update

     

    经过上述六个步骤,新的yum源已经安装完成了,我们可以用yum install 命令来测试安装是否正常:

     

    [root@Linuxprobe ~]# yum -y install lftp

    Loaded plugins: fastestmirror, product-id, subscription-manager

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

    Loading mirror speeds from cached hostfile

    Resolving Dependencies

    --> Running transaction check

    ---> Package lftp.x86_64 0:4.4.8-7.el7 will be installed

    --> Finished Dependency Resolution

    Dependencies Resolved

    ================================================================================================

    Package              Arch                     Version                    Repository               Size

    ================================================================================================

    Installing:

    lftp                x86_64                    4.4.8-7.el7                base                     750 k

    Transaction Summary

    ================================================================================================

     

    Install  1 Package

    ………………省略部分安装过程………………

    Installed:

    lftp.x86_64 0:4.4.8-7.el7

    Complete!

     

        到这里,新的yum源已经安装完成了,以后我们就可以用yum命令来愉快的使用RedHat系统了,而不必再担心会出现注册提示无法更新的问题了。

  • 相关阅读:
    ubuntu下ssh服务相关操作
    搜索引擎的基础-倒排索引
    mysql重置密码
    mysql 服务器配置
    Activiti如何替换已部署流程图
    循环select查询结果集
    存储过程范例,有输入输出参数,带回滚
    sql server中字符串无法替换空格的问题
    Myeclipse实用快捷键总结
    Linux中添加用户与删除用户
  • 原文地址:https://www.cnblogs.com/probemark/p/11019560.html
Copyright © 2020-2023  润新知