Download all installation packages of the entire Yum source to the local specified directory

Foreword:

 Since most of the company's business runs in an intranet environment, the intranet environment cannot directly use yum to install, upgrade and update software, so it is necessary to build a self-built Yum source to meet the current daily work needs.

Download all installation packages in the entire Yum source to the local specified directory

1. Prepare to download to the local Yum source (Alibaba source, Tsinghua source)

Insert image description here
2. Check Yum source status

[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

 You can see that there are three warehouses in the Yum source we prepared, with a total of 7929 installation packages.

3. Download all installation packages in the entire Yum source to the local server

reposync:This command is very powerful and can download all installation packages in the remote Yum repository to the local directory.该命令是来自于 yum-utils 软件包里面的。

 Description of common parameters:

 -r: Specify the name of the repo source of the locally configured yum warehouse
 -p: Specify the download path

[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/

Insert image description here
4. View the installation package of the entire Yum source downloaded locally

[root@centos ~]# ll centos6/
drwxr-xr-x 3 root root 4096 1031 14:28 extras
drwxr-xr-x 3 root root 4096 1031 14:28 os
drwxr-xr-x 3 root root 4096 1031 13:14 updates

[root@centos ~]# ll centos6/extras/
drwxr-xr-x 2 root root 4096 1031 14:28 Packages

[root@centos ~]# ll centos6/extras/Packages/
-rw-r--r-- 1 root root  256356 1031 14:28 bakefile-0.2.8-3.el6.centos.x86_64.rpm
-rw-r--r-- 1 root root    4096 1031 14:28 centos-release-azure-1.0-2.el6.centos.noarch.rpm
-rw-r--r-- 1 root root    3996 1031 14:28 centos-release-cr-6-0.el6.centos.x86_64.rpm
-rw-r--r-- 1 root root    4316 1031 14:28 centos-release-gluster312-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root    5116 1031 14:28 centos-release-gluster41-1.0-1.el6.centos.x86_64.rpm
-rw-r--r-- 1 root root    4316 1031 14:28 centos-release-gluster5-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root    4268 1031 14:28 centos-release-gluster6-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root    4160 1031 14:28 centos-release-gluster7-1.0-1.el6.centos.noarch.rpm
-rw-r--r-- 1 root root    4728 1031 14:28 centos-release-gluster-legacy-3.10-1.el6.centos.noarch.rpm
...
...

Insert image description here

[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

 You can see that there are three folders in the local centos6 directory. These three folders represent the three warehouses in the Yum source we downloaded. Each warehouse has different installation packages. With all the installation packages of the entire Yum source, follow Next we can use them to build our own Yum source.

[Personal public account]

【微信公众号】搜索: 非著名运维 --》 公众号回复 “资料” 送运维自学资料大礼包哦!I will also share some operation and maintenance knowledge above. Please pay attention to it. Thank you all.

Guess you like

Origin blog.csdn.net/qq_44895681/article/details/127616357
Recommended