red hat 6.5 配置yum源

转载于:https://blog.csdn.net/qq_29963431/article/details/52564726

今天准备在自己的虚拟机配置一下yum源,在网上各种找教程,但是因为兼容性的问题还有一些下载地址错误,一直装不好,决定自己记录一下。

我的虚拟机是red hat 6.5 64位,这里的下载地址也是64位的。配置的是CentOS-6

yum源,python版本是2.6

刚装的red hat6.5,当我们使用yum命令的时候会报错:

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

为了省去注册操作,通常选择配置CentOS  yum源,配置步骤如下:

  1. 检查是否安装有yum

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

  2. 删除自带的yum

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

    因为一些包之间可能会有依赖关系,所以我们需要加上参数 --nodeps 无视依赖关系

    之后我们再次使用  rpm -qa | grep yum,确定yum包全部删除

  3. 下载yum

    这一点一定要注意,因为red hat版本问题还有系统内部python版本的问题,出错好多次

    再次重申,我的red hat6.5版本,64

     

    Yum包下载地址http://mirrors.163.com/centos/

    在这个网站里,你可以自己选择需要下载的文件,进入形如5/或者6/的文件下载,其他的无法下载

     

    REHL6.5 x86_64的看这里

    wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm

    wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

    wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm

    如果以上地址出错,可以直接进网站下载三个文件,

    形如yum.*.centos.noarch.rpm  yum-metadata-parser*.rpm  

    yum-plugin-fastemirror.*.rpm

  4. 解压yum

    rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-3.2.29-73.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm --force --nodeps

    如果直接解压可能会出现包的依赖错误,这里我直接选择忽视依赖性

    因为这里下载的文件可能不一样,建议解压命令自己打,多tab几下就好

     

    接下来更换yum

    cd  /etc/yum.repos.d/

    wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo

    vi CentOS6-Base-163.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-6 - Base - 163.com

    baseurl=http://mirrors.163.com/centos/6/os/$basearch/

    #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os

    gpgcheck=1

    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

     

    #released updates

    [updates]

    name=CentOS-6 - Updates - 163.com

    baseurl=http://mirrors.163.com/centos/6/updates/$basearch/

    #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates

    gpgcheck=1

    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

     

    #additional packages that may be useful

    [extras]

    name=CentOS-6 - Extras - 163.com

    baseurl=http://mirrors.163.com/centos/6/extras/$basearch/

    #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras

    gpgcheck=1

    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

     

    5清理缓存

    yum clean all

    重建缓存

    yum makecache

  1. 更新

    yum update

     

    中间遇到很多问题比如

    [root@localhost ~ ]# yum

    There was a problem importing one of the Python modules

    required to run yum. The error leading to this problem was:

       No module named yum

    Please install a package which provides this module, or

    verify that the module is installed correctly.

    It's possible that the above module doesn't match the

    current version of Python, which is:

    2.6.7 (************)

     

    解决方法:

    查找yum文件,并编辑此py文件

    [root@localhost ~ ]# which yum

    /usr/bin/yum

    [root@localhost ~ ]# vi /usr/bin/yum

     

    #!/usr/bin/python

    改为:

    whereis python出来的结果

    #!/usr/bin/python2.6

     

    如果实在不行,重新安装yum包吧(就是上边说的三个文件,重新进入网站自选),少年,这个yum包可能不适合你的系统版本

     

    装好之后试一下yum list命令,如果出现一大堆包,恭喜你

猜你喜欢

转载自blog.csdn.net/QEcode/article/details/83687671
今日推荐