一配置本地 YUM 源
--1.1 实验环境
RHEL6:虚拟机
--1.2 挂载光驱
[root@redhat6 yum.repos.d]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
备注:将光盘 ISO 文件挂载到目录 /mnt
--1.3 创建本地目录,用来 copy 光盘包
[root@redhat6 local_repo]# mkdir -p /opt/rpm/local_repo
--1.4 copy RPM 包到指定目录
[root@redhat6 log]# cd /mnt/Packages/
[root@redhat6 Packages]# cp * /opt/rpm/local_repo
--1.5 安装 createrepo 包
[root@redhat6 local_repo]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
warning: createrepo-0.9.8-4.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
deltarpm is needed by createrepo-0.9.8-4.el6.noarch
python-deltarpm is needed by createrepo-0.9.8-4.el6.noarch
You have new mail in /var/spool/mail/root
--1.5.1根据提示,安装需要的包
[root@redhat6 local_repo]# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.i686.rpm warning: deltarpm-3.5-0.5.20090913git.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:deltarpm ########################################### [100%] [root@redhat6 local_repo]# [root@redhat6 local_repo]# [root@redhat6 local_repo]# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm warning: python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:python-deltarpm ########################################### [100%] [root@redhat6 local_repo]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm warning: createrepo-0.9.8-4.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:createrepo ########################################### [100%] |
备注:createrepo 包安装成功
--1.6 创建 repo 数据库
[root@redhat6 local_repo]# createrepo -d /opt/rpm/local_repo 2804/2804 - perl-Archive-Extract-0.38-119.el6_1.1.i686.rpm |
备注:这个步骤需要点时间。
--1.7 编写 /etc/yum.repos.d/local_repo.repo 文件
文件 /etc/yum.repos.d/local_repo.repo 内容如下。
[rhel-source] name=Red Hat Enterprise Linux Local repo ##仓库描述 baseurl=file:///opt/rpm/local_repo ##软件仓库位置 enabled=1 ##是否启用 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ##签名秘钥 |
二 yum 源测试
--2.1 查找 ruby 相关包
[root@redhat6 yum.repos.d]# yum search ruby Name and summary matches only, use "search all" for everything. |
--2.2 安装包 ruby.i68
[root@redhat6 yum.repos.d]# yum install ruby.i686 Dependencies Resolved ==================================================================================================================================== Transaction Summary Total download size: 2.3 M Installed: Dependency Installed: Complete! |
备注:本地 yum 源配置成功。
--2.3 列出已安装的包
[root@redhat6 yum.repos.d]# yum list | grep ruby Repository rhel-source is listed more than once in the configuration ruby.i686 1.8.7.352-3.el6 @rhel-source ruby-libs.i686 1.8.7.352-3.el6 @rhel-source ruby-irb.i686 1.8.7.352-3.el6 rhel-source ruby-qpid.i686 0.7.946106-2.el6 rhel-source ruby-qpid-qmf.i686 0.12-6.el6 rhel-source |
--2.4 查看包信息
[root@redhat6 yum.repos.d]# yum info ruby.i686 Loaded plugins: product-id, refresh-packagekit, security, subscription-manager Updating certificate-based repositories. Repository rhel-source is listed more than once in the configuration Installed Packages Name : ruby Arch : i686 Version : 1.8.7.352 Release : 3.el6 Size : 1.8 M Repo : installed From repo : rhel-source Summary : An interpreter of object-oriented scripting language URL : http://www.ruby-lang.org/ License : Ruby or GPLv2 Description : Ruby is the interpreted scripting language for quick and easy : object-oriented programming. It has many features to process text : files and to do system management tasks (as in Perl). It is simple, : straight-forward, and extensible. |
--2.5 删除 yum 缓存数据
[root@redhat6 yum.repos.d]# yum clean all Loaded plugins: product-id, refresh-packagekit, security, subscription-manager Updating certificate-based repositories. Repository rhel-source is listed more than once in the configuration Cleaning repos: rhel-source Cleaning up Everything |