RHEL Centos7 Yum網絡源與光盤源設置

RHEL 官方擴展源


  首先我們可以使用下RHEL的官方源.命令很簡單


# yum localinstall http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm -y


 若發現它報個404之類的,去 http://dl.fedoraproject.org/pub/epel/7/x86_64/e/ 找找看 epel-release 開頭的rpm package,或許有更新,總之裝個epel-release*.rpm後,看/etc/yum.repos.d/文件夾下就多了兩個文件如下:


-rw-r--r-- 1 root root  957 Jun 19 07:20 epel.repo

-rw-r--r-- 1 root root 1056 Jun 19 07:20 epel-testing.repo

  你若沒有特別的需求,你應該只要有epel.repo就可以.


  epel.repo


[epel]

name=Extra Packages for Enterprise Linux 7 - $basearch

#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

 

[epel-debuginfo]

name=Extra Packages for Enterprise Linux 7 - $basearch - Debug

#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1

 

[epel-source]

name=Extra Packages for Enterprise Linux 7 - $basearch - Source

#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1 

  你也可以直接把上面那些內容寫到/etc/yum.repos.d/epel.repo文件中.

  然後:# yum makecache  這樣就可以用了。


  嘗試是否成功也很容易


# yum repolist

......

repo id      repo name                                       status

epel/x86_64  Extra Packages for Enterprise Linux 7 - x86_64  5,425

...... 

  發現有高亮一欄就算過了.


remi源


  安裝和RHEL差不多,這個源主要是提供了一些php相關的擴展庫,若不使用php,意義感覺不算大.


# yum localinstall http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

  同樣可以在/etc/yum.repos.d/中看到多了個remi.repo

  編輯可以看到內容如下:


[remi]

name=Les RPM de remi pour Enterprise Linux 7 - $basearch

#baseurl=http://rpms.famillecollet.com/enterprise/7/remi/$basearch/

mirrorlist=http://rpms.famillecollet.com/enterprise/7/remi/mirror

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-php55]

name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 7 - $basearch

#baseurl=http://rpms.famillecollet.com/enterprise/7/php55/$basearch/

mirrorlist=http://rpms.famillecollet.com/enterprise/7/php55/mirror

# WARNING: If you enable this repository, you must also enable "remi"

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-php56]

name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 7 - $basearch

#baseurl=http://rpms.famillecollet.com/enterprise/7/php56/$basearch/

mirrorlist=http://rpms.famillecollet.com/enterprise/7/php56/mirror

# WARNING: If you enable this repository, you must also enable "remi"

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-test]

name=Les RPM de remi en test pour Enterprise Linux 7 - $basearch

#baseurl=http://rpms.famillecollet.com/enterprise/7/test/$basearch/

mirrorlist=http://rpms.famillecollet.com/enterprise/7/test/mirror

# WARNING: If you enable this repository, you must also enable "remi"

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-debuginfo]

name=Les RPM de remi pour Enterprise Linux 7 - $basearch - debuginfo

baseurl=http://rpms.famillecollet.com/enterprise/7/debug-remi/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-php55-debuginfo]

name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 7 - $basearch - debuginfo

baseurl=http://rpms.famillecollet.com/enterprise/7/debug-php55/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-php56-debuginfo]

name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 7 - $basearch - debuginfo

baseurl=http://rpms.famillecollet.com/enterprise/7/debug-php56/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-test-debuginfo]

name=Les RPM de remi en test pour Enterprise Linux 7 - $basearch - debuginfo

baseurl=http://rpms.famillecollet.com/enterprise/7/debug-test/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi 

  默認enable全是0,根據需要自行將enable改爲1,注意高亮的第五行enable必須改爲1 remi才能用.


  然後makecache 測試什麼的就和RHEL一樣不細說了.


puias源


      puias 是基於RH的一個擴展distribution和mirror。無論是CentOS 5,6還是7都可以得到它的一些擴展的程序。尤其是科學計算領域的一些模塊,果斷是要入手的。目前它由普林斯頓高能所維護。

  你去它的官網可以得到很多說明。比如這個頁面

  我們可以只選擇計算的部分如下:


  puias-computational.repo


[PUIAS_computational]

name=PUIAS computational Base $releasever - $basearch

mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist

#baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias 

  /etc/yum.repo.d/下建立文件,保存即可。


  因爲我們這次沒有使用rpm包,所以需要import一下GPG KEY.


rpm --import http://puias.princeton.edu/data/puias/7/x86_64/os/RPM-GPG-KEY-puias 

RepoForge源


   RepoForge原名RPMForge,是一個維護得很不錯的repo站點.點擊此處可以看到RHEL各版本的下載鏈接.拿到鏈接後


yum localinstall xxx.rpm -y 

  即可完成安裝。

  目前爲止似乎還沒有把centos 7加上,但是沒關係,隨便找個6的鏈接,把6變成7即可獲得該rpm包的大致位置。當前我得到的位置是 : http://apt.sw.be/redhat/el7/en/x86_64/rpmforge/RPMS/

  進入後找到rpmforge-release-**的文件,獲得下載鏈接,安裝即可。


yum localinstall http://apt.sw.be/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm -y

yum makecache


光盤源

默認的yum是以網絡來安裝的,在沒有網絡或者網速不佳的情況下,通過yum來安裝軟件是意見非常痛苦的事情,其實對於CentOS DVD來說,裏面提供的軟件就足以滿足我們的需要了,而且DVD裏的軟件版本都是穩定版,下載速度還快,對於學習CentOS來說,將CentOS DVD作爲默認yum源可以大大提高學習效率。

1、爲DVD創建一個掛載目錄

[root@localhost ~]# mkdir /media/CentOS

2、在Linux下掛載CentOS DVD(虛擬機掛載DVD不說了,應該都會)

[root@localhost ~]# mount -t auto /dev/cdrom /media/CentOS

3、查看相關配置文件,目錄爲

[root@localhost ~]# ls -l /etc/yum.repos.d/
-rw-r--r--. 1 root root 1926  7月  3 10:15 CentOS-Base.repo
-rw-r--r--. 1 root root  637  7月  3 10:15 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  626  7月  3 10:15 CentOS-Media.repo

4、禁用yum的網絡更新方式,簡單地將默認首選的CentOS-Base.repo改名爲CentOS-Base.repo.bak即可

[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak

5、配置本地yum源

[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Media.repo

[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=0

修改爲

[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
gpgcheck=1
enabled=1

其中baseurl修改爲DVD的掛載目錄,enabled=1開啓本地更新模式

:wq 保存退出

6、清除原有的yum信息

[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning up Everything

7、檢查DVD軟件列表

[root@localhost yum.repos.d]# yum list
Loaded plugins: fastestmirror
Determining fastest mirrors
c6-media                                                | 3.7 kB    00:00 ...
c6-media/primary_db                                      | 3.3 MB    00:00 ...

這樣以後就默認使用DVD安裝軟件了,如果想恢復網絡安裝模式,將 CentOS-Base.repo.bak 更名還原即可。

PS.每次重啓系統後需要手工掛載DVD到/media/CentOS/,如果嫌麻煩可以自己寫腳本自動掛載。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章