究极完整版!!Centos6.9安装最适配的python和yum,附带教大家如何写Centos6.9的yum.repos.d配置文件。亲测可行!

前言!

这里我真是要被Centos6.9给坑惨了,最刚开始学习linux的时候并没有在意那么的,没有考虑到选版本问题,直到23年下半年,官方不维护Centos6.9了,基本上当时配置的文件和安装的依赖都用不了了,而且不更新了,真的崩溃了,所以真心建议大家选版本的时候要多看几篇文章,避免踩坑,后来为了解决这个问题,在网上搜了很多6.9的配置,最后是用的阿里云的解决的。

由于不同的虚拟机的依赖不同,可能会出现与我不同的错误,建议大家重装的时候先存个快照

重装yum和python

重装yum和python的话分为一下几步

1.卸载已有的python和yum

保证把之前的版本卸载干净

rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps   ##强制删除系统安装程序python包及其相关
whereis python |xargs rm -frv   ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果

rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps  #卸载yum
whereis yum |xargs rm -frv #卸载残余的yum
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps   ##强制删除系统安装程序python包及其相关
whereis python |xargs rm -frv   ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果

rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps  #卸载yum
whereis yum |xargs rm -frv #卸载残余的yum

2.下载新的安装包

因为centos6.9已经不维护了, 所以大部分的镜像都失效了,只有下面的镜像可以使用。

wget https://vault.centos.org/6.9/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/python-setuptools-0.6.10-3.el6.noarch.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/rpm-python-4.8.0-55.el6.x86_64.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/yum-utils-1.1.30-40.el6.noarch.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/yum-plugin-protectbase-1.1.30-40.el6.noarch.rpm
wget https://vault.centos.org/6.9/os/x86_64/Packages/yum-plugin-aliases-1.1.30-40.el6.noarch.rpm

3.安装

# 安装所有的包并忽略依赖
rpm -Uvh --replacepkgs python*.rpm --nodeps --force
rpm -Uvh --replacepkgs rpm-python*.rpm --nodeps --force
rpm -Uvh --replacepkgs yum*.rpm --nodeps --force

4.测试

yum --version

python -v

 

配置 CentOS 6.9阿里源

下文以centos6.9 x86_64为例,其他版本和平台可以将下文配置中的相关字段替换(打开浏览器进入相应url对照)

正常情况下应该使用阿里源http://mirrors.aliyun.com/centos/6.9/
根据链接中的readme显示6.9已被弃用
因此需要使用另一路径http://mirrors.aliyun.com/centos-vault/6.9/

1.删除/etc/yum.repos.d路径下所有.repo文件
2.在该路径下建立如下两个文件
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-6.9 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/os/x86_64/
        http://mirrors.aliyuncs.com/centos-vault/6.9/os/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.9/os/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#released updates 
[updates]
name=CentOS-6.9 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/updates/x86_64/
        http://mirrors.aliyuncs.com/centos-vault/6.9/updates/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.9/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-6.9 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/extras/x86_64/
        http://mirrors.aliyuncs.com/centos-vault/6.9/extras/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.9/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.9 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/centosplus/x86_64/
        http://mirrors.aliyuncs.com/centos-vault/6.9/centosplus/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.9/centosplus/x86_64/
gpgcheck=1
enabled=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.9 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/contrib/x86_64/
        http://mirrors.aliyuncs.com/centos-vault/6.9/contrib/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.9/contrib/x86_64/
gpgcheck=1
enabled=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

CentOS-SCLo-rh.repo:

# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/sclo/x86_64/rh/
gpgcheck=1
enabled=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/sclo/x86_64/rh/
gpgcheck=0
enabled=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/sclo/Source/rh/
gpgcheck=1
enabled=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

3.执行yum clean all&&yum makecache

可能发生的问题:

  1. RPM-GPG-KEY报错:
    执行以下命令
    wget http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
    cp RPM-GPG-KEY-CentOS-6 /etc/pki/rpm-gpg/
    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    
  2. NOT FOUND xxx/repodata/repomd.xml
    看下报错的repo的相应路径中是否存在repodata/repomd.xml,适当配置中的调整baseurl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月初,

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值