当前位置: 首页 > article >正文

【Linux】CentOS7停服之后配置yum镜像源

🙋大家好!我是毛毛张!
🌈个人首页: 神马都会亿点点的毛毛张

毛毛张今天分享一个CentOS7系统停服之后,配置yum镜像源的步骤,有坑!

文章目录

  • 1.概述
  • 2.查看系统架构
    • 2.1 查看内核版本
    • 2.2 查看linux版本信息
    • 2.3 查看linux是64为还是32位
    • 2.4 直接查看系统的架构
    • 2.5 CPU架构x86、x86_64和amd64之间的关系
      • 2.5.1 X86 的来由及其架构特点
      • 2.5.2 X86_64 与 AMD64 的发展关系
      • 2.5.3 其他相关术语
      • 2.5.4 总结
  • 3.备份旧的yum源
  • 4.配置CentOS7源
    • 4.1 x86_64架构配置CentOS7源
    • 4.2 不是x86_64架构的配置CentOS7源
  • 5.清理缓存和重建缓存
  • 6.大功告成!
  • 参考文献

1.概述

  • CentOS7停服之后,官方yum源无法访问,如果继续用会发生如下报错:
    Could not resolve host: mirrorlist.centos.org; Unknown error
    
  • 解决方案:官方镜像源不能用了,配置国内镜像源不就行了,但是不同的CPU架构配置的镜像源不同,现在很多网上的教程默认就是配置的x86_64架构的镜像源,导致毛毛张昨天在配置yum镜像源的时候就报错了,因为毛毛张的CentOS7系统的架构不是x86_64,而是aarch64的,导致我配置好了镜像源也不能使用。
  • 下面毛毛张就来重新介绍一下如何配置CentOS7系统的yum镜像源
    • 查看系统架构
    • 备份旧的yum源
    • 根据自己的系统架构配置对应的yum源
    • 清理缓存和重建缓存

2.查看系统架构

2.1 查看内核版本

命令:

cat /proc/version
uname -a
uname -r

演示:

(base) shl@zhihui-mint:~$ cat /proc/version
Linux version 5.0.0-32-generic (buildd@lgw01-amd64-015) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #34~18.04.2-Ubuntu SMP Thu Oct 10 10:36:02 UTC 2019
(base) shl@zhihui-mint:~$ uname -r
5.0.0-32-generic
(base) shl@zhihui-mint:~$ uname -a
Linux zhihui-mint 5.0.0-32-generic #34~18.04.2-Ubuntu SMP Thu Oct 10 10:36:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

2.2 查看linux版本信息

命令:

lsb_release -a
cat /etc/issue

演示:

(base) shl@zhihui-mint:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	LinuxMint
Description:	Linux Mint 19.3 Tricia
Release:	19.3
Codename:	tricia
(base) shl@zhihui-mint:~$ cat /etc/issue
Linux Mint 19.3 Tricia \n \l

2.3 查看linux是64为还是32位

命令:

getconf LONG_BIT
file /bin/ls

演示:

(base) shl@zhihui-mint:~$ getconf LONG_BIT
64
(base) shl@zhihui-mint:~$ file /bin/ls
/bin/ls: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=9567f9a28e66f4d7ec4baf31cfbf68d0410f0ae6, stripped

2.4 直接查看系统的架构

命令:

dpkg --print-architecture
arch
file /lib/systemd/systemd

演示:

(base) shl@zhihui-mint:~$ dpkg --print-architecture 
amd64
(base) shl@zhihui-mint:~$ arch
x86_64
(base) shl@zhihui-mint:~$ file /lib/systemd/systemd
/lib/systemd/systemd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=85c772a89c42ba78383dec576b414b2b953cbe41, stripped

2.5 CPU架构x86、x86_64和amd64之间的关系

2.5.1 X86 的来由及其架构特点

  • 历史背景与命名由来:早在 20 世纪 80 年代,因特尔推出了 8086 处理器,随后的处理器产品呈现出规律性发展,包括 80186、80286、80386 等。这些处理器的编号中都带有“86”,因此被统称为 X86 系列,其中“X”作为通配符,代替了前面不同的数字,代表了这一系列的处理器。
  • 架构特点与 32 位系统:X86 指的是一种 CPU 的架构,其显著特点是 CPU 的寄存器是 32 位的,这也使得它被称为 32 位 CPU。由于基于 32 位 CPU 开发的操作系统也被称为 32 位操作系统,而 X86 架构在 32 位 CPU 领域具有较高的知名度,因此 32 位操作系统通常也被称为 X86 系统。

2.5.2 X86_64 与 AMD64 的发展关系

  • 因特尔的转型与选择:在 21 世纪初,因特尔为了突破 32 位 X86 架构在速度和性能等方面的限制,开始向 64 位架构发展。当时面临两个选择:一是向下兼容 X86 架构,二是设计一种全新的不兼容 X86 的指令集。
  • AMD 的领先与竞争格局:AMD 抢先一步,率先制造出了兼容 X86 架构的商用 64 位 CPU,并将其命名为 AMD64,占据了 64 位 PC 的先机,赢得了用户的认可。相比之下,因特尔最初设计出的不兼容 X86 的全新 64 位指令集 IA-64,由于缺乏编译器支持、不兼容微软 Windows 等问题,发展并不顺利。
  • 因特尔的调整与融合:因特尔在 IA-64 不顺利的情况下,也改变了策略,支持 AMD64 指令集,并将其命名为 X86_64,以表示这是 X86 指令集的 64 位扩展。因此,X86_64、x64、AMD64 实质上是同一个东西,现在常见的英特尔和 AMD 桌面级 CPU 基本上都采用这一 64 位架构。

2.5.3 其他相关术语

  • i386 的含义:i386 通常被用来作为对英特尔 32 位微处理器的统称,从严格意义上讲,i386 就是指英特尔 80386。但现在更广泛地,人们习惯将 i386 视为 32 位系统的代名词,即 X86 架构。

2.5.4 总结

  • X86 是英特尔推出的一系列以 “86” 为后缀的处理器的统称,其架构特点是 32 位寄存器,因此被称为 32 位系统。
  • 随着科技的发展,为了突破 X86 架构的限制,AMD 率先推出了兼容 X86 的 64 位架构 AMD64
  • 而英特尔在经历一些波折后也转而支持这一架构,将其命名为 X86_64。
  • 现在,X86_64(或 AMD64)已经成为一种主流的指令集架构,被广泛应用于英特尔和 AMD 的桌面级 CPU 中。

3.备份旧的yum源

  • 在配置yum的镜像源的时候,也不要忘记备份原来的源,操作步骤:
    • /etc/yum.repos.d/目录下创建一个bak目录,
    • 再将/etc/yum.repos.d/中的.repo源配置文件移动至bak目录中,当然如果您确定/etc/yum.repos.d/目录中的源配置没用,也可以将/etc/yum.repos.d/目录清空(rm -f /etc/yum.repos.d/*
  • 具体命令:
    mkdir -p /etc/yum.repos.d/bak
    mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
    

4.配置CentOS7源

4.1 x86_64架构配置CentOS7源

下面整理了多个CentOS7国内镜像的源,任选其一即可,提供curl命令下载方式,以及wget命令下载方式,任选其一。

阿里云源(curl方式)

curl -o /etc/yum.repos.d/Centos7-aliyun.repo https://mirrors.wlnmp.com/centos/Centos7-aliyun-x86_64.repo

阿里云源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-aliyun-x86_64.repo -P /etc/yum.repos.d/

网易源(curl方式)

curl -o /etc/yum.repos.d/Centos7-163.repo https://mirrors.wlnmp.com/centos/Centos7-163-x86_64.repo

网易源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-163-x86_64.repo -P /etc/yum.repos.d/

腾讯源(curl方式)

curl -o /etc/yum.repos.d/Centos7-tencent.repo https://mirrors.wlnmp.com/centos/Centos7-tencent-x86_64.repo

腾讯源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-tencent-x86_64.repo -P /etc/yum.repos.d/

中国科学技术大学源(curl方式)

curl -o /etc/yum.repos.d/Centos7-ustc.repo https://mirrors.wlnmp.com/centos/Centos7-ustc-x86_64.repo

中国科学技术大学源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-ustc-x86_64.repo -P /etc/yum.repos.d/

荆楚理工学院源(curl方式)

curl -o /etc/yum.repos.d/Centos7-jcut.repo https://mirrors.wlnmp.com/centos/Centos7-jcut-x86_64.repo

荆楚理工学院源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-jcut-x86_64.repo -P /etc/yum.repos.d/

清华源(curl方式)

curl -o /etc/yum.repos.d/Centos7-tuna.repo https://mirrors.wlnmp.com/centos/Centos7-tuna-x86_64.repo

清华源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-tuna-x86_64.repo -P /etc/yum.repos.d/

南阳理工学院源(curl方式)

curl -o /etc/yum.repos.d/Centos7-nyist.repo https://mirrors.wlnmp.com/centos/Centos7-nyist-x86_64.repo

南阳理工学院源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-nyist-x86_64.repo -P /etc/yum.repos.d/

4.2 不是x86_64架构的配置CentOS7源

只要当前不是x86_64架构的,都使用以下配置,适用于aarch64、i386、ppc64等!

阿里云源(curl方式)

curl -o /etc/yum.repos.d/Centos7-aliyun.repo https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo

阿里云源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo -P /etc/yum.repos.d/

附:CentOS7-aliyun.repo配置文件内容(非x86_64架构系统),配置文件通过$basearch变量自动识别系统架构。

网易源(curl方式)

curl -o /etc/yum.repos.d/Centos7-163.repo https://mirrors.wlnmp.com/centos/Centos7-163-altarch.repo

网易源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-163-altarch.repo -P /etc/yum.repos.d/

腾讯源(curl方式)

curl -o /etc/yum.repos.d/Centos7-tencent.repo https://mirrors.wlnmp.com/centos/Centos7-tencent-altarch.repo

腾讯源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-tencent-altarch.repo -P /etc/yum.repos.d/

中国科学技术大学源(curl方式)

curl -o /etc/yum.repos.d/Centos7-ustc.repo https://mirrors.wlnmp.com/centos/Centos7-ustc-altarch.repo

中国科学技术大学源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-ustc-altarch.repo -P /etc/yum.repos.d/

荆楚理工学院源(curl方式)

curl -o /etc/yum.repos.d/Centos7-jcut.repo https://mirrors.wlnmp.com/centos/Centos7-jcut-altarch.repo

荆楚理工学院源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-jcut-altarch.repo -P /etc/yum.repos.d/

清华源(curl方式)

curl -o /etc/yum.repos.d/Centos7-tuna.repo https://mirrors.wlnmp.com/centos/Centos7-tuna-altarch.repo

清华源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-tuna-altarch.repo -P /etc/yum.repos.d/

南阳理工学院源(curl方式)

curl -o /etc/yum.repos.d/Centos7-nyist.repo https://mirrors.wlnmp.com/centos/Centos7-nyist-altarch.repo

南阳理工学院源(wget方式)

wget https://mirrors.wlnmp.com/centos/Centos7-nyist-altarch.repo -P /etc/yum.repos.d/

5.清理缓存和重建缓存

yum clean all  # 清除缓存
yum makecache  # 重建缓存

6.大功告成!

  • 此时CentOS7的yum源配置完成,可以像原来一样使用了。

参考文献

  • https://blog.csdn.net/weixin_41010198/article/details/109166131
  • https://www.cnblogs.com/lvzhenjiang/articles/18350828
  • https://blog.csdn.net/wf19930209/article/details/79536506

都看到这了,不妨一键三连再走吧!

🌈欢迎和毛毛张一起探讨和交流!
联系方式点击下方个人名片


http://www.kler.cn/a/564106.html

相关文章:

  • Ubuntu 下通过 Docker 部署 Nginx 服务器
  • Ubuntu指令(一)
  • 如何优化Redis性能:从理论到实践
  • 苹果折叠屏iPhone突破折痕难题 或将在2026年发布
  • git 常用功能
  • AI快速变现之路,AI视频创作
  • Nacos 服务挂掉时如何恢复配置并访问缓存
  • 机器学习数学基础:31.信度与重测
  • Unity:应用关闭时执行函数方法
  • 如何合理使用Python爬虫按关键字搜索VIP商品:代码示例与实践指南
  • 软件测试八股文,软件测试常见面试合集【附答案】
  • Linux 系统串口配置及权限设置详解
  • 供应链与生产制造L1-L4级高阶流程规划框架(53页PPT)
  • MySQL之Redo Log:确保数据持久性和崩溃恢复
  • 【算法】796. 子矩阵的和
  • PostgreSQL数据库之pg_dump使用
  • java每日精进 2.24 【MQ实际应用场景】
  • Vue 中的 computed 与 watch:深度剖析与实践应用
  • 本地大模型编程实战(22)用langchain实现基于SQL数据构建问答系统(1)
  • Hot100 动态规划