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 CentOS-Debuginfo.repo CentOS-Media.repo
#新建local.repo文件,或者也可以对自带的.repo文件进行编辑
# vi local.repo
#输入以下内容后保存
[centos] #库名称,可以自取
name=centos #自定义名称,可以自取
baseurl=file:///mnt #本地光盘的挂载点
gpgcheck=0 #检查GPG-KEY,0:不检查 1:检查
enabled=1 #启用yum源,0:不启用 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 mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 - ""
Error: Cannot find a valid baseurl for repo: base
#说明:
此处出错了,错误原因是自带yum源中包含了错误中的url连接,而url需要访问网络,当无法访问时就出现错误了,解决方法:把自带repo都移到bak目录,仅用自己创建的yum源
# mkdir bak
# ls
bak CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo local.repo
# 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 be
updated
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================
Package
Arch
Version
Repository
Size
===========================================================================
Installing:
gcc
x86_64
4.4.4-13.el6
centos
10 M
Installing for dependencies:
cloog-ppl
x86_64
0.15.7-1.2.el6
centos
93 k
...
Transaction Summary
===========================================================================
Install
9 Package(s)
Upgrade
0 Package(s)
Total download size: 18 M
Installed size: 38 M
#此处输入Y,回车,下载安装
Is this ok [y/N]: y
Downloading Packages:
---------------------------------------------------------------------------
Total
43 MB/s |
18 MB
00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing
: ppl-0.10.2-11.el6.x86_64
1/9
Installing
: cloog-ppl-0.15.7-1.2.el6.x86_64
2/9
Installing
: mpfr-2.4.1-6.el6.x86_64
3/9
Installing
:
cpp-4.4.4-13.el6.x86_64
4/9
...
Complete!
#查找软件组包,比如查找X桌面系统包
# yum grouplist | grep X
Legacy X Window System compatibility
X
Window System
Legacy UNIX compatibility
TeX
support
Xhosa Support
#安装组包
# yum groupinstall "X Window System"
...
注意:组包包名含空格时,整个包名必须用双引号
好了,下次使用时,只需要再次加载关盘就可直接使用yum命令,无需再配置yum源