1、查询某个命令是由哪个rpm包提供的
若命令已经存在:
[root@syztoo ~]# whereis yumdownloader
yumdownloader: /usr/bin/yumdownloader /usr/share/man/man1/yumdownloader.1.gz
[root@syztoo ~]# rpm -qf /usr/bin/yumdownloader
yum-utils-1.1.31-54.el7_8.noarch
[root@syztoo ~]#
若命令不存在:
[root@node01 ~]# yum provides yumdownloader
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
docker-ce-stable/7/x86_64/filelists_db | 47 kB 00:00:00
epel/x86_64/filelists_db | 12 MB 00:00:21
extras/7/x86_64/filelists_db | 303 kB 00:00:00
kubernetes/filelists | 44 kB 00:00:00
updates/7/x86_64/filelists_db | 12 MB 00:00:20
yum-utils-1.1.31-54.el7_8.noarch : Utilities based around the yum package manager
Repo : base
Matched from:
Filename : /usr/bin/yumdownloader
[root@node01 ~]#
2、通过 yum 下载 rpm 包,仅下载,不安装
yum install --downloadonly --downloaddir=/root docker-ce
# 这种方式会下载所有依赖的包, 但是如果依赖的包在主机上已经安装过了,就不会下载该依赖的包
yumdownloader httpd --destdir=./
# 只下载对应的包, 不会下载其他依赖的包, 且主机上无论安装与否都会下载
3、搭建 yum 离线仓库
1、获取镜像包
[root@centos repo]# yum install --downloadonly --downloaddir=/data/docker/repo docker-ce
.
.
.
[root@centos repo]# ll
total 112192
-rw-r--r-- 1 root root 261632 Aug 23 2019 audit-2.8.5-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 104408 Aug 23 2019 audit-libs-2.8.5-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 78256 Aug 23 2019 audit-libs-python-2.8.5-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 302068 Nov 12 2018 checkpolicy-2.5-8.el7.x86_64.rpm
-rw-r--r-- 1 root root 35355976 Jul 31 22:41 containerd.io-1.6.22-3.1.el7.x86_64.rpm
-rw-r--r-- 1 root root 40816 Jul 6 2020 container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
-rw-r--r-- 1 root root 13706740 Jul 24 23:07 docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 25559408 Jul 24 23:07 docker-ce-24.0.5-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 14032924 Jul 24 23:07 docker-ce-cli-24.0.5-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 9542860 Jul 24 23:07 docker-ce-rootless-extras-24.0.5-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 13371788 Jul 24 23:07 docker-compose-plugin-2.20.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 83764 Apr 29 2020 fuse3-libs-3.6.1-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 55796 Apr 29 2020 fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
-rw-r--r-- 1 root root 67720 Aug 23 2019 libcgroup-0.41-21.el7.x86_64.rpm
-rw-r--r-- 1 root root 115284 Nov 12 2018 libsemanage-python-2.5-14.el7.x86_64.rpm
-rw-r--r-- 1 root root 938736 Apr 4 2020 policycoreutils-2.5-34.el7.x86_64.rpm
-rw-r--r-- 1 root root 468316 Apr 4 2020 policycoreutils-python-2.5-34.el7.x86_64.rpm
-rw-r--r-- 1 root root 32880 Jul 4 2014 python-IPy-0.75-6.el7.noarch.rpm
-rw-r--r-- 1 root root 635184 Nov 12 2018 setools-libs-3.3.8-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 83452 Apr 29 2020 slirp4netns-0.4.3-4.el7_8.x86_64.rpm
[root@centos repo]#
2、创建仓库索引
[root@centos docker]# createrepo /data/docker/repo
Spawning worker 0 with 5 pkgs
Spawning worker 1 with 5 pkgs
Spawning worker 2 with 5 pkgs
Spawning worker 3 with 5 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@centos docker]#
3、配置镜像仓库
[root@centos yum.repos.d]# cat syztoo.repo
[syztoo]
name=syztoo
baseurl=file:///data/docker/repo
enabled=1
gpgcheck=0
[root@centos yum.repos.d]#
4、测试安装
[root@centos yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: syztoo
Cleaning up list of fastest mirrors
Other repos take up 219 M of disk space (use --verbose for details)
[root@centos yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
syztoo | 2.9 kB 00:00:00
syztoo/primary_db | 16 kB 00:00:00
repo id repo name status
syztoo syztoo 20
repolist: 20
[root@centos yum.repos.d]# yum install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:24.0.5-1.el7 will be installed
--> Processing Dependency: containerd.io >= 1.6.4 for package: 3:docker-ce-24.0.5-1.el7.x86_64
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-24.0.5-1.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-24.0.5-1.el7.x86_64
.
.
.
Installed:
docker-ce.x86_64 3:24.0.5-1.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.6.22-3.1.el7
docker-buildx-plugin.x86_64 0:0.11.2-1.el7 docker-ce-cli.x86_64 1:24.0.5-1.el7 docker-ce-rootless-extras.x86_64 0:24.0.5-1.el7 docker-compose-plugin.x86_64 0:2.20.2-1.el7
fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7
policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
Dependency Updated:
audit.x86_64 0:2.8.5-4.el7 audit-libs.x86_64 0:2.8.5-4.el7 policycoreutils.x86_64 0:2.5-34.el7
Complete!
[root@centos yum.repos.d]#