配置本地yum源

摘要:当我们使用光盘安装系统以后,还有很多包没有安装,此时,我们可以将那些包配置成本地的源,方便以后的安装。让然,你可以更懒惰一点,直接把那些包拷贝过来,然后使用rpm -ivh的命令进行安装。本文,主要根据RHEL6.4和centos5.8两个版本,讲解了本地yum源的搭建方法。


 

1.挂载iso到/mnt目录下 

mount -o loop rhel6.iso /mnt

mount /dev/cdrom /mnt

 

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


2.1centos 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


2.2)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) <[email protected]>" 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!

你可能感兴趣的:(yum,本地软件源)