linux配置本地YUM源
1、檢視已將安裝的作業系統版本
[root@min-base ~]#cat /etc/redhat-release
CentOS Linuxrelease 7.2.1511 (Core)
2、下載並掛在iso映象
接下來就是將iso的光碟映象進行掛載了
mount-t iso9660 -o loop CentOS-7-x86_64-DVD-1503-01.iso /mnt
(如果是掛載插入的光碟,只需要輸入命令mount/dev/cdrom /mnt/,其餘的操作是相同的)
掛載CentOS-7-x86_64-Everything-1511.iso,把裡面所有檔案都拷貝到本地目錄/yum/yum-iso
[root@min-base ~]#mkdir /mnt/yum-iso
[root@min-base ~]#mount –o loop xx.iso /mnt/yum-iso/
mount: /dev/sr0 is write-protected,mounting read-only
[root@min-base ~]#mkdir /yum/
[root@min-base ~]#cp -a /mnt/yum-iso/ /yum/
[root@min-base ~]#ll /yum/
total 4
dr-xr-xr-x. 8 root root 4096 Dec 10 2015 yum-iso
[root@min-base ~]#ll /yum/yum-iso/
total 640
-r--r--r--. 1 root root 14 Dec 10 2015 CentOS_BuildTag
dr-xr-xr-x. 3 root root 33 Dec 10 2015 EFI
-r--r--r--. 1 root root 215 Dec 10 2015 EULA
-r--r--r--. 1 root root 18009 Dec 10 2015 GPL
dr-xr-xr-x. 3 root root 69 Dec 10 2015 images
dr-xr-xr-x. 2 root root 4096 Dec 10 2015 isolinux
dr-xr-xr-x. 2 root root 41 Dec 10 2015 LiveOS
dr-xr-xr-x. 2 root root 483328 Dec 10 2015 Packages
dr-xr-xr-x. 2 root root 4096 Dec 10 2015 repodata
-r--r--r--. 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-r--r--r--. 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Dec 10 2015 TRANS.TBL
[root@min-base ~]#
3、備份、移除其他repo
[root@min-base ~]#cd /etc/yum.repos.d/
[root@min-base yum.repos.d]# ll
-rw-r--r--. 1 root root 1664 Dec 9 2015CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Dec 9 2015CentOS-CR.repo
-rw-r--r--. 1 root root 649Dec 9 2015CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 290Dec 9 2015 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630Dec 9 2015 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Dec 9 2015CentOS-Sources.repo
-rw-r--r--. 1 root root 1952 Dec 9 2015CentOS-Vault.repo
[root@min-base yum.repos.d]# tar zcvf repo-bk.tar.gz CentOS-*
CentOS-Base.repo
CentOS-CR.repo
CentOS-Debuginfo.repo
CentOS-fasttrack.repo
CentOS-Media.repo
CentOS-Sources.repo
CentOS-Vault.repo
[root@min-base yum.repos.d]# rm -f CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-Vault.repo
4 、配置本地repo
[root@min-base yum.repos.d]# vi CentOS-Media.repo
填入如下內容
[c7-media]
name=CentOS-$releasever- Media
baseurl=file:///yum/yum-iso/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
註釋:配置repo路徑、關閉gbp校驗、啟用這個repo
5、製作cache
[root@min-base yum.repos.d]# yum clean all
Loaded plugins:fastestmirror
Cleaning repos:c7-media
Cleaning upeverything
Cleaning up listof fastest mirrors
[root@min-base yum.repos.d]# yum makecache
Loaded plugins:fastestmirror
c7-media| 3.6 kB 00:00:00
(1/4): c7-media/group_gz| 155 kB 00:00:00
(2/4): c7-media/primary_db| 5.3 MB 00:00:00
(3/4): c7-media/filelists_db| 6.2 MB 00:00:00
(4/4): c7-media/other_db| 2.3 MB 00:00:00
Determiningfastest mirrors
Metadata CacheCreated
[root@min-base yum.repos.d]#
這樣就可以使用yum安裝軟體啦!