自定义Yum仓库
问题
- 准备软件包目录
- 新建文件夹 /custom
- 拷入 linuxqq、realplayer 两个 RPM 包
- 为软件包目录生成 repodata/ 数据
- 从 RHEL 6 光盘安装 createrepo
- 执行 createrepo /custom
- 测试上述 YUM 源
方案
本题的思路:
1)先搭建好yum仓库,安装createrepo软件包
2)创建目录“/custom”
3)将事先准备好的rpm包,复制到目录“/custom”目录里
4)执行 createrepo /custom
5)编写新的yum客户端配置文件,添加新的yum源
步骤
实现此案例需要按照如下步骤进行。
步骤一:准备软件包目录
新建文件夹 /custom,命令操作如下所示:
[root@localhost /]# mkdir /custom
[root@localhost /]# ls -ld /custom/
drwxr-xr-x. 2 root root 4096 1月 13 21:27 /custom/
[root@localhost /]# ls /root/桌面/
httpd-2.2.25.tar.gz linuxqq-v1.0.2-beta1.i386.rpm RealPlayer11GOLD.rpm
[root@localhost /]#
拷入 linuxqq、realplayer 两个 RPM 包
[root@localhost /]# cp /root/桌面/linuxqq-v1.0.2-beta1.i386.rpm /custom/
[root@localhost /]# cp /root/桌面/RealPlayer11GOLD.rpm /custom/
[root@localhost /]# ls /custom/
linuxqq-v1.0.2-beta1.i386.rpm RealPlayer11GOLD.rpm
[root@localhost /]#
步骤二:为软件包目录生成 repodata/ 数据
从 RHEL 6光盘安装 createrepo。(因cretaerepo包依赖关系复杂首先要搭建yum)
命令操作如下所示:
[root@localhost /]# umount /dev/cdrom
[root@localhost /]# mount /dev/cdrom /media/ //挂载光盘设备到/media
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost /]# mount | tail -1
/dev/sr0 on /media type iso9660 (ro)
[root@localhost /]# vim /etc/yum.repos.d/rhel6.repo //配置客户端文件
[rhel-6]
name=Red Hat Enterprise Linux 6
baseurl=file:///media/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@localhost /]# yum repolist //客户端测试yum
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id repo name status
rhel-6 Red Hat Enterprise Linux 6 3,690
repolist: 3,690
[root@localhost /]# yum -y install createrepo //利用yum安装createrepo
执行 createrepo /custom
[root@localhost /]# ls /custom/
linuxqq-v1.0.2-beta1.i386.rpm RealPlayer11GOLD.rpm
[root@localhost /]# createrepo /custom/
Spawning worker 0 with 2 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost /]# ls /custom/
linuxqq-v1.0.2-beta1.i386.rpm RealPlayer11GOLD.rpm repodata
[root@localhost /]#
步骤三:测试上述 YUM 源
编写客户端配置文件,命令操作如下所示:
[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel6.repo rhel-source.repo
[root@localhost yum.repos.d]# cp rhel6.repo myrpm.repo
[root@localhost yum.repos.d]# vim myrpm.repo
[rhel-myrpm]
name=Red Hat Enterprise Linux myrpm
baseurl=file:///custom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
测试yum源
[root@localhost /]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-myrpm | 2.9 kB 00:00 …
rhel-myrpm/primary_db | 3.4 kB 00:00 …
repo id repo name status
rhel-6 Red Hat Enterprise Linux 6 3,690
rhel-myrpm Red Hat Enterprise Linux myrpm 2
repolist: 3,692
[root@localhost /]