Redhat下yum安装
首先要确定自己的操作系统版本,使用 lsb_release -a 命令查看,例如:
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release6.0 (Santiago)
Release: 6.0
Codename: Santiago
由于 RedHat 是商业版本,没有注册的操作系统是无法是 yum 在线安装功能的。解决的办法是卸载 RedHat 的 yum, 替换成 CentOs 的 yum。
1.删除redhat原有的yum
rpm -aq|grep yum|xargs rpm -e --nodeps
2.下载yum安装文件
注意,如果下载时找不到文件,就登录到:http://mirrors.sohu.com/centos/6/os/x86_64/上查找相应的文件。然后再下载。
3.进行安装yum
rpm -ivhpython-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivhyum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
rpm -ivh yum-3.2.27-14.el6.centos.noarch.rpmum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
注意最后两个包必需同时安装,否则会相互依赖
4.更新repo文件/etc/yum.repos.d/xxxx.repo
http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
下面是搜狐的:
# CentOS-Base.repo
#
# This file uses a new mirrorlist systemdeveloped by Lance Davis for CentOS.
# The mirror system uses the connecting IPaddress of the client and the
# update status of each mirror to pickmirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking othermirrors.
#
# If the mirrorlist= does not work for you,as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.sohu.com/centos/6.0/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.sohu.com/centos/6.0/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-6
#packages used/produced in the build butnot released
#[addons]
#name=CentOS-$releasever - Addons
#baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/
#gpgcheck=1
#gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.sohu.com/centos/6.0/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionalityof existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.sohu.com/centos/6.0/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-6
注意要将baseurl中的 6.0改成 6,例如
baseurl=http://mirrors.ustc.edu.cn/centos/6.0/os/$basearch/
改成
baseurl=http://mirrors.ustc.edu.cn/centos/6/os/$basearch/
5、yum clean all
6、yum install vim #测试一下可不可以用
http://myceo.blog.51cto.com/2340655/755896常见错误解答