在線yum安裝必須要保持服務器能夠連入網絡並且他下載的還會比較慢因為地址大部分多是國外的下載站。另外yum在線下載的都是比較新的軟件包,可能不是很穩定,那么使用yum的本地資源就是光盤里的RPM包,讓本地光盤作為yum源,這種源的版本可能不是最新的但是相對比較穩定,這種方式一般在工作中比常用。下面就來介紹下光盤yum源安裝。
第一步:
虛擬機以vmwareworkstations 為例安裝centos6.5虛擬機 並設置連接鏡像1
第二步:掛載光盤
[root@server ~]#mkdir cdrom //創建掛載點。
[root@server ~]# mount /dev/sr0 /mnt/cdrom //手動掛載。
[root@server ~]# mount

//顯示已經掛載成功。
第三步:將默認的網絡yum源失效
[root@server ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo[Y1]
[Y1]默認情況下使用的是第一個也就是網絡yum源文件生效,如果使他生效只需要將enable=1即可。如果讓所有的yum源不生效那么把enable=0就可以。
第三步:修改yum源 配置文件 生效
[root@server ~]# vi /etc/yum.repos.d/CentOS-Media.repo
# CentOS-Media.repo
#
# 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.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c6-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c6-media [command]
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/ //將這里修改為光盤掛載的地址
# file:///media/cdrecorder/ //將這兩個沒用的地址給注釋掉就是#掉
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
"/etc/yum.repos.d/CentOS-Media.repo" 21L, 629C
:wq!//保存退出
第五步:查看rpm包文件 搭建成功



