35 openEuler搭建repo(yum)服务器-创建、更新本地repo源
使用mount挂载,将openEuler的ISO发布包openEuler-22.03-LTS-everything-x86_64-dvd.iso创建为本地repo源,并能够对repo源进行更新。
35.1 获取ISO发布包
请从如下网址获取openEuler的ISO发布包。
https://repo.openeuler.org/openEuler-22.03-LTS/ISO/
35.2 挂载ISO创建repo源
-
将openEuler-22.03-LTS-everything-x86_64-dvd.iso上传到/home目录。
-
在root权限下使用mount命令挂载ISO发布包。
# mount -o loop /home/openEuler-22.03-LTS-everything-x86_64-dvd.iso /mnt
例如示例命令如下:
[root@repo ~]# mount -o loop /home/openEuler-22.03-LTS-everything-x86_64-dvd.iso /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@repo ~]#
[root@repo ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 1.7G 0 1.7G 0% /dev
tmpfs 1.7G 12K 1.7G 1% /dev/shm
tmpfs 677M 9.1M 668M 2% /run
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/mapper/vg00-lv_root 41G 19G 20G 48% /
tmpfs 1.7G 0 1.7G 0% /tmp
/dev/sda1 974M 88M 819M 10% /boot
/dev/loop0 16G 16G 0 100% /mnt
[root@repo ~]#
- 挂载好的mnt目录如下:
# tree -d /mnt
例如示例命令如下:
[root@repo ~]# tree -d /mnt
/mnt
├── docs
├── EFI
│ └── BOOT
│ └── fonts
├── images
│ └── pxeboot
├── isolinux
├── ks
├── Packages
└── repodata
10 directories
[root@repo ~]#
其中,Packages为rpm包所在的目录,repodata为repo源元数据所在的目录,RPM-GPG-KEY-openEuler为openEuler的签名公钥。
35.3 创建本地repo源
- 可以拷贝ISO发布包中相关文件至本地目录以创建本地repo源。
# mount -o loop /home/openEuler-22.03-LTS-everything-x86_64-dvd.iso /mnt
# mkdir -p /home/repo
# cp -r /mnt/* /home/repo/
例如示例命令如下:
[root@repo ~]# mount -o loop /home/openEuler-22.03-LTS-everything-x86_64-dvd.iso /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@repo ~]#
[root@repo ~]# mkdir -p /home/repo
[root@repo ~]#
[root@repo ~]# cp -r /mnt/* /home/repo/
[root@repo ~]#
- 从而本地repo目录如下:
# tree -d /home/repo
例如示例命令如下:
[root@repo ~]# tree -d /home/repo
/home/repo
├── docs
├── EFI
│ └── BOOT
│ └── fonts
├── images
│ └── pxeboot
├── isolinux
├── ks
├── Packages
└── repodata
10 directories
[root@repo ~]#
Packages为rpm包所在的目录,repodata为repo源元数据所在的目录,RPM-GPG-KEY-openEuler为openEuler的签名公钥。
35.4 更新repo源
更新repo源有两种方式:
- 通过新版本的ISO更新已有的repo源,与创建repo源的方式相同,即挂载ISO发布包或重新拷贝ISO发布包至本地目录。
- 在repo源的Packages目录下添加rpm包,然后通过createrepo命令更新repo源。
# createrepo --update --workers=10 /home/repo
其中,--update表示更新,--workers表示线程数,可自定义。
说明: 若命令打印信息为“createrepo:未找到命令”,则表示未安装createrepo软件,可在root权限下执行dnf install createrepo进行安装。
例如示例命令如下:
[root@repo ~]# createrepo --update --workers=10 /home/repo
-bash: createrepo:未找到命令
[root@repo ~]#
[root@repo ~]# dnf install createrepo -y
Last metadata expiration check: 1:11:41 ago on 2022年11月29日 星期二 20时22分38秒.
Dependencies resolved.
=============================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================
Installing:
createrepo_c x86_64 0.17.6-1.oe2203 OS 137 k
Installing dependencies:
drpm x86_64 0.5.0-2.oe2203 update 60 k
Transaction Summary
=============================================================================================================================
Install 2 Packages
Total download size: 197 k
Installed size: 535 k
Downloading Packages:
(1/2): drpm-0.5.0-2.oe2203.x86_64.rpm 331 kB/s | 60 kB 00:00
(2/2): createrepo_c-0.17.6-1.oe2203.x86_64.rpm 539 kB/s | 137 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------
Total 722 kB/s | 197 kB 00:00
retrieving repo key for OS unencrypted from http://repo.openeuler.org/openEuler-22.03-LTS/OS/x86_64/RPM-GPG-KEY-openEuler
OS 14 kB/s | 2.1 kB 00:00
Importing GPG key 0xB25E7F66:
Userid : "private OBS (key without passphrase) <defaultkey@localobs>"
Fingerprint: 12EA 74AC 9DF4 8D46 C69C A0BE D557 065E B25E 7F66
From : http://repo.openeuler.org/openEuler-22.03-LTS/OS/x86_64/RPM-GPG-KEY-openEuler
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : drpm-0.5.0-2.oe2203.x86_64 1/2
Installing : createrepo_c-0.17.6-1.oe2203.x86_64 2/2
Running scriptlet: createrepo_c-0.17.6-1.oe2203.x86_64 2/2
Verifying : createrepo_c-0.17.6-1.oe2203.x86_64 1/2
Verifying : drpm-0.5.0-2.oe2203.x86_64 2/2
Installed:
createrepo_c-0.17.6-1.oe2203.x86_64 drpm-0.5.0-2.oe2203.x86_64
Complete!
[root@repo ~]#
[root@repo ~]# createrepo --update --workers=10 /home/repo
Directory walk started
Directory walk done - 16818 packages
type group added to list from path: /home/repo/repodata/93612b651befaec659f6700eab197afbbd9380df1bb302f73621ed1f4764940b-normal.xml
type group_gz added to list from path: /home/repo/repodata/c2a33c2e9423b23416c587e201ad7c690ef870f29998f4387f1cc9bea816d62e-normal.xml.gz
Loaded information about 16818 packages
Temporary output repo path: /home/repo/.repodata/
Preparing sqlite DBs
Pool started (with 10 workers)
Pool finished
[root@repo ~]#
标签:x86,35,repo,64,home,yum,openEuler,root From: https://blog.51cto.com/u_237826/6106511