RHEL6.4 和centos5.8搭建本地yum源

rhel6 下载url
ed2k://|file|[红帽企业Linux.6.4.服务器版].rhel-server-6.4-i386-dvd[ED2000.COM].iso|3155165184|6c8dbe0e5816705cb190821547951ea0|h=m4gtwan6h4blg6wdsim4iyzknxt5c53l|/

 

1.挂载iso到/mnt目录下 
mount -o loop rhel6.iso /mnt

mount /dev/cdrom /mnt

 

2.创建repos和 修改 yumRepo.py配置文件

(centos 5.8)

mount /dev/cdrom /mnt

cd /etc/yum.repos.d/

cp CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bk

#vi CentOS-Debuginfo.repo 
[debug]
name=CentOS-5 - Debuginfo
#baseurl=http://debuginfo.centos.org/5/$basearch/
baseurl=file:///mnt
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
enabled=1

#vi /usr/lib/python2.4/site-packages/yum/yumRepo.py
remote = url + ‘/’ + relative  787行
为 
remote = "/mnt" + ‘/’ + relative


(redhat6.4)
vi /etc/yum.repos.d/rhel-debuginfo.repo 
[Server] 
name=Red Hat Enterprise Linux Server 
baseurl=file:///mnt 
enabled=1 
gpgcheck=1 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

vi /usr/lib/python2.6/site-packages/yum/yumRepo.py

remote = url + ‘/’ + relative  802行

remote = "/mnt" + ‘/’ + relative

4.安装rpm包测试本地yum源是否可用
redhat6.4安装成功表示搭建本地源成功

redhat6#yum install mysql (安装测试本地yum源是否可用)
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i686 0:5.1.66-2.el6_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch           Version                  Repository        Size
================================================================================
Installing:
 mysql           i686           5.1.66-2.el6_3           Server           895 k

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

Total download size: 895 k
Installed size: 2.3 M
Is this ok [y/N]: 


centos 5.8 安装成功表示搭建本地源成功

[root@contos yum.repos.d]# yum install mysql
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
debug                                                                                                  | 1.3 kB     00:00     
debug/primary                                                                                          | 1.2 MB     00:00     
debug                                                                                                               3595/3595
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i386 0:5.0.77-4.el5_6.6 set to be updated
--> Processing Dependency: perl(DBI) for package: mysql
---> Package mysql.x86_64 0:5.0.77-4.el5_6.6 set to be updated
--> Running transaction check
---> Package perl-DBI.x86_64 0:1.52-2.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================
 Package                      Arch                       Version                              Repository                 Size
==============================================================================================================================
Installing:
 mysql                        i386                       5.0.77-4.el5_6.6                     debug                     4.8 M
 mysql                        x86_64                     5.0.77-4.el5_6.6                     debug                     4.8 M
Installing for dependencies:
 perl-DBI                     x86_64                     1.52-2.el5                           debug                     600 k

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

Total download size: 10 M
Is this ok [y/N]: y
Downloading Packages:
------------------------------------------------------------------------------------------------------------------------------
Total                                                                                          85 MB/s |  10 MB     00:00     
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
debug/gpgkey                                                                                           | 1.5 kB     00:00     
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : perl-DBI                                                                                               1/3 
  Installing     : mysql                                                                                                  2/3 
  Installing     : mysql                                                                                                  3/3 

Installed:
  mysql.i386 0:5.0.77-4.el5_6.6                                mysql.x86_64 0:5.0.77-4.el5_6.6                               

Dependency Installed:
  perl-DBI.x86_64 0:1.52-2.el5                                                                                                

Complete!