Linux 配置iso系统盘为本地yum源
![此博文包含图片](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
Linux配置iso系统盘为本地yum源
by:授客QQ:1033553122
1、目的
安装软件时,经常会遇到包或类库的依赖性问题,为此,我们可以通过yum命令安装软件,尽量避免出现繁琐的软件依赖关系。
2、操作步骤
以CentOS-6.0-x86_64-bin-DVD1.iso为例
步骤1.挂载光盘
# mount /dev/cdrom /mnt
步骤2.配置.repo文件
# cd /etc/yum.repos.d/
# ls
CentOS-Base.repo
#新建local.repo文件,或者也可以对自带的.repo文件进行编辑
# vi local.repo
#输入以下内容后保存
[centos]
name=centos
baseurl=file:///mnt #本地光盘的挂载点
gpgcheck=0 #检查GPG-KEY,0:不检查1:检查
enabled=1
注意:
如果设置gpgcheck=1,则必须配置gpgkey,形如以下
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
步骤3.清除yum缓存
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning up Everything
步骤4.更新yum源
[root@localhost yum.repos.d]# yum update
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlisthttp://mirrorlist.centos.org/?release=6&arch=x86_64&repo=oserror was
14: PYCURL ERROR 6 - ""
Error: Cannot find a valid baseurl for repo: base
#说明:
此处出错了,错误原因是自带yum源中包含了错误中的url连接,而url需要访问网络,当无法访问时就出现错误了,解决方法:把自带repo都移到bak目录,仅用自己创建的yum源
# mkdir bak
# ls
bak
# mv CentOS*.* bak
然后重复步骤3&4
# yum clean all
# yum update
到此,已经配置好本地yum源了
步骤5.其它操作
#查找单个软件包,比如查找名称中包含gcc的软件包
#安装软件包,比如gcc
[root@localhost yum.repos.d]# yum install gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
...
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.32-71.el6 set to beupdated
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================Package
===========================================================================
Installing:
Installing for dependencies:
...
Transaction Summary
===========================================================================
Install
Upgrade
Total download size: 18 M
Installed size: 38 M
#此处输入Y,回车,下载安装
Is this ok [y/N]: y
Downloading Packages:
---------------------------------------------------------------------------
Total
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
...
Complete!
#查找软件组包,比如查找X桌面系统包
# yum grouplist | grep X
#安装组包
# yum groupinstall "X Window System"
...
注意:组包包名含空格时,整个包名必须用双引号
好了,下次使用时,只需要再次加载关盘就可直接使用yum命令,无需再配置yum源