首页 > 代码库 > linux yum 用本地光盘做源安装perl

linux yum 用本地光盘做源安装perl

参考:http://hi.baidu.com/pengduo66/item/abfe454f81cdb7e5a4c06675

场景说明:选择最小化安装linux操作系统,没有安装perl工具。由于网络的故障问题,无法使用yum install perl 从网上安装perl,目前只有原版的安装光盘。于是尝试使用本地的光盘作为安装源。

步骤1:创建光盘挂载点

    mkdir /iso

步骤2:挂载光盘镜像

    mount -o loop /CentOS-6.5-x86_64-bin-DVD1.iso /iso

步骤3:设置/etc/yum.repos.d/CentOS-Media.repo,基本原理指定光盘的挂载点

# CentOS-Media.repo

#说明,这个源能够使用挂载的DVD源,指定一个挂载点。可以使用这个源,利用yum

#直接从光盘镜像中安装软件

#  This repo can be used with mounted DVD media, verify the mount point for

#  CentOS-6.  You can use this repo and yum to install items directly off the

#  DVD ISO that we release.

#说明:为了使用这个源,必须接上DVD,同时使用如下的指令:

#yum --enablerepo=c6-media  install  XXXX

# To use this repo, put in your DVD and use it with the other repos too:

#  yum --enablerepo=c6-media [command]

#说明:如果你只想或者只能够使用媒体安装源,必须使用如下的命令:

#yum --disablerepo=\* --enablerepo=c6-media install perl

# or for ONLY the media repo, do this:

#

#  yum --disablerepo=\* --enablerepo=c6-media [command]


[c6-media]

name=CentOS-$releasever - Media

###################修改的语句#######################

baseurl=file:///iso/

###########指定光盘的挂载点#########################

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

保存退出。

步骤4:yum --disablerepo=\* --enablerepo=c6-media install perl

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

c6-media                                                 | 4.0 kB     00:00 ... 

c6-media/primary_db                                      | 4.4 MB     00:00 ... 

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package perl.x86_64 4:5.10.1-136.el6 will be installed

--> Processing Dependency: perl-libs = 4:5.10.1-136.el6 for package: 4:perl-5.10.1-136.el6.x86_64

--> Processing Dependency: perl-libs for package: 4:perl-5.10.1-136.el6.x86_64

--> Processing Dependency: perl(version) for package: 4:perl-5.10.1-136.el6.x86_64

--> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-136.el6.x86_64

--> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-136.el6.x86_64

--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.10.1-136.el6.x86_64

--> Running transaction check

---> Package perl-Module-Pluggable.x86_64 1:3.90-136.el6 will be installed

---> Package perl-Pod-Simple.x86_64 1:3.13-136.el6 will be installed

--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-136.el6.x86_64

---> Package perl-libs.x86_64 4:5.10.1-136.el6 will be installed

---> Package perl-version.x86_64 3:0.77-136.el6 will be installed

--> Running transaction check

---> Package perl-Pod-Escapes.x86_64 1:1.04-136.el6 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


================================================================================

 Package                   Arch       Version                Repository    Size

================================================================================

Installing:

 perl                      x86_64     4:5.10.1-136.el6       c6-media      10 M

Installing for dependencies:

 perl-Module-Pluggable     x86_64     1:3.90-136.el6         c6-media      40 k

 perl-Pod-Escapes          x86_64     1:1.04-136.el6         c6-media      32 k

 perl-Pod-Simple           x86_64     1:3.13-136.el6         c6-media     212 k

 perl-libs                 x86_64     4:5.10.1-136.el6       c6-media     578 k

 perl-version              x86_64     3:0.77-136.el6         c6-media      51 k


Transaction Summary

================================================================================

Install       6 Package(s)


Total download size: 11 M

Installed size: 36 M

Is this ok [y/N]: y

Downloading Packages:

--------------------------------------------------------------------------------

Total                                            20 MB/s |  11 MB     00:00     

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Importing GPG key 0xC105B9DE:

 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>

 Package: centos-release-6-5.el6.centos.11.1.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)

 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

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 : 1:perl-Pod-Escapes-1.04-136.el6.x86_64                       1/6 

  Installing : 4:perl-libs-5.10.1-136.el6.x86_64                            2/6 

  Installing : 1:perl-Pod-Simple-3.13-136.el6.x86_64                        3/6 

  Installing : 3:perl-version-0.77-136.el6.x86_64                           4/6 

  Installing : 1:perl-Module-Pluggable-3.90-136.el6.x86_64                  5/6 

  Installing : 4:perl-5.10.1-136.el6.x86_64                                 6/6 

  Verifying  : 1:perl-Module-Pluggable-3.90-136.el6.x86_64                  1/6 

  Verifying  : 1:perl-Pod-Escapes-1.04-136.el6.x86_64                       2/6 

  Verifying  : 4:perl-5.10.1-136.el6.x86_64                                 3/6 

  Verifying  : 4:perl-libs-5.10.1-136.el6.x86_64                            4/6 

  Verifying  : 1:perl-Pod-Simple-3.13-136.el6.x86_64                        5/6 

  Verifying  : 3:perl-version-0.77-136.el6.x86_64                           6/6 


Installed:

  perl.x86_64 4:5.10.1-136.el6                                                  


Dependency Installed:

  perl-Module-Pluggable.x86_64 1:3.90-136.el6                                   

  perl-Pod-Escapes.x86_64 1:1.04-136.el6                                        

  perl-Pod-Simple.x86_64 1:3.13-136.el6                                         

  perl-libs.x86_64 4:5.10.1-136.el6                                             

  perl-version.x86_64 3:0.77-136.el6                                            


Complete!

步骤5:详细说明和参考文档的不同

参考文档使用的是:c5-media  而我们使用的是c6-media,因为使用centos6.4版本。

在使用yum进行install时,经常会出现下面的错误 
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 1ac70ce6 
导致安装不能进行。解决方法如下: 
[root@localhost CentOS]# rpm --import   /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 
[root@localhost CentOS]# rpm --import   /etc/pki/rpm-gpg/RPM-GPG-KEY-beta