RHEL6.5使用安裝光碟搭建本地YUM

stonebox1122發表於2015-07-24
1、掛載光碟
[root@linuxclient ~]# mount /dev/cdrom /media/
mount: block device /dev/sr0 is write-protected, mounting read-only

2、備份系統的repo檔案
[root@linuxclient ~]# cd /etc/yum.repos.d/
[root@linuxclient yum.repos.d]# ls
CentOS6-Base-163.repo  rhel-source.repo
[root@linuxclient yum.repos.d]# mkdir bak
[root@linuxclient yum.repos.d]# mv *.repo bak/
[root@linuxclient yum.repos.d]# ls
bak

3、建立本地的repo檔案
[root@linuxclient yum.repos.d]# vim local.repo
[root@linuxclient yum.repos.d]# cat local.repo
[Local]
baseurl=file:///media/Server
gpgcheck=1
enabled=1

4、匯入金鑰(如果上面的gpgcheck=0,這一步可以跳過)
[root@linuxclient yum.repos.d]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*

5、清除快取
[root@linuxclient yum.repos.d]# yum clean all
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.
Repository 'Local' is missing name in configuration, using id
Cleaning repos: Local
Cleaning up Everything

6、重新生成快取
[root@linuxclient yum.repos.d]# yum makecache
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.
Repository 'Local' is missing name in configuration, using id
Local                                                                                                             | 3.9 kB     00:00 ...
Local/group_gz                                                                                                    | 204 kB     00:00 ...
Local/filelists_db                                                                                                | 3.8 MB     00:00 ...
Local/primary_db                                                                                                  | 3.1 MB     00:00 ...
Local/other_db                                                                                                    | 1.6 MB     00:00 ...
Metadata Cache Created

7、根據以上步驟編寫指令碼

[root@precise ~]# cat createlocalyum.sh

#!/bin/bash

cd /etc/yum.repos.d/

mkdir bak

mv *.repo bak/

cat << EOF > local.repo

[Local]

baseurl=file:///media/Server

gpgcheck=1

enabled=1

EOF

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*

yum clean all

yum makecache


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28536251/viewspace-1750096/,如需轉載,請註明出處,否則將追究法律責任。

相關文章