YUM以光盘映像为源,不用光盘,不用网络就能方便用yum安装rpm包

 
主要步骤:
   (一) 制作Redhat光盘镜像
   (二) 配置/etc/yum.repos.d/rhel-debuginfo.repo文件。
 
具体步骤:
  1.从光盘制作光盘镜像文件。将光盘放入光驱,执行下面的命令。
 
         #cp /dev/cdrom /var/local/mydisk.iso
 
      或者 #dd if=/dev/cdrom of=/var/local/mydisk.iso
  注:执行上面的任何一条命令都可将当前光驱里的光盘制作成光盘镜像文件/var/local/mydisk.iso
 
  2.光盘镜像文件的挂接(mount)
 
         #mkdir /mnt/vcdrom
 
  注:建立一个目录用来作挂接点(mount point)
 
3。配置/etc/yum.repos.d/rhel-debuginfo.repo文件。
 
[root@localhost ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo 
[Cluster] 
name=Red Hat Enterprise Linux $releasever - $basearch - Cluster 
baseurl= file:///mnt/vcdrom/Cluster 
enabled=1 
gpgcheck=1 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 
[ClusterStorage] 
name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage 
baseurl= file:///mnt/vcdrom/ClusterStorage 
enabled=1 
gpgcheck=1 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 
[Server] 
name=Red Hat Enterprise Linux $releasever - $basearch - Server 
baseurl= file:///mnt/vcdrom/Server 
enabled=1 
gpgcheck=1 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 
[VT] 
name=Red Hat Enterprise Linux $releasever - $basearch - VT 
baseurl= file:///mnt/vcdrom/VT 
enabled=1 
gpgcheck=1 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 
   注:rhel-debuginfo.repo文件其实只修改了所有的baseurl=file:///,其余行未做更改。但baseurl=file:///之后的路径必须于挂载点相同。
 
4。挂在镜像:
[root@localhost ~]# mount /var/local/mydisk.iso /mnt/vcdrom/ -o loop
注:每次开机时要想使用yum时,必须先执行一次第4步的命令,让光盘镜像先挂载上。否则执行不了yum命令。
 
5.执行yum命令
[root@localhost ~]# yum search httpd
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
================================ Matched: httpd ================================
mod_ssl.i386 : Apache HTTP 服务器的 SSL/TLS 模块
system-config-httpd.noarch : Apache 配置工具。
httpd.i386 : Apache HTTP 服务器
httpd-devel.i386 : Apache HTTP 服务器的开发工具。
httpd-manual.i386 : Apache HTTP 服务器的文档。
mod_dav_svn.i386 : Subversion 服务器的 Apache 服务器模块。
 
 至此;当执行yum命令时,使用的rpm包,就是来自光盘镜像了.