RHEL6.0下本地yum源的配置
说明:在使用yum命令安装软件的时候,必须提前配置yum源,本文以挂载RHEl6的官方镜像至本地,创建本地yum源。
在RHEl6中默认在/etc/yum.repos.d/目录下没有*.repo的文件,需要自己手动建立一个。
1.挂载官方镜像至本地并实现开机自动挂载
# mount /dev/dvd /media
# ls /media
此时我们看到已经成功挂载官方镜像至/media下了。
# vim /etc/fstab #添加如下一句,实现开机自动挂载
/dev/dvd /mnt iso9660 defaults,loop 0 0
说明:挂载时一定要指定文件类型为iso9660,否则会挂载失败
2.查看系统是否已经成功安装yum相关包
- [root@lihuan ~]# rpm -qa | grep yum
- yum-rhn-plugin-0.9.1-5.el6.noarch
- yum-utils-1.1.26-11.el6.noarch
- yum-metadata-parser-1.1.2-14.1.el6.i686
- yum-3.2.27-14.el6.noarch
默认都已经安装了。
3.手动编写yum源所需的文件
# cd /etc/yum.repos.d/ #在此目录下,建立任何以.repo结尾的文件即可,这里以yum.repo为例:
- # vim yum.local #内容如下
- [yum]
- name=yum
- baseurl=file:///media/
- enabled=1
- gpgcheck=1
- gpgkey=file:///media/ RPM-GPG-KEY-redhat-release
说明:如果设置gpgcheck=0则不检测gpgkey,就不检查文件签名,就不需要指定gpgkey的位置(建议使用本文的写法)
4.测试yum源是否可用
- # yum clean all #清除yum源缓存
- [root@lihuan ~]# yum install httpd -y
- Loaded plugins: rhnplugin
- This system is not registered with RHN.
- RHN support will be disabled.
- Setting up Install Process
- Resolving Dependencies
- --> Running transaction check
- ---> Package httpd.i686 0:2.2.15-5.el6 set to be updated
- --> Finished Dependency Resolution
- Dependencies Resolved
- ============================================================================================
- Package Arch Version Repository Size
- ============================================================================================
- Installing:
- httpd i686 2.2.15-5.el6 base 813 k
- Transaction Summary
- ============================================================================================
- Install 1 Package(s)
- Upgrade 0 Package(s)
- Total download size: 813 k
- Installed size: 2.8 M
- Downloading Packages:
- Running rpm_check_debug
- Running Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing : httpd-2.2.15-5.el6.i686 1/1
- Installed:
- httpd.i686 0:2.2.15-5.el6
- Complete!
说明:此时发现可以使用yum命令成功安装软件了。当然yum命令的好处不仅仅是安装软件,还有解决软件安装时的依赖关系,这样的方法安装软件就方便多了。
补充:关于yum命令的详细使用方法,可以使用man yum的方法获取帮助信息,一些简单yum命令的使用方法参照:http://lihuan.blog.51cto.com/4391550/800845。
例:
# man yum
yum(8) yum(8)
NAME
yum - Yellowdog Updater Modified
SYNOPSIS
yum [options] [command] [package ...]
DESCRIPTION
yum is an interactive, rpm based, package manager. It can automatically
perform system updates, including dependency analysis and obsolete process-
ing based on "repository" metadata. It can also perform installation of new
packages, removal of old packages and perform queries on the installed
and/or available packages among many other commands/services (see below).
yum is similar to other high level package managers like apt-get and smart.
While there are some graphical interfaces directly to the yum code, more
recent graphical interface development is happening with PackageKit and the
gnome-packagekit application.
command is one of:
* install package1 [package2] [...]
* update [package1] [package2] [...]
* check-update
* upgrade [package1] [package2] [...]
* distribution-synchronization [package1] [package2] [...]
* remove | erase package1 [package2] [...]