根据 CentOS 7 配置yum阿里源 (三步即可)-阿里云开发者社区操作步骤报时报错
[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
http://mirrors.aliyun.com/centos/7/os/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
http://mirrors.aliyuncs.com/centos/7/os/aarch64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/aarch64/repodata/repomd.xml: (28, 'Connection timed out after 30002 milliseconds')
正在尝试其它镜像。
直接在web上使用以上地址访问,发现报错
http://mirrors.aliyuncs.com/centos/7/os/aarch64/repodata/repomd.xml
而直接使用http://mirrors.aliyun.com/centos/ 地址则没有问题,应此阿里云yum源已经发生了变化
为此我们可以自己定义一个yum 源
cd /etc/yum.repos.d/
vi /etc/yum.repos.d/CentOS-Base-Aliyun.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
添加完了后,验证如下:
[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras local updates
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
local | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/14): base/group_gz | 153 kB 00:00:00
(2/14): base/primary_db | 6.1 MB 00:00:01
(3/14): extras/primary_db | 253 kB 00:00:00
(4/14): local/group_gz | 153 kB 00:00:00
(5/14): local/filelists_db | 6.1 MB 00:00:00
(6/14): extras/other_db | 154 kB 00:00:00
(7/14): local/primary_db | 4.9 MB 00:00:00
(8/14): local/other_db | 2.1 MB 00:00:00
(9/14): extras/filelists_db | 305 kB 00:00:00
(10/14): base/other_db | 2.6 MB 00:00:00
(11/14): updates/filelists_db | 15 MB 00:00:05
(12/14): base/filelists_db | 7.2 MB 00:00:07
(13/14): updates/other_db | 1.6 MB 00:00:00
(14/14): updates/primary_db | 27 MB 00:00:11
元数据缓存已建立
[root@localhost yum.repos.d]#
配置本地yum 源
在CentOS 7中配置本地YUM源的操作步骤如下:
•挂载ISO镜像•
创建挂载目录(如/opt/centos),执行命令:
mkdir /opt/centos
mount /dev/cdrom /opt/centos # 物理光驱
# 或挂载ISO文件:
mount -o loop /path/to/CentOS-7-x86_64-Everything.iso /opt/centos
-
确保镜像内容可访问
-
配置repo文件 在
/etc/yum.repos.d/
目录创建新文件(如local.repo
),内容为:[local] name=Local Yum baseurl=file:///opt/centos # 与挂载点一致 enabled=1 gpgcheck=0
更新YUM缓存 清理旧缓存并生成新数据:
yum clean all
yum makecache
设置开机挂载(可选) 编辑/etc/fstab
文件,添加:
/dev/cdrom /opt/centos iso9660 defaults 0 0