createrepo
介绍
createrepo
是一个用于创建 RPM
包的工具,它可以帮助你创建一个本地的 YUM
仓库。createrepo
并不是用于运行 YUM
仓库服务的软件,而是用来生成仓库的元数据,使得 YUM 可以理解和使用这个仓库
实验主题
搭建安装docker-ce
的本地yum仓库
,并安装httpd
为其他主机提供内网网络yum源
使用于CentOS7,openEuler
等系列的yum仓库
实验前提
该server端
系统之前没有安装过docker-ce
软件 ,否则系统中就会存在之前
的依赖环境
,导致通过yum仅下载
的依赖包不全
,无法下载所需的全部依赖
实验前的准备
这里我们以openEuler
为例,准备两台机子
,一台作为服务端
,一台作为客户端
1.server端
配置yum网络源
(这里以阿里云
为主)
[ root@yum_server yum.repos.d]
[ docker]
name = docker-ce
baseurl = https://mirrors.aliyun.com/docker-ce/linux/rhel/9/x86_64/stable/
gpgcheck = 0
2.server端
配置本地yum源
(需要挂载本地镜像)
[ root@yum_server ~]
[ root@yum_server ~]
[ root@yum_server ~]
[ root@yum_server rc.d]
[ root@yum_server rc.d]
[ root@yum_server ~]
[ root@yum_server guangpan]
docs EFI images isolinux ks Packages repodata RPM-GPG-KEY-openEuler TRANS.TBL
[ root@yum_server yum.repos.d]
[ bendi]
name = docker
baseurl = file:///guangpan
gpgcheck = 0
[ root@yum_server ~]
docker 132 MB/s | 3.4 MB 00:00
docker-ce 14 kB/s | 3.5 kB 00:00
Metadata cache created.
3.关闭selinux
和firewalld
[ root@yum_server ~]
Disabled
[ root@yum_server ~]
inactive
4.安装createrepo
包
[ root@yum_server ~]
Last metadata expiration check: 0 :03:54 ago on 2024 年08月29日 星期四 17 时44分27秒.
createrepo_c-0.17.6-3.oe2203sp4.x86_64 : Creates a common metadata repository
Repo : bendi
Matched from:
Provide : createrepo = 0.17 .6-3.oe2203sp4
[ root@yum_server ~]
[ root@yum_server ~]
Version: 0.17 .6 ( Features: DeltaRPM LegacyWeakdeps )
server端
实验步骤
1.只下载,不安装
yum install docker-ce --downloadonly --downloaddir=/mnt
:将有关docker-ce
的所有依赖包
下载到/mnt
下,不安装
[ root@yum_server ~]
Last metadata expiration check: 0 :00:44 ago on 2024 年08月29日 星期四 17 时59分14秒.
Dependencies resolved.
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Package Architecture Version Repository Size
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Installing:
docker-ce x86_64 3 :27.2.0-1.el9 docker 27 M
Installing dependencies:
container-selinux noarch 2 :2.138-5.oe2203sp4 bendi 33 k
containerd.io x86_64 1.7 .21-3.1.el9 docker 43 M
docker-ce-cli x86_64 1 :27.2.0-1.el9 docker 7.8 M
Installing weak dependencies:
docker-buildx-plugin x86_64 0.16 .2-1.el9 docker 14 M
docker-compose-plugin x86_64 2.29 .2-1.el9 docker 13 M
Transaction Summary
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Install 6 Packages
Total size: 104 M
Total download size: 104 M
Installed size: 407 M
YUM will only download packages for the transaction.
Is this ok [ y/N] : y
Downloading Packages:
( 1 /5) : docker-buildx-plugin-0.16.2-1.el9.x86_64.rpm 2.3 MB/s | 14 MB 00:05
( 2 /5) : docker-ce-cli-27.2.0-1.el9.x86_64.rpm 2.3 MB/s | 7.8 MB 00:03
( 3 /5) : docker-ce-27.2.0-1.el9.x86_64.rpm 2.3 MB/s | 27 MB 00:11
( 4 /5) : docker-compose-plugin-2.29.2-1.el9.x86_64.rpm 2.2 MB/s | 13 MB 00:06
( 5 /5) : containerd.io-1.7.21-3.1.el9.x86_64.rpm 2.3 MB/s | 43 MB 00:18
-------------------------------------------------------------------------------------------------------------
Total 5.6 MB/s | 104 MB 00:18
Complete!
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages' .
[ root@yum_server ~]
[ root@yum_server mnt]
containerd.io-1.7.21-3.1.el9.x86_64.rpm docker-ce-27.2.0-1.el9.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm docker-ce-cli-27.2.0-1.el9.x86_64.rpm
docker-buildx-plugin-0.16.2-1.el9.x86_64.rpm docker-compose-plugin-2.29.2-1.el9.x86_64.rpm
2.制作本地yum仓库
[ root@yum_server mnt]
[ root@yum_server mnt]
containerd.io-1.7.21-3.1.el9.x86_64.rpm docker-ce-27.2.0-1.el9.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm docker-ce-cli-27.2.0-1.el9.x86_64.rpm
docker-buildx-plugin-0.16.2-1.el9.x86_64.rpm docker-compose-plugin-2.29.2-1.el9.x86_64.rpm
docker-ce
[ root@yum_server mnt]
[ root@yum_server mnt]
docker-ce
[ root@yum_server mnt]
[ root@yum_server docker-ce]
containerd.io-1.7.21-3.1.el9.x86_64.rpm docker-ce-27.2.0-1.el9.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm docker-ce-cli-27.2.0-1.el9.x86_64.rpm
docker-buildx-plugin-0.16.2-1.el9.x86_64.rpm docker-compose-plugin-2.29.2-1.el9.x86_64.rpm
此时此docker-ce目录
只是一个存放rpm软件包
的目录
,并不是软件仓库
使用createrepo命令
制作软件仓库
(使用createrepo命令将docker-ce目录变成docker-ce的软件仓库
)
[ root@yum_server ~]
[ root@yum_server ~]
[ root@yum_server docker-ce]
containerd.io-1.7.21-3.1.el9.x86_64.rpm docker-ce-27.2.0-1.el9.x86_64.rpm repodata
container-selinux-2.138-5.oe2203sp4.noarch.rpm docker-ce-cli-27.2.0-1.el9.x86_64.rpm
docker-buildx-plugin-0.16.2-1.el9.x86_64.rpm docker-compose-plugin-2.29.2-1.el9.x86_64.rpm
[ root@yum_server docker-ce]
[ root@yum_server repodata]
03b10e6ebfe6c159910990de370a837e198a3c00ecb2e99ec858b058d795e197-other.sqlite.bz2
2e5f1954f4590e9bde861fdc9f090dbd441104252132aa1ea5056beb3bee56f7-other.xml.gz
4b0b15d284e9883da77dce9fe5b95fe16750d92ba14851326d2a0695dbf3e143-primary.sqlite.bz2
9ee298814d084e84e3db9f2562b06969bdabd5c48d312c8e2e0971ca7309c3b4-primary.xml.gz
e287e62e0abaa26175fba50205f2316a5911e326334b1f260ff748d43535204a-filelists.sqlite.bz2
f5e8473f4966cd091a8df973e251bea5a1addb8aaa892f010b297ccf322258d6-filelists.xml.gz
repomd.xml
3.制作安装docker-ce
的本地yum源
[ root@yum_server docker-ce]
/mnt/docker-ce
[ root@yum_server docker-ce]
[ root@yum_server yum.repos.d]
bendi.repo openEuler.repo.bak wangluo.repo
[ root@yum_server yum.repos.d]
[ root@yum_server yum.repos.d]
[ root@yum_server yum.repos.d]
bendi.repo.bak openEuler.repo.bak wangluo.repo.bak
[ root@yum_server yum.repos.d]
[ docker]
name = docker-ce
baseurl = file:///mnt/docker-ce
gpgcheck = 0
[ root@yum_server yum.repos.d]
docker-ce 2.6 MB/s | 4.7 kB 00:00
Metadata cache created.
4.server端
测试
[ root@yum_server ~]
Last metadata expiration check: 0 :03:18 ago on 2024 年08月29日 星期四 18 时17分16秒.
Dependencies resolved.
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Package Architecture Version Repository Size
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Installing:
docker-ce x86_64 3 :27.2.0-1.el9 docker 27 M
Installing dependencies:
container-selinux noarch 2 :2.138-5.oe2203sp4 docker 33 k
containerd.io x86_64 1.7 .21-3.1.el9 docker 43 M
docker-ce-cli x86_64 1 :27.2.0-1.el9 docker 7.8 M
Installing weak dependencies:
docker-buildx-plugin x86_64 0.16 .2-1.el9 docker 14 M
docker-compose-plugin x86_64 2.29 .2-1.el9 docker 13 M
Transaction Summary
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Install 6 Packages
Total size: 104 M
Installed size: 407 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1 /1
Installing : docker-compose-plugin-2.29.2-1.el9.x86_64 1 /6
Running scriptlet: docker-compose-plugin-2.29.2-1.el9.x86_64 1 /6
Installing : container-selinux-2:2.138-5.oe2203sp4.noarch 2 /6
Running scriptlet: container-selinux-2:2.138-5.oe2203sp4.noarch 2 /6
Installing : containerd.io-1.7.21-3.1.el9.x86_64 3 /6
Running scriptlet: containerd.io-1.7.21-3.1.el9.x86_64 3 /6
Installing : docker-buildx-plugin-0.16.2-1.el9.x86_64 4 /6
Running scriptlet: docker-buildx-plugin-0.16.2-1.el9.x86_64 4 /6
Installing : docker-ce-cli-1:27.2.0-1.el9.x86_64 5 /6
Running scriptlet: docker-ce-cli-1:27.2.0-1.el9.x86_64 5 /6
Installing : docker-ce-3:27.2.0-1.el9.x86_64 6 /6
Running scriptlet: docker-ce-3:27.2.0-1.el9.x86_64 6 /6
Verifying : container-selinux-2:2.138-5.oe2203sp4.noarch 1 /6
Verifying : containerd.io-1.7.21-3.1.el9.x86_64 2 /6
Verifying : docker-buildx-plugin-0.16.2-1.el9.x86_64 3 /6
Verifying : docker-ce-3:27.2.0-1.el9.x86_64 4 /6
Verifying : docker-ce-cli-1:27.2.0-1.el9.x86_64 5 /6
Verifying : docker-compose-plugin-2.29.2-1.el9.x86_64 6 /6
Installed:
container-selinux-2:2.138-5.oe2203sp4.noarch containerd.io-1.7.21-3.1.el9.x86_64
docker-buildx-plugin-0.16.2-1.el9.x86_64 docker-ce-3:27.2.0-1.el9.x86_64
docker-ce-cli-1:27.2.0-1.el9.x86_64 docker-compose-plugin-2.29.2-1.el9.x86_64
Complete!
5.安装httpd
[ root@yum_server ~]
[ root@yum_server yum.repos.d]
[ root@yum_server yum.repos.d]
Last metadata expiration check: 0 :06:47 ago on 2024 年08月29日 星期四 18 时17分16秒.
Dependencies resolved.
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Package Architecture Version Repository Size
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Installing:
httpd x86_64 2.4 .51-21.oe2203sp4 bendi 1.3 M
Installing dependencies:
apr x86_64 1.7 .0-6.oe2203sp4 bendi 106 k
apr-util x86_64 1.6 .1-14.oe2203sp4 bendi 105 k
httpd-filesystem noarch 2.4 .51-21.oe2203sp4 bendi 6.8 k
httpd-tools x86_64 2.4 .51-21.oe2203sp4 bendi 67 k
mariadb-connector-c x86_64 3.1 .13-4.oe2203sp4 bendi 174 k
mod_http2 x86_64 1.15 .25-3.oe2203sp4 bendi 122 k
openEuler-logos-httpd noarch 1.0 -9.oe2203sp4 bendi 6.6 k
Transaction Summary
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Install 8 Packages
Total size: 1.9 M
Installed size: 6.2 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: mariadb-connector-c-3.1.13-4.oe2203sp4.x86_64 1 /1
Preparing : 1 /1
Running scriptlet: apr-1.7.0-6.oe2203sp4.x86_64 1 /8
Installing : apr-1.7.0-6.oe2203sp4.x86_64 1 /8
Running scriptlet: apr-1.7.0-6.oe2203sp4.x86_64 1 /8
Installing : openEuler-logos-httpd-1.0-9.oe2203sp4.noarch 2 /8
Installing : mariadb-connector-c-3.1.13-4.oe2203sp4.x86_64 3 /8
Running scriptlet: apr-util-1.6.1-14.oe2203sp4.x86_64 4 /8
Installing : apr-util-1.6.1-14.oe2203sp4.x86_64 4 /8
Running scriptlet: apr-util-1.6.1-14.oe2203sp4.x86_64 4 /8
Installing : httpd-tools-2.4.51-21.oe2203sp4.x86_64 5 /8
Running scriptlet: httpd-filesystem-2.4.51-21.oe2203sp4.noarch 6 /8
Installing : httpd-filesystem-2.4.51-21.oe2203sp4.noarch 6 /8
Installing : mod_http2-1.15.25-3.oe2203sp4.x86_64 7 /8
Installing : httpd-2.4.51-21.oe2203sp4.x86_64 8 /8
Running scriptlet: httpd-2.4.51-21.oe2203sp4.x86_64 8 /8
Verifying : apr-1.7.0-6.oe2203sp4.x86_64 1 /8
Verifying : apr-util-1.6.1-14.oe2203sp4.x86_64 2 /8
Verifying : httpd-2.4.51-21.oe2203sp4.x86_64 3 /8
Verifying : httpd-filesystem-2.4.51-21.oe2203sp4.noarch 4 /8
Verifying : httpd-tools-2.4.51-21.oe2203sp4.x86_64 5 /8
Verifying : mariadb-connector-c-3.1.13-4.oe2203sp4.x86_64 6 /8
Verifying : mod_http2-1.15.25-3.oe2203sp4.x86_64 7 /8
Verifying : openEuler-logos-httpd-1.0-9.oe2203sp4.noarch 8 /8
Installed:
apr-1.7.0-6.oe2203sp4.x86_64 apr-util-1.6.1-14.oe2203sp4.x86_64
httpd-2.4.51-21.oe2203sp4.x86_64 httpd-filesystem-2.4.51-21.oe2203sp4.noarch
httpd-tools-2.4.51-21.oe2203sp4.x86_64 mariadb-connector-c-3.1.13-4.oe2203sp4.x86_64
mod_http2-1.15.25-3.oe2203sp4.x86_64 openEuler-logos-httpd-1.0-9.oe2203sp4.noarch
Complete!
6.制作软连接,指向/mnt/docker-ce/
[ root@yum_server ~]
[ root@yum_server html]
[ root@yum_server html]
docker
[ root@yum_server html]
总用量 0
lrwxrwxrwx 1 root root 15 8 月 29 18 :27 docker -> /mnt/docker-ce/
7.开启httpd服务
[ root@yum_server html]
[ root@yum_server html]
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
8.简单测试访问
访问http://172.25.254.143/docker
client端实验步骤
1.配置内网网络yum源
[ root@yum_client ~]
[ root@yum_client yum.repos.d]
openEuler.repo.bak
[ root@yum_client yum.repos.d]
[ docker]
name = docker-ce
baseurl = http://172.25.254.143/docker
gpgcheck = 0
2.测试
[ root@yum_client ~]
docker-ce 481 kB/s | 4.7 kB 00:00
Metadata cache created.
实验最终测试
[ root@yum_client ~]
Last metadata expiration check: 0 :01:50 ago on 2024 年08月29日 星期四 18 时35分32秒.
Dependencies resolved.
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Package Architecture Version Repository Size
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Installing:
docker-ce x86_64 3 :27.2.0-1.el9 docker 27 M
Installing dependencies:
container-selinux noarch 2 :2.138-5.oe2203sp4 docker 33 k
containerd.io x86_64 1.7 .21-3.1.el9 docker 43 M
docker-ce-cli x86_64 1 :27.2.0-1.el9 docker 7.8 M
Installing weak dependencies:
docker-buildx-plugin x86_64 0.16 .2-1.el9 docker 14 M
docker-compose-plugin x86_64 2.29 .2-1.el9 docker 13 M
Transaction Summary
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Install 6 Packages
Total download size: 104 M
Installed size: 407 M
Downloading Packages:
( 1 /6) : container-selinux-2.138-5.oe2203sp4.noarch.rpm 6.4 MB/s | 33 kB 00:00
( 2 /6) : docker-buildx-plugin-0.16.2-1.el9.x86_64.rpm 56 MB/s | 14 MB 00:00
( 3 /6) : docker-ce-cli-27.2.0-1.el9.x86_64.rpm 59 MB/s | 7.8 MB 00:00
( 4 /6) : docker-ce-27.2.0-1.el9.x86_64.rpm 54 MB/s | 27 MB 00:00
( 5 /6) : docker-compose-plugin-2.29.2-1.el9.x86_64.rpm 60 MB/s | 13 MB 00:00
( 6 /6) : containerd.io-1.7.21-3.1.el9.x86_64.rpm 61 MB/s | 43 MB 00:00
---------------------------------------------------------------------------------------------------------------
Total 149 MB/s | 104 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1 /1
Installing : docker-compose-plugin-2.29.2-1.el9.x86_64 1 /6
Running scriptlet: docker-compose-plugin-2.29.2-1.el9.x86_64 1 /6
Installing : container-selinux-2:2.138-5.oe2203sp4.noarch 2 /6
Running scriptlet: container-selinux-2:2.138-5.oe2203sp4.noarch 2 /6
Installing : containerd.io-1.7.21-3.1.el9.x86_64 3 /6
Running scriptlet: containerd.io-1.7.21-3.1.el9.x86_64 3 /6
Installing : docker-buildx-plugin-0.16.2-1.el9.x86_64 4 /6
Running scriptlet: docker-buildx-plugin-0.16.2-1.el9.x86_64 4 /6
Installing : docker-ce-cli-1:27.2.0-1.el9.x86_64 5 /6
Running scriptlet: docker-ce-cli-1:27.2.0-1.el9.x86_64 5 /6
Installing : docker-ce-3:27.2.0-1.el9.x86_64 6 /6
Running scriptlet: docker-ce-3:27.2.0-1.el9.x86_64 6 /6
Verifying : container-selinux-2:2.138-5.oe2203sp4.noarch 1 /6
Verifying : containerd.io-1.7.21-3.1.el9.x86_64 2 /6
Verifying : docker-buildx-plugin-0.16.2-1.el9.x86_64 3 /6
Verifying : docker-ce-3:27.2.0-1.el9.x86_64 4 /6
Verifying : docker-ce-cli-1:27.2.0-1.el9.x86_64 5 /6
Verifying : docker-compose-plugin-2.29.2-1.el9.x86_64 6 /6
Installed:
container-selinux-2:2.138-5.oe2203sp4.noarch containerd.io-1.7.21-3.1.el9.x86_64
docker-buildx-plugin-0.16.2-1.el9.x86_64 docker-ce-3:27.2.0-1.el9.x86_64
docker-ce-cli-1:27.2.0-1.el9.x86_64 docker-compose-plugin-2.29.2-1.el9.x86_64
Complete!