Linux下配置本地yum源

梓沐發表於2016-02-15
原文地址:

```
[root@localhost ~]# mkdir /iso
[root@localhost ~]# mount /dev/cdrom /iso
```

```
[root@localhost iso]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel-source.repo
[root@localhost yum.repos.d]# touch iso.repo
```

```
[root@localhost yum.repos.d]# cat iso.repo
```

```
#yun源的名字,做到全域性唯一不重複
[rhel-iso]
#註釋資訊
name=Red Hat Enterprise Linux $releasever - $basearch - Source
#yum源的路徑,支援三種協議:http、ftp、file,其中file表示本地檔案,/iso才是真實路徑
baseurl=file:///iso
#1表示啟用,0表示禁用
enabled=1
#指紋校驗,為0表示不校驗
gpgcheck=0
#校驗參考的檔案
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release
```

```
[root@localhost yum.repos.d]# pwd
/etc/yum.repos.d
[root@localhost yum.repos.d]# ll
total 8
-rw-r--r--. 1 root root 173 Jul 23 19:09 iso.repo
-rw-r--r--. 1 root root 529 Apr 28  2011 rhel-source.repo
```

測試是否配置成功,還可以進入iso檢視是否有檔案

```
[root@larrywen yum.repos.d]# yum grouplist|grep Devel
  Additional Development
  Desktop Platform Development
  Development tools
  Server Platform Development
```

真實機配置本地yum源

```
[root@larrywen yum.repos.d]#mkdir /iso
[root@larrywen yum.repos.d]# cp rhel-source.repo iso.repo
```

```
[root@larrywen yum.repos.d]# cat iso.repo
```

```
#yun源的名字,做到全域性唯一不重複
[rhel-iso]
#註釋資訊
name=Red Hat Enterprise Linux $releasever - $basearch - Source
#yum源的路徑,支援三種協議:http、ftp、file,其中file表示本地檔案,/iso才是真實路徑
baseurl=file:///iso
#1表示啟用,0表示禁用
enabled=1
#指紋校驗,為0表示不校驗
gpgcheck=0
#校驗參考的檔案
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
```

本地需要掛載,使用mount命令即可

```
[root@larrywen yum.repos.d]# mount
/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso /iso -o loop
```

可以測試是否配置成功,還可以進入iso檢視是否有檔案

```
[root@larrywen yum.repos.d]# yum grouplist|grep Devel
Additional Development
Desktop Platform Development
Development tools
Server Platform Development
```

mount後重啟失效,要想永久生效,新增此句話

```
[root@localhost yum.repos.d]# echo "mount /dev/cdrom /iso" >> /etc/rc.local
[root@localhost yum.repos.d]# cat /etc/rc.local


#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
```

```
touch /var/lock/subsys/local
mount /dev/cdrom /iso
```

yum group安裝和解除安裝
安裝

```
[root@rac1 yum.repos.d]# yum groupinstall "Fonts"
```

解除安裝

```
[root@rac1 yum.repos.d]# yum groupremove "Fonts"
```



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

相關文章