由于红帽在线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源
wget http://mirror.centos.org/centos/6.0/os/i386/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirror.centos.org/centos/6.0/os/i386/Packages/yum-metadata-parser-1.1.2-14.1.el6.i686.rpm
wget http://mirror.centos.org/centos/6.0/os/i386/Packages/yum-3.2.27-14.el6.centos.noarch.rpm
wget http://mirror.centos.org/centos/6.0/os/i386/Packages/yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
三、安装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源在线安装软件了!