redhat一直都习惯直接通过DVD挂载本地yum源,直接安装自带的版本软件包,而centos由于提供在线yum源,一般都在线直接yum install,但是在线安装的可能是更新的版本,与系统自带的不匹配,比如需要安装一个kernel-devel,而在线版本比所安装的centos的kernel版本高,那么就只有去网上下载对应版本了,比较麻烦,直接挂载dvd,安装对应的devel可能会省一些事
由于两个系统yum配置里稍有不同,所以一直也没去研究,今天试了下,其实照葫芦画瓢,区别不大
1:塞进CentOS DVD光盘,将网络关掉
正常情况下在/media下面会出现挂载上去的dvd,如:
# ls /media/
CentOS_6.4_Final
但如果实在没有,那就通过mount命令挂载一下:
mkdir –p /media/CentOS
mount –t iso9660 /dev/cdrom /media/CentOS
2:配置本地repo
cd /etc/yum.repos.d
vim local.repo 可配置以下内容:
[local]
name=local repo
baseurl=file:///media/CentOS_6.4_Final
enabled=1
gpgcheck=0
如果按1中mount的dvd,baseurl最后就是CentOS;至于gpgcheck如果是1没修改为0,就必须要写gpgkey,其实直接修改成0就行了
3:yum update
yum clean all
yum list
# yum list
Loaded plugins: fastestmirror, priorities, refresh-packagekit, security
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 – “Couldn’t resolve host ‘mirrorlist.centos.org'”
Error: Cannot find a valid baseurl for repo: base
好吧,原因是,网络被关了,而默认首先读的是Base这个repo的内容,而这个链接是没办法连接的,所以只需要把Base这个repo重命名一下即可:
mv CentOS-Base.repo CentOS-Base.repo.bak
再来试试就搞定了
# yum list | more
Loaded plugins: fastestmirror, priorities, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Installed Packages
ConsoleKit.x86_64 0.4.1-3.el6 @anaconda-CentOS-201303020151.x86_64/6.4
ConsoleKit-libs.x86_64 0.4.1-3.el6 @anaconda-CentOS-201303020151.x86_64/6.4
ConsoleKit-x11.x86_64 0.4.1-3.el6 @anaconda-CentOS-201303020151.x86_64/6.4
DeviceKit-power.x86_64 014-3.el6 @anaconda-CentOS-201303020151.x86_64/6.4
GConf2.x86_64 2.28.0-6.el6 @anaconda-CentOS-201303020151.x86_64/6.4
GConf2-devel.x86_64 2.28.0-6.el6 @anaconda-CentOS-201303020151.x86_64/6.4
……………………………………………………………………………………………………………………