前言:
由于公司业务大部分都在内网环境下运行,内网环境无法直接使用yum安装升级更新软件,所以需要自建Yum源来满足目前日常工作需要。
下载整个Yum源中所有安装包至本地指定目录
1.准备要下载到本地的Yum源(阿里源、清华源)

2.查看Yum源情况
[root@centos ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
仓库标识 仓库名称 状态
extras Qcloud centos extras - x86_64 47
os Qcloud centos os - x86_64 6,713
updates Qcloud centos updates - x86_64 1,169
repolist: 7,929复制
可以看到我们准备好的Yum源中有三个仓库,总共有7929个安装包。
3.下载整个Yum源中所有安装包到本地服务器上
reposync:
该命令很强大,可以将远端Yum仓库里面的所有安装包全部下载到本地目录中。该命令是来自于 yum-utils 软件包里面的。
常用参数说明:
-r :指定已经本地已经配置的 yum 仓库的 repo源的名称
-p :指定下载的路径
[root@centos ~]# yum -y install yum-utils #执行安装软件包
[root@centos ~]# mkdir centos6 #创建本地Yum包存放目录
[root@centos ~]# yum repolist #查看Yum源的仓库标识名称
Loading mirror speeds from cached hostfile
仓库标识 仓库名称 状态
extras Qcloud centos extras - x86_64 47
os Qcloud centos os - x86_64 6,713
updates Qcloud centos updates - x86_64 1,169
repolist: 7,929
[root@centos ~]# reposync -r extras -p /root/centos6/ #根据每个据仓库标识下载安装包到本地目录
[extras: 1 of 47 ] Downloading Packages/bakefile-0.2.8-3.el6.centos.x86_64.rpm
bakefile-0.2.8-3.el6.centos.x86_64.rpm | 250 kB 00:00
[extras: 2 of 47 ] Downloading Packages/centos-release-azure-1.0-2.el6.centos.noarch.rpm
centos-release-azure-1.0-2.el6.centos.noarch.rpm | 4.0 kB 00:00
[extras: 3 of 47 ] Downloading Packages/centos-release-cr-6-0.el6.centos.x86_64.rpm
centos-release-cr-6-0.el6.centos.x86_64.rpm
...
...
[root@centos ~]# reposync -r os -p /root/centos6/
[os: 1 of 6713 ] Downloading Packages/389-ds-base-1.2.11.15-95.el6_9.x86_64.rpm
389-ds-base-1.2.11.15-95.el6_9.x86_64.rpm | 1.5 MB 00:00
[os: 2 of 6713 ] Downloading Packages/389-ds-base-devel-1.2.11.15-95.el6_9.i686.rpm
389-ds-base-devel-1.2.11.15-95.el6_9.i686.rpm | 149 kB 00:00
[os: 3 of 6713 ] Downloading Packages/389-ds-base-devel-1.2.11.15-95.el6_9.x86_64.rpm
389-ds-base-devel-1.2.11.15-95.el6_9.x86_64.rpm
...
...
[root@centos ~]# reposync -r updates -p /root/centos6/复制

4,查看下载到本地的整个Yum源的安装包
[root@centos ~]# ll centos6/
drwxr-xr-x 3 root root 4096 10月 31 14:28 extras
drwxr-xr-x 3 root root 4096 10月 31 14:28 os
drwxr-xr-x 3 root root 4096 10月 31 13:14 updates
[root@centos ~]# ll centos6/extras/
drwxr-xr-x 2 root root 4096 10月 31 14:28 Packages
[root@centos ~]# ll centos6/extras/Packages/
-rw-r--r-- 1 root root 256356 10月 31 14:28 bakefile-0.2.8-3.el6.centos.x86_64.rpm
-rw-r--r-- 1 root root 4096 10月 31 14:28 centos-release-azure-1.0-2.el6.centos.noarch.rpm
-rw-r--r-- 1 root root 3996 10月 31 14:28 centos-release-cr-6-0.el6.centos.x86_64.rpm
-rw-r--r-- 1 root root 4316 10月 31 14:28 centos-release-gluster312-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root 5116 10月 31 14:28 centos-release-gluster41-1.0-1.el6.centos.x86_64.rpm
-rw-r--r-- 1 root root 4316 10月 31 14:28 centos-release-gluster5-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root 4268 10月 31 14:28 centos-release-gluster6-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root 4160 10月 31 14:28 centos-release-gluster7-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root 4728 10月 31 14:28 centos-release-gluster-legacy-3.10-1.el6.centos.noarch.rpm
...
...复制

[root@centos ~]# ll centos6/extras/Packages/ | wc -l
48
[root@centos ~]# ll centos6/os/Packages/ | wc -l
6714
[root@centos ~]# ll centos6/updates/Packages/ | wc -l
1170复制
可以看到本地centos6目录中有三个文件夹,这三个文件夹表示我们下载的Yum源中的三个仓库,每个仓库都有不同的安装包,有了整个Yum源的所有安装包,接下来我们就可以利用它们来搭建属于自己的Yum源了。
高手都是点完赞再走,必须的!
复制
“点赞+在看”双点击,开启今日暴富
文章转载自非著名运维,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
Centos/RedHat 7.x服务器挂载ISCSI存储示例(无多路径非LVM)
小周的数据库进阶之路
50次阅读
2025-03-31 10:03:04
基于CentOS操作系统部署BIND9
IT那活儿
36次阅读
2025-04-18 10:00:59
学习linux用centos哪个版本学习?
云知识CLOUD
26次阅读
2025-04-08 11:30:16
Centos系统云主机中nvme盘不可用解决方法
天翼云开发者社区
21次阅读
2025-04-03 19:07:44
Cloud-init 概述及 PVE 下创建步骤说明
老柴杂货铺
16次阅读
2025-04-07 00:19:57
CentOS 7.9 网络配置全指南
老柴杂货铺
14次阅读
2025-04-10 00:00:17
配置docker yum源
青青河边草
10次阅读
2025-04-25 08:55:39
上下五千年最齐全、最完整、最牛的sqlserver在linux环境上安装实操
青年数据库学习互助会
8次阅读
2025-04-24 09:53:06
热门文章
Kubernetes v1.22.1部署报错2: Get “http://localhost:10248/healthz“
2021-09-24 4825浏览
快速解决Kubernetes从k8s.gcr.io仓库拉取镜像失败问题
2021-09-23 3648浏览
三步解决Docker拉取镜像报错:x509: certificate has expired or is not yet v..
2021-09-29 3538浏览
harbor-db重启报错:initdb: error: directory "/var/lib/postgresql/da..
2021-10-16 3273浏览
Gitlab其他用户登录返回500错误解决
2022-03-10 2843浏览
最新文章
在Docker守护进程停机期间保持容器运行(即重启Docker时,正在运行的容器不会停止)
2022-12-20 1182浏览
基于Linux系统的本地Yum源搭建与配置(ISO方式、RPM方式)
2022-11-18 447浏览
解决第三方邮箱APP登陆QQ、163邮箱无法验证账户名或密码的问题(IOS、MacOS、Windows、Android)
2022-11-11 1526浏览
超简单一步解决Win10系统无法访问网页,但软件能够联网的问题
2022-10-21 1231浏览
史上最详细的Windows10系统离线安装.NET Framework 3.5的方法(附离线安装包下载)
2022-09-17 2451浏览