配置 Linux 國內 yum 源

      若在內網中,無法連接互聯網,需要使用 yum,可參考博文 “使用DVD光盤或者ISO作爲本地YUM源”。

      執行命令 “rpm  -qa | grep  yum” 沒有返回值,或者 執行命令 “yum” 提示:沒有那個文件或目錄。均爲沒有安裝 yum 服務,如何安裝也參考博文 “使用DVD光盤或者ISO作爲本地YUM源”。

 

      步入正文,以 Red Hat Enterprese Linux 6.8 環境爲例(安裝好 redhat 後,不能註冊的話,不能使用系統自帶的 yum 源)。

      只需把如下內容保存到文本中,另存爲 “rhel-source.repo” 文件,複製到 Linux 系統 “/etc/yum.repos.d” 目錄下即可。

#rhel-source.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.

# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#

[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

參數說明:

      1)   [repoid] :倉庫的名稱,不能重複,獨一無二。通常 使用 [base](基礎包源)、[updates](更新/升級包源)、[extras](擴展包源)三個就夠了。

      2)name:倉庫的描述,若不寫將會用repoid當作name。

      3)baseurl:必須是有效的路徑,務必親測有效(國內很多 yum 的在線源可能已經失效,也存在鏡像的目錄已更新,如 系統發行版本的目錄名稱由 “6.0” 更新爲 “6”)。url支持的協議有 http://  ftp://  file:// 三種,baseurl 後可以跟多個 url,但 baseurl 只能有一個。

      4)enabled=1|0  激活或禁用倉庫,若不寫默認啓用。

      5)gpgcheck=1|0  是否在安裝包是檢測 gpg 簽名,默認檢測,即爲1。

      6)gpgkey:指定 reposity 的 gpg key 路徑。通常在各個 repository 站點首頁的醒目位置(如 163 源的 CentOS 地址爲 http://mirrors.163.com/centos/)。

      7)參數中的變量(如果系統獲取不到變量或獲取不正確,可將變量替換爲對應的版本和架構)

  • $releasever:發行版的版本。
  • $arch:cpu 體系。
  • $basearch:cpu 的基本體系組。

 
 另,

      安裝 EPEL(Extra Packages for Enterprise Linux )源。            

yum list | grep epel-release
yum install -y epel-release
yum clean all
yum makecache
yum repolist

 

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