美文网首页
CentOS8 配置阿里云的yum源

CentOS8 配置阿里云的yum源

作者: 木子的毛线 | 来源:发表于2022-06-26 09:17 被阅读0次

1 检查是否有yum 安装

如果没有安装需要先安装yum,可百度搜索

# 查看是否安装yum
rpm -qa | grep yum

# 运行结果:表示已安装
yum-4.2.17-6.el8.noarch

2 备份yum配置文件

yum配置文件目录为:/etc/yum.repos.d/

#进入yum配置文件目录
cd /etc/yum.repos.d/
# 目录文件,可能不同系统配置源文件的数量不一致,是正常的
ls
CentOS-AppStream.repo  CentOS-centosplus.repo  CentOS-Devel.repo      CentOS-HA.repo          CentOS-Sources.repo                       mysql-community.repo
CentOS-Base.repo       CentOS-CR.repo          CentOS-Extras.repo     CentOS-Media.repo       CentOS-Vault.repo                         mysql-community-source.repo
CentOS-Base.repo.old   CentOS-Debuginfo.repo   CentOS-fasttrack.repo  CentOS-PowerTools.repo  mysql-community-release-el7-5.noarch.rpm

备份所有的配置源

#在/etc/yum.repos.d/目录下创建一个backup目录
mkdir backup

# 复制所有的repo文件到backup目录
 mv *.repo  backup/

3 下载阿里云的yum源配置文件

可以通过wget命令下载阿里云的yum源

[root@test239 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
--2022-06-27 09:01:35--  http://mirrors.aliyun.com/repo/Centos-8.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 219.159.26.112, 101.75.234.99, 119.188.213.248, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|219.159.26.112|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2600 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/CentOS-Base.repo           100%[========================================================================================>]   2.54K  --.-KB/s    in 0.02s   

2022-06-27 09:01:35 (143 KB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2600/2600]

[root@test239 ~]#  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
--2022-06-27 09:01:45--  http://mirrors.aliyun.com/repo/Centos-8.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 219.159.26.112, 219.159.26.114, 219.159.26.117, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|219.159.26.112|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2600 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/CentOS-Base.repo           100%[========================================================================================>]   2.54K  --.-KB/s    in 0.009s  

2022-06-27 09:01:45 (286 KB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2600/2600]

这时候/etc/yum.repos.d/目录下会有一个CentOS-Base.repo文件

[root@test239 yum.repos.d]# ll
total 20
drwxr-xr-x. 2 root root 4096 Jun 27 08:55 backup
-rw-r--r--. 1 root root 2600 Feb 11 10:14 CentOS-Base.repo

4 修改yum源配置文件

进入CentOS-Base.repo文件

[root@test239 yum.repos.d]# vim  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-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/

在vim中进入命令模式(英文输入的前提下按ESC,然后再按冒号,即可进入)
替换阿里云的源

%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g

再次进入命令模式,继续替换

%s/$releasever/$releasever-stream/g

保存,退出:进入命令模式,输入wq,回车

5 更新yum源的配置文件,使配置生效

执行下面两个命令:
yum clean all
yum makecache

[root@test239 yum.repos.d]# yum clean all
34 files removed
[root@test239 yum.repos.d]# yum makecache
CentOS-8 - Base - mirrors.aliyun.com                                                                                                         448 kB/s | 4.6 MB     00:10    
CentOS-8 - Extras - mirrors.aliyun.com                                                                                                        25 kB/s |  10 kB     00:00    
CentOS-8 - AppStream - mirrors.aliyun.com                                                                                                    282 kB/s | 8.4 MB     00:30    
Metadata cache created.
[root@test239 yum.repos.d]# 

搞定,结束

相关文章

  • Centos Issue

    CentOS配置本地Yum源、阿里云Yum源、163Yum源、并配置Yum源的优先级

  • Linux 搭建SVN服务器(C/S模式)

    Linux System Environment 一、配置阿里云yum源和epel源提示:阿里云yum源官网 ht...

  • Docker安装

    配置阿里云的源 尽量用阿里云的yum源,下载速度快。有时Docker官方的源会出现访问超时。配置阿里云的docke...

  • CouchDB入门

    配置yum源 在CentOS8上默认的yum源是没有couchdb包的,因此需要添加couchdb的yum源。创建...

  • CentOS-7服务器基础环境搭建

    一、更换阿里云yum镜像 1.备份本地yum源 2 获取阿里yum源配置文件 更新cache 查看 二、基础工具安...

  • CentOS7更换yum国内源

    先来备份一下yum源配置文件 下载yum的源配置文件,放入/etc/yum.repos.d/,以阿里云源为例 运行...

  • centos更换yum源

    更换系统默认yum 源 更换yum源为阿里云yum源 备份系统默认的yum源 下载阿里云yum源 添加 epel ...

  • Ambari2.6.2 和HDP2.6.5搭建Hadoop集群-

    配置yum源 把系统自带的源移动到别处,也可以直接删了 配置阿里云基础yum源和epel源 CentOS7默认没有...

  • CentOS8 配置阿里云的yum源

    1 检查是否有yum 安装 如果没有安装需要先安装yum,可百度搜索 2 备份yum配置文件 yum配置文件目录为...

  • CentOS(6.x)的yum源配置

    一、阿里云的源配置官网:https://opsx.alibaba.com/mirror 二、yum源配置 1、备份...

网友评论

      本文标题:CentOS8 配置阿里云的yum源

      本文链接:https://www.haomeiwen.com/subject/vmenvrtx.html