標籤:
1、安裝vm-tools
2、設定共用資料夾,我設定的共用資料夾是E:\ProgramData 名稱:ProgramData
3、建立檔案夾 mkdir /media/CentOS/
4、掛載iso檔案
在CentOS中,設定檔案分享權限設定後,我們可以在/mnt/hgfs/目錄下發現一個ProgramData /子目錄,CentOS的iso檔案也就在該目錄下,本人共用以後,iso檔案在CentOS的路徑為
/mnt/hgfs/ProgramData/CentOS-6.3-x86_64-bin-DVD2.iso
將該鏡像檔案掛載到/media/CentOS/
[[email protected] yum.repos.d]# mount -o loop /mnt/hgfs/ProgramData/CentOS-6.3-x86_64-bin-DVD2.iso /media/CentOS/
5、修改設定檔
cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# more CentOS-Media.repo
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
# 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:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
其中 baseurl即是我們需要修改的參數,因為我們已經將iso鏡像掛載在/media/CentOS/目錄下了,所以不需要修改。yum本地源可以使用了。
6、使用本地yum源安裝軟體
使用本地yum源的方法在CentOS-Media.repo中已經描述了:
(4.1)除了使用本地yum源,也會是使用其他的yum源
yum --enablerepo=c6-media [command]
(4.2)只是用本地yum源
yum --disablerepo=/* --enablerepo=c6-media [command]
下面是用本地yum源安裝mysql
[[email protected] yum.repos.d]# yum --disablerepo=/* --enablerepo=c6-media install mysql-server
centos設定使用本地源