1. 程式人生 > >Redhat 6.2 配置使用epel 和 163 yum源來安裝saltstack過程

Redhat 6.2 配置使用epel 和 163 yum源來安裝saltstack過程

由於紅帽線上yum更新需要註冊,沒有註冊redhat的機器,更新會提示    This system is not registered with RHN.

由於需要安裝saltstack,可以先配置epel源。到官網下載對應紅帽系統版本的yum源安裝包

rpm -ivh epel-release-6-8.noarch.rpm 安裝。

匯入key:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

配置EPEL YUM源

在rhel中執行命令:

#yum repolist

報錯:

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again


解決過程:

安裝了epel-release-6-8.noarch.rpm以後,會在/etc/yum.repos.d目錄下,新增兩個檔案:

epel.repo                     #這是標準的epel源,經過測試,並且比較穩定的

epel-testing.repo         #這是最新的,正在測試階段。

預設情況下,yum會搜尋/etc/yum.repos.d目錄下所有的檔案,搜尋其中的yum 源。搜尋的前提是enable=1,如果是enable=0就不搜尋該源了。

經過對比發現,上述錯誤中的epel,表示在epel.repo中發現問題。

開啟epel.repo後發現

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

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

將其修改為:

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

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

即可。

由於本地光碟和epel源沒有 PyYAML ,所以安裝saltstack仍然不成功,配置網易163的yum源即可。

網上存在文章說需要解除安裝yum,安裝centos來配置網易163的yum源,我操作時,可以直接配置163源來使用,沒有做前3步。

一、需要刪除RHEL原有的yum
             rpm -aq|grep yum|xargs rpm -e --nodeps  #刪除

二、然後下載新的yum安裝包  #這裡我們使用CentOS的yum源

三、安裝yum軟體包

rpm -ivh  python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh  yum-metadata-parser-1.1.2-14.1.el6.i686.rpm
rpm -ivh  yum-3.2.27-14.el6.centos.noarch.rpm  yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm

 注意:最後兩個安裝包要放在一起同時安裝,否則會提示相互依賴,安裝失敗。


四、更改yum源  #我們使用網易的CentOS映象源
cd /etc/yum.repos.d/
wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo
vi CentOS6-Base-163.repo  #編輯檔案

把檔案裡面的$releasever全部替換為版本號,即6 最後儲存!

# CentOS-Base.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

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

yum clean all     #清理yum快取
yum makecache     #將伺服器上的軟體包資訊快取到本地,以提高搜尋安裝軟體的速度
yum install vim*  #測試yum是否可用
 
至此,Redhat6可以使用CentOS的yum源線上安裝軟體了!