1、将ISO镜像插入虚拟机或者光驱

2、创建一个yum.repo文件



[root@node1 ~]# cd /etc/yum.repos.d/
[root@node1 yum.repos.d]# ls
rhel-debuginfo.repo
[root@node1 yum.repos.d]# cp rhel-debuginfo.repo yum.repo


3、编辑yum.repo文件

编辑之前



[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-debuginfo-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


编辑之后 



[base]
name=Red Hat Enterprise Linux
baseurl=file:///media/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


4、挂载光盘



[root@node1 yum.repos.d]# mount /dev/cdrom /media/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@node1 yum.repos.d]#


5、通过yum进行安装软件包



[root@oggsource ~]# yum install strace
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package strace.i386 0:4.5.18-5.el5_4.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================
Installing:
strace i386 4.5.18-5.el5_4.1 base 171 k

Transaction Summary
==============================================================================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)

Total download size: 171 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : strace 1/1

Installed:
strace.i386 0:4.5.18-5.el5_4.1

Complete!
[root@oggsource ~]#


6、操作完成

############################################################################################################################

############################################################################################################################

############################################################################################################################

############################################################################################################################

############################################################################################################################

在Oracle Linux Server release 6.3上配置yum源

配置环境:



[root@RACDG ~]# uname -a
Linux RACDG.localdomain 2.6.39-200.24.1.el6uek.x86_64 #1 SMP Sat Jun 23 02:39:07 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@RACDG ~]# more /etc/issue
Oracle Linux Server release 6.3
Kernel \r on an \m


1、虚拟机或者物理机上插入安装光盘

2、编辑public-yum-ol6.repo文件

编辑之前,最好先备份一份源文件



[root@CQRAC ~]# cd /etc/yum.repos.d/
[root@CQRAC yum.repos.d]# ls
public-yum-ol6.repo
[root@CQRAC yum.repos.d]# cp public-yum-ol6.repo public-yum-ol6.repo.bak


修改前的public-yum-ol6.repo



[ol6_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/latest/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1

[ol6_ga_base]
name=Oracle Linux $releasever GA installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/0/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_u1_base]
name=Oracle Linux $releasever Update 1 installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/1/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_u2_base]
name=Oracle Linux $releasever Update 2 installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/2/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_u3_base]
name=Oracle Linux $releasever Update 3 installation media copy ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/3/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=0

[ol6_UEK_latest]
name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/UEK/latest/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1

[ol6_UEK_base]
name=Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)


修改后的public-yum-ol6.repo



[base]
name=Oracle Linux
baseurl=file:///media/Server
gpgcheck=0
enabled=1


3、mount安装光盘镜像



[root@CQRAC ~]# mount /dev/cdrom /media
mount: block device /dev/sr0 is write-protected, mounting read-only


4、执行yum list测试一下配置是否成功,如果能够list出结果,说明配置成功



[root@CQRAC ~]# yum list
...
...
...
xorg-x11-server-common.x86_64 1.10.6-1.el6 base
xorg-x11-server-utils.x86_64 7.5-5.2.el6 base
xorg-x11-twm.x86_64 1:1.0.3-5.1.el6 base
xorg-x11-utils.x86_64 7.4-8.el6 base
xorg-x11-xauth.x86_64 1:1.0.2-7.1.el6 base
xorg-x11-xdm.x86_64 1:1.1.6-14.1.el6 base
xorg-x11-xinit.x86_64 1.0.9-13.el6 base
xorg-x11-xkb-utils.x86_64 7.4-6.el6 base
xrestop.x86_64 0.4-7.1.el6 base
xsane.x86_64 0.997-8.0.1.el6 base
xsane-common.x86_64 0.997-8.0.1.el6 base
xsane-gimp.x86_64 0.997-8.0.1.el6 base
xsettings-kde.x86_64 0.11-1.el6 base
xterm.x86_64 253-1.el6 base
xulrunner.i686 10.0.5-1.0.1.el6_2 base
xulrunner.x86_64 10.0.5-1.0.1.el6_2 base
xvattr.x86_64 1.3-18.el6 base
xz-devel.i686 4.999.9-0.3.beta.20091007git.el6 base
xz-devel.x86_64 4.999.9-0.3.beta.20091007git.el6 base
xz-libs.i686 4.999.9-0.3.beta.20091007git.el6 base
yajl.i686 1.0.7-3.el6 base
yelp.x86_64 2.28.1-13.el6_2 base
ypserv.x86_64 2.19-22.el6 base
yum-plugin-aliases.noarch 1.1.30-14.el6 base
yum-plugin-changelog.noarch 1.1.30-14.el6 base
yum-plugin-downloadonly.noarch 1.1.30-14.el6 base
yum-plugin-tmprepo.noarch 1.1.30-14.el6 base
yum-plugin-verify.noarch 1.1.30-14.el6 base
yum-plugin-versionlock.noarch 1.1.30-14.el6 base
yum-presto.noarch 0.6.2-1.el6 base
zenity.x86_64 2.28.0-1.el6 base
zlib.i686 1.2.3-27.el6 base
zlib-devel.i686 1.2.3-27.el6 base
zlib-devel.x86_64 1.2.3-27.el6 base
zsh.x86_64 4.3.10-5.el6 base


5、配置成功