Linux 创建本地YUM Repo

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/SSH_5523/article/details/51705494
一配置本地 YUM 源
--1.1 实验环境
RHEL6:虚拟机


--1.2 挂载光驱
[root@redhat6 yum.repos.d]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only

  备注:将光盘 ISO 文件挂载到目录 /mnt


--1.3 创建本地目录,用来 copy 光盘包
[root@redhat6 local_repo]# mkdir -p /opt/rpm/local_repo


--1.4 copy RPM 包到指定目录
[root@redhat6 log]# cd /mnt/Packages/
[root@redhat6 Packages]# cp * /opt/rpm/local_repo


--1.5 安装 createrepo 包
[root@redhat6 local_repo]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
warning: createrepo-0.9.8-4.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]
     
   备注:createrepo 包安装成功
  
 
--1.6 创建 repo 数据库
 

 [root@redhat6 local_repo]# createrepo -d /opt/rpm/local_repo
1944/2804 - MAKEDEV-3.24-6.el6.i686.rpm                                        
iso-8859-1 encoding on Ville [email protected]> - 2.8.2-2

2804/2804 - perl-Archive-Extract-0.38-119.el6_1.1.i686.rpm                     
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
 
        
  备注:这个步骤需要点时间。

  
--1.7 编写 /etc/yum.repos.d/local_repo.repo 文件

   文件 /etc/yum.repos.d/local_repo.repo   内容如下。



 [rhel-source]
name=Red Hat Enterprise Linux Local repo   ##仓库描述
baseurl=file:///opt/rpm/local_repo         ##软件仓库位置
enabled=1                                  ##是否启用
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release   ##签名秘钥



--1.8 测试


[root@localhost yum.repos.d]# yum search vim
Loaded plugins: fastestmirror, rhnplugin, security
Repository base is listed more than once in the configuration
Repository update is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository addons is listed more than once in the configuration
Repository rhel-source is listed more than once in the configuration
This system is not registered with RHN.
RHN support will be disabled.
Determining fastest mirrors
addons                                               | 1.9 kB     00:00    
addons/primary_db                                    | 1.1 kB     00:00    
base                                                 | 1.1 kB     00:00    
base/primary                                         | 1.3 MB     00:25    
base                                                              3667/3667
extras                                               | 2.1 kB     00:00    
extras/primary_db                                    | 173 kB     00:00    
rhel-source                                          | 1.9 kB     00:00    
rhel-source/primary_db                               | 2.0 MB     00:00    
update                                               | 1.9 kB     00:00    
update/primary_db                                    | 764 kB     00:15    
=============================== Matched: vim ===============================
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System.
vim-common.x86_64 : The common files needed by any version of the VIM
                  : editor.
vim-enhanced.x86_64 : A version of the VIM editor which includes recent
                    : enhancements.
vim-minimal.x86_64 : A minimal version of the VIM editor.
[root@localhost yum.repos.d]# cd /opt/rpm/local_repo
[root@localhost local_repo]# ls | grep vim
vim-common-7.0.109-7.el5.x86_64.rpm
vim-enhanced-7.0.109-7.el5.x86_64.rpm
vim-minimal-7.0.109-7.el5.x86_64.rpm
vim-X11-7.0.109-7.el5.x86_64.rpm

猜你喜欢

转载自blog.csdn.net/SSH_5523/article/details/51705494