自定义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 /]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值