资源描述
一配置本地 YUM 源
--1.1 实验环境
RHEL6:虚拟机
--1.2 挂载光驱
[root@redhat6 yum.repos.d]# mount -o loop /root/Desktop/rhel-server-6.2-x86_64-dvd.iso.iso /mnt
备注:将光盘 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 安装 包
--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
1944/2804 - MAKEDEV-3.24-6.el6.i686.rpm
iso-8859-1 encoding on Ville Skytt?ville.skytta@iki.fi> - 2.8.2-2
2804/2804 - perl-Archive-Extract-0.38-119.el6_1.1.i686.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
备注:这个步骤需要点时间。
--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
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Repository rhel-source is listed more than once in the configuration
rhel-source | 2.7 kB 00:00 ...
rhel-source/primary_db | 2.5 MB 00:00 ...
======================================================== N/S Matched: ruby =========================================================
ruby-irb.i686 : The Interactive Rubyy
ruby-libs.i686 : Libraries necessary to run Ruby
ruby-qpid.i686 : Ruby language client for AMQP
ruby-qpid-qmf.i686 : The QPID Management Framework bindings for ruby
ruby.i686 : An interpreter of object-oriented scripting language
saslwrapper.i686 : Ruby and Python wrappers for the cyrus sasl library.
Name and summary matches only, use "search all" for everything.
--2.2 安装包 ruby.i68
[root@redhat6 yum.repos.d]# yum install 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
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ruby.i686 0:1.8.7.352-3.el6 will be installed
--> Processing Dependency: ruby-libs = 1.8.7.352-3.el6 for package: ruby-1.8.7.352-3.el6.i686
--> Processing Dependency: libruby.so.1.8 for package: ruby-1.8.7.352-3.el6.i686
--> Running transaction check
---> Package ruby-libs.i686 0:1.8.7.352-3.el6 will be installed
--> Processing Dependency: libreadline.so.5 for package: ruby-libs-1.8.7.352-3.el6.i686
--> Running transaction check
---> Package compat-readline5.i686 0:5.2-17.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
ruby i686 1.8.7.352-3.el6 rhel-source 532 k
Installing for dependencies:
compat-readline5 i686 5.2-17.1.el6 rhel-source 127 k
ruby-libs i686 1.8.7.352-3.el6 rhel-source 1.6 M
Transaction Summary
====================================================================================================================================
Install 3 Package(s)
Total download size: 2.3 M
Installed size: 7.7 M
Is this ok [y/N]: y
Downloading Packages:
------------------------------------------------------------------------------------------------------------------------------------
Total 16 MB/s | 2.3 MB 00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Importing GPG key 0xFD431D51:
Userid : Red Hat, Inc. (release key 2) <security@>
Package: redhat-release-server-6Server-6.2.0.3.el6.i686 (@anaconda-RedHatEnterpriseLinux-201111171035.i386/6.2)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Is this ok [y/N]: y
Importing GPG key 0x2FA658E0:
Userid : Red Hat, Inc. (auxiliary key) <security@>
Package: redhat-release-server-6Server-6.2.0.3.el6.i686 (@anaconda-RedHatEnterpriseLinux-201111171035.i386/6.2)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : compat-readline5-5.2-17.1.el6.i686 1/3
Installing : ruby-libs-1.8.7.352-3.el6.i686 2/3
Installing : ruby-1.8.7.352-3.el6.i686 3/3
Installed products updated.
Installed:
ruby.i686 0:1.8.7.352-3.el6
Dependency Installed:
compat-readline5.i686 0:5.2-17.1.el6 ruby-libs.i686 0:1.8.7.352-3.el6
Complete!
备注:本地 yum 源配置成功。
--2.3 列出已安装的包
[root@redhat6 yum.repos.d]# yum list | grep rubyin
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
--2.6清除YUM缓存
yum 会把下载的软件包和header存储在cache中,而不会自动删除。如果我们觉得它们占用了磁盘空间,可以使用yum clean指令进行清除,更精确的用法是yum clean headers清除header,yum clean packages清除下载的rpm包,yum clean all一股脑儿端
1.清除缓存目录(/var/cache/yum)下的软件包
命令:yum clean packages
2.清除缓存目录(/var/cache/yum)下的 headers
命令:yum clean headers
3.清除缓存目录(/var/cache/yum)下旧的 headers
命令:yum clean oldheaders
4.清除缓存目录(/var/cache/yum)下的软件包及旧的headers
命令:yum clean, yum clean all (= yum clean packages; yum clean oldheaders)
展开阅读全文