Centos运维之切换国内yum镜像源

简介: Centos运维之切换国内yum镜像源

一、准备工作

保证本地包含wget工具,执行如下指令表示已经安装 wget工具。

$ wget --version
GNU Wget 1.14 在 linux-gnu 上编译。
+digest +https +ipv6 +iri +large-file +nls +ntlm +opie +ssl/openssl 
Wgetrc: 
    /etc/wgetrc (系统)

没有则通过 yum 安装。

yum -y install wget

二、备份历史配置

找到本地 yum 源仓库配置,/etc/yum.repos.d

ll /etc/yum.repos.d
-rw-r--r--. 1 root root 2523 12月 26 19:31 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11月 23 23:08 CentOS-CR.repo
-rw-r--r--. 1 root root  649 11月 23 23:08 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 11月 23 23:08 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 11月 23 23:08 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 23 23:08 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 11月 23 23:08 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 11月 23 23:08 CentOS-x86_64-kernel.repo

保留原始配置CentOS-Base.repo

mv CentOS-Base.repo CentOS-Base.repo.bak

三、配置国内源

下载阿里云镜像源配置,需要注意的是,目前,阿里云镜像中,只能够支持https

$ wget -O CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2021-04-07 11:00:18--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.160.44.224, 111.160.44.229, 111.160.44.230, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.160.44.224|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “CentOS-Base.repo”

四、清空缓存

配置文件后,需要先清空本地的 yum 缓存。

$ yum clean all

重新添加缓存。

$ yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                    | 3.6 kB  00:00:00   
extras                                                                                  | 2.9 kB  00:00:00   
updates                                                                                 | ...........
元数据缓存已建立

表示配置成功。



相关文章
|
5天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
54 25
|
1月前
|
缓存 Linux
CentOS-6的iso下载地址镜像yum源
通过上述步骤,您可以成功下载CentOS 6的ISO镜像文件,并配置适用于CentOS 6的YUM源。尽管CentOS 6已经停止更新,但使用这些镜像和YUM源配置,可以继续在需要的环境中使用和维护CentOS 6系统。
391 20
|
1月前
|
Linux
CentOs9 yum源出现404问题
CentOs9-stream yum源出现404问题
|
2月前
|
缓存 Linux
解决CentOS 7停止更新后yum源失效问题【图文教程】
以上步骤完成后,你的 CentOS 7 系统就会使用阿里云的 yum 源,更换yum以后就可以正常使用啦。
2131 2
|
4月前
|
Linux 虚拟化 开发者
一键将CentOs的yum源更换为国内阿里yum源
一键将CentOs的yum源更换为国内阿里yum源
7184 8
|
6月前
|
缓存 运维 Linux
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
|
5月前
|
消息中间件 运维 Linux
linux之centos运维kafka
linux之centos运维kafka
|
5月前
|
Linux
centos使用阿里的yum源
centos使用阿里的yum源
|
6月前
|
缓存 Linux 网络安全
解决 CentOS 7 官方 yum 仓库无法使用的最佳实践
【8月更文挑战第18天】若 CentOS 7 的官方 YUM 仓库无法使用,可按以下步骤解决: 1. **检查网络连接**: - 确认服务器能正常上网,可通过访问外部网站或网络诊断测试。 - 检查防火墙设置,避免其阻挡 YUM 的网络访问。 2. **检查 YUM 配置**: - 核实 `/etc/yum.repos.d/` 下的 `CentOS-Base.repo` 文件中仓库地址正确无误。 - 确认配置文件内的 `enabled` 选项设为 `1` 以启用仓库。
2674 0
|
6月前
|
Linux Docker 容器
在CentOS操作系统上使用yum安装/使用/卸载Docker容器引擎
在CentOS操作系统上安装、配置、使用和卸载Docker容器引擎的详细步骤,包括配置Docker镜像加速的方法。
608 0