Red Hat Enterprise Linux 5中在安装时没有选择所有软件包,以后在使用过程中想再增加缺少的软件包,通常情况可以通过两种途径完成。
一、是通过rpm手工安装需要安装的软件包;
二、是通过注册RHN,然后由yum通过internet连接到RHN站来新增软件包。
这两种情况都有其不便之外,第一种由于存在软件包的依赖性关系,可能需要在安装一个rpm包之前要安装多个与之关联的软件包,而往往这些依赖的包的名称我们无法正确定位。尤其经常提示缺乏某一动态函数库时,我们就不容易方便查到所需软件包的名称。第二种方法虽然不存在上述情况,但显而易见的问题是需要连接internet,而且安装软件包的速度会很慢。
为了避免上述两种情况的弊端,我们可以通过自己创建本地的repository(仓库)的方法来实现软件包的快速安装。(此方法前提是你有Red Hat Enterprise Linux 5安装介质盘)
1.        创建挂载点
mkdir /yum
2.        挂载安装介质盘
mount /dev/cdrom /mnt
3.        复制光盘内容到/yum目录中
cp /mnt/* /yum
4.        安装创建repository的软件包
   rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm
5.        /yum/repodate目录下的所有内容移动到指定的位置/home/repodate
mv /yum/Server/repodata/*把系统原有的存放repository内容的目录改名
6.        创建自己的repository(yum创建软件库)
  createrepo –g /home/repodate/comps-rhel5-server-core.xml /yum/Server/ repodate
7.        修改yumrepository配置文件,指定baseurl路径为本地file
cd /etc/yum.repos.d
vi rhel51-server.repo,修改的内容如下
[rhel51-server]
name=Red Hat Enterprise Linux $releasever - $basearch
baseurl=file:///yum/Server
enable=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
8.        如果还想实现更新库的功能,只需要把从RHN下载的新的软件包copyServer目录下,再运行createrepo命令更新库内容就可以了
9.        测试:安装安装vsftp软件包
[root@localhost ftp]# yum install vsftpd
Failed to set locale, defaulting to C
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vsftpd to pack into transaction set.
vsftpd-2.0.5-10.el5.i386. 100% |=========================|  17 kB    00:00     
---> Package vsftpd.i386 0:2.0.5-10.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
vsftpd                  i386       2.0.5-10.el5     Server            137 k

Transaction Summary
=============================================================================
Install      1 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         

Total download size: 137 k
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
warning: vsftpd-2.0.5-10.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: vsftpd                                                [1/1]warning: /etc/logrotate.d/vsftpd.log created as/etc/logrotate.d/vsftpd.log.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/pam.d/vsftpd created as /etc/pam.d/vsftpd.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/ftpusers created as/etc/vsftpd/ftpusers.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/user_list created as/etc/vsftpd/user_list.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/vsftpd.conf created as/etc/vsftpd/vsftpd.conf.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/vsftpd_conf_migrate.sh created as/etc/vsftpd/vsftpd_conf_migrate.sh.rpmnew
  Installing: vsftpd                       ######################### [1/1]

Installed: vsftpd.i386 0:2.0.5-10.el5
Complete!
[root@localhost ftp]#
10.        测试:卸载vsftpd
[root@localhost ftp]# yum remove vsftpd
Failed to set locale, defaulting to C
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Remove Process
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package vsftpd.i386 0:2.0.5-10.el5 set to be erased
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Removing:
vsftpd                  i386       2.0.5-10.el5     installed         283 k

Transaction Summary
=============================================================================
Install      0 Package(s)         
Update       0 Package(s)         
Remove       1 Package(s)         

Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Removing  : vsftpd                       ######################### [1/1]

Removed: vsftpd.i386 0:2.0.5-10.el5
Complete! <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />