from:http://wangyan.org/blog/setup-local-yum-repo.html
一,本地
1、創建本地yum倉庫
1.
mkdir
-p /yum/
local
#可以有N級目錄
2.
cp
...
#復制RPM包到上述目錄
2、創建repo文件
/etc/yum.repo.d/Centos-local.repo:
1 [Local] # list出來的名字 2 name=Local Yum 3 baseurl=file:///yum/ 4 gpgcheck=1 5 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 6 enabled=1
3、安裝createrepo
yum
install
createrepo
#使用yum安裝createrepo
4、創建索引
1.
createrepo /yum #本地源的目錄
2.
yum makecache
#更新緩存
使用時可能需要臨時去掉網絡yum源:/etc/yum.repos.d/Centos-Base.repo:
enabled=0
二,光盤
一、使用CentOS光盤作為本地yum源
實體機上直接放入光盤
1.
mkdir
/mnt/cdrom
#創建目錄
2.
mount
/dev/cdrom /mnt/cdrom
#掛載
2、創建repo文件
/etc/yum.repos.d/CentOS-cdrom.repo
[cdrom] name=Local cdrom yum baseurl=file:///mnt/cdrom/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=1
問:為什么連createrepo軟件都不用安裝?
createrepo 的作用是創建索引文件的(位於repodata文件夾),光盤中連GPG-KEY都有了。