一、配置YUM源地址

1.下载阿里YUM源

[root@MYSQL ~]# cd /etc/yum.repos.d/
[root@MYSQL yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo

2.修改$releasever的值

我们获取到的配置文件Centos-7.repo打开后有个releasever,这个是yum变量,我们需要替换掉,否则源没法使用,如果不替换可以试一下yum的命令查看显示什么就知道了。根据自己系统版本把releasever,这个是yum变量,我们需要替换掉,否则源没法使用,如果不替换可以试一下yum的命令查看显示什么就知道了。 根据自己系统版本把releasever,这个是yum变量,我们需要替换掉,否则源没法使用,如果不替换可以试一下yum的命令查看显示什么就知道了。根据自己系统版本把releasever替换为相对应的版本数字。
$releasever的值,表示当前系统的发行版本,可以通过rpm -qi centos-release命令查看,结果如下:

[mysql@MYSQL ~]$  rpm -qi centos-release
Name        : centos-release
Version     : 7
Release     : 9.2009.0.el7.centos
Architecture: x86_64
Install Date: 2021年04月30日 星期五 06时17分57秒
Group       : System Environment/Base
Size        : 44787
License     : GPLv2
Signature   : RSA/SHA256, 2020年10月26日 星期一 20时40分20秒, Key ID **************
Source RPM  : centos-release-7-9.2009.0.el7.centos.src.rpm
Build Date  : 2020年10月23日 星期五 22时53分59秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
Summary     : CentOS Linux release file
Description :
CentOS Linux release files

使用如下命令替换$releasever

[root@MYSQL yum.repos.d]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/Centos-7.repo
[root@MYSQL yum.repos.d]# ls
Centos-7.repo     CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo

$basearch是我们的系统硬件架构(CPU指令集),使用命令arch得到,结果如下:

[mysql@MYSQL ~]$  arch
x86_64

在Linux中使用命令arch可以初步查看出当前系统所识别出来的机器CPU类型,如"i386", “i486”,“i586”, “alpha”, “sparc”, “arm”, “m68k”,“mips”,“ppc”,“ia64”,"x86_64"等;ia64和x86_64就说明这台机器是64位的;所以我这儿要使用x86_64作为basearch的值baseurl=http://mirror.centos.org/centos/basearch的值 baseurl=http://mirror.centos.org/centos/basearch的值baseurl=http://mirror.centos.org/centos/releasever/os/$basearch/
完整路径便是
baseurl=http://mirror.centos.org/centos/7/os/x86_64/

3、注释aliyuncs.com

centos-7.repo文件里面有的是使用的是https://mirrors.aliyuncs.com.建议都注释掉,这个地址是用在阿里云服务器内网的,我们自己的电脑不可能链接得到。

二、下载epel源

[root@MYSQL yum.repos.d]# wget https://mirrors.aliyun.com/repo/epel-7.repo
--2021-05-06 21:58:15--  https://mirrors.aliyun.com/repo/epel-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 183.233.97.113, 183.233.97.115, 183.240.178.9, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|183.233.97.113|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:664 [application/octet-stream]
正在保存至: “epel-7.repo”100%[=================================================================================================================================>] 664         --.-K/s 用时 0s      2021-05-06 21:58:16 (28.4 MB/s) - 已保存 “epel-7.repo” [664/664])[root@MYSQL yum.repos.d]# ls
Centos-7.repo     CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo    epel-7.repo

三、清除缓存,再生成缓存

执行 yum clean all清除所有缓存

[root@MYSQL yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
正在清理软件源: base epel extras updates
Cleaning up list of fastest mirrors

最后执行yum makecache生成缓存。

[root@MYSQL yum.repos.d]# yum makecache
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Determining fastest mirrors* base: mirrors.aliyun.com* extras: mirrors.bfsu.edu.cn* updates: mirrors.aliyun.com
base                                                                                                                                                | 3.6 kB  00:00:00
epel                                                                                                                                                | 4.7 kB  00:00:00
extras                                                                                                                                              | 2.9 kB  00:00:00
updates                                                                                                                                             | 2.9 kB  00:00:00
(1/16): base/7/x86_64/group_gz                                                                                                                      | 153 kB  00:00:00
(2/16): epel/x86_64/group_gz                                                                                                                        |  96 kB  00:00:00
(3/16): base/7/x86_64/filelists_db                                                                                                                  | 7.2 MB  00:00:01
(4/16): epel/x86_64/updateinfo                                                                                                                      | 1.0 MB  00:00:01
(5/16): base/7/x86_64/other_db                                                                                                                      | 2.6 MB  00:00:02
(6/16): epel/x86_64/prestodelta                                                                                                                     |  727 B  00:00:00
(7/16): epel/x86_64/primary_db                                                                                                                      | 6.9 MB  00:00:01
(8/16): extras/7/x86_64/filelists_db                                                                                                                | 231 kB  00:00:00
(9/16): extras/7/x86_64/other_db                                                                                                                    | 139 kB  00:00:00
(10/16): extras/7/x86_64/primary_db                                                                                                                 | 236 kB  00:00:00
(11/16): epel/x86_64/other_db                                                                                                                       | 3.4 MB  00:00:01
(12/16): updates/7/x86_64/other_db                                                                                                                  | 607 kB  00:00:00
(13/16): updates/7/x86_64/filelists_db                                                                                                              | 4.7 MB  00:00:01
(14/16): updates/7/x86_64/primary_db                                                                                                                | 8.0 MB  00:00:02
(15/16): epel/x86_64/filelists_db                                                                                                                   |  12 MB  00:00:08
(16/16): base/7/x86_64/primary_db                                                                                                                   | 6.1 MB  00:00:09
元数据缓存已建立

Centos7配置阿里YUM源相关推荐

  1. Centos7配置本地yum源、epel源

    2.配置本地yum源,安装net-tools命令使用ifconfig命令查看ip地址 [root@bogon yum.repos.d]# vi /etc/fstab#编辑系统启动文件将sr0磁盘开机自 ...

  2. CentOS7配置本地yum源 和yum源服务器

    1.基于iso镜像的centos源 1.1.准备iso 1.1.1查看自己使用的linux服务器内核版本 cat /etc/redhat-release 或者 cat /etc/centos-rele ...

  3. Centos 配置阿里yum源

    备份默认源文件 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 获取阿里yum源文件,并重命名为默 ...

  4. Centos7更新阿里yum源

    一.下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7.repo 二.备份并替换系统的repo文件 cp Centos-7.repo /etc/ ...

  5. CentOS7配置阿里yum仓库

    阿里镜像提供的配置方法:传送门 CentOS7的yum仓库配置文件路径/etc/yum.repos.d,配置前建议备份下面的文件. 切换到root用户,执行下面的命令 # 下载Cenos-7.repo ...

  6. Centos7镜像iso挂载配置本地yum源

    CentOS7配置本地yum源 1.创建本地源文件夹 mkdir -p /mnt/centos7/ 2.备份原本地源 cp /ctc/yum.repo.d/* /etc/yum.repo.d.bak ...

  7. centos8 阿里云yum源_CentOS7更换阿里yum源

    CentOS7更换阿里yum源 更换之前确保自己安装wget 复制代码 yum list wget 若没有安装:复制代码 yum -y install wget 首先备份原版/etc/yum.repo ...

  8. CentOS7配置阿里云yum源和EPEL源

    CentOS7配置阿里云yum源和EPEL源 1.备份 [root@bogon ~]# cd /etc/yum.repos.d/ [root@bogon yum.repos.d]# mkdir rep ...

  9. CentOS7 yum源修改为阿里,配置阿里epel源

    镜像下载.域名解析.时间同步请点击 阿里巴巴开源镜像站 一.概念/区分: yum源 什么是yum源: yum是一个在CentOS.RedHat和Fedora操作系统中使用的Shell前端软件包管理器. ...

  10. Centos7配置阿里云yum源

    Centos7配置阿里云yum源 原因:系统默认的yum源的国外的,下载慢:这里配置国内源,下载快,网络稳定. [准备:如未安装wget,需要先安装wget :通过命令 yum install wge ...

最新文章

  1. Lampiao靶机渗透测试
  2. 马云:很多P2P公司披着互联网金融的外衣做非法金融服务
  3. SAL-9 获取所有部门当前manager的当前薪水情况,给出dept_no, emp_no以及salary,当前表示to_date='9999-01-01'...
  4. DELL服务器引导光盘图片及下载链接
  5. 配置oracle 11g环境,oracle 11g 的安装环境的配置
  6. 国际计算机语言,国际标准的5种PLC编程语言简介
  7. 非递归分治法排序 MergeSort without recursion
  8. thinkphp extend.php,【ThinkPHP5.1】如何引用extend的类库
  9. 如何看CentOS系统是32位还是64位的?
  10. Springboot 整合 Netty 实战(附源码)
  11. java 事务嵌套_解惑 spring 嵌套事务
  12. Spring Boot Restful API 构建实战!
  13. EPLAN教程——导出CAD如何快捷配置
  14. 汽车电子行业常见缩略词(前视摄像头相关)
  15. 用python实现基于PANN(retrained Audio Neural Networks)的声音检测方法
  16. 2021南京扬子中学高考成绩查询,2021年南京高考各高中成绩及本科升学率数据排名及分析...
  17. php城市切换,城市切换 - 网下淘
  18. 一款性能足够的4.5寸以下的手机
  19. 山东科技大学OJ题库 1904 帮小明算算数
  20. GEE5:kNDVI植被指数的获取

热门文章

  1. Java实现日历小程序【代码】
  2. 均值cvar模型matlab代码,VAR和cvar模型的matlab代码
  3. C语言自学笔记(10)
  4. 在iOS上使用AirPrint实现无线打印功能
  5. 使用Badboy录制脚本
  6. I2C接口触摸屏驱动分析
  7. JavaScript 怎样写注释
  8. js注释过后依然起作用
  9. 马哥linux视频笔记,马哥linux学习笔记(示例代码)
  10. 这几款火爆的独立游戏告诉你,寒冬?不存在的