Red Hat Enterprise Linux Server release 6.4 x64 安装 yum 源

本想将mongodb安装到redhat中,yum不能使用,看网上说可以另外安装。

试了几次网上的,没有成功。看着看着也发现规律,知道怎么改了。

 

先把自带的卸载:

rpm -aq | grep yum | xargs rpm -e --nodeps

下载几个必要的包:(我这是64位的,不是的话先访问http://ftp.sjtu.edu.cn/centos/6/os/确定)

wget http://ftp.sjtu.edu.cn/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://ftp.sjtu.edu.cn/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://ftp.sjtu.edu.cn/centos/6/os/x86_64/Packages/yum-3.2.29-60.el6.centos.noarch.rpm
wget http://ftp.sjtu.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm


安装yum:

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-3.2.29-60.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm

 

 

 

编辑repo包:(如果也可以先把它删除)

vi /etc/yum.repos.d/CentOS-Base.repo

 

[base]
name=CentOS-6-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever6&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/6/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates

[update]
name=CentOS-6-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/6/updates/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#packages used/produced in the build but not released

[extras]
name=CentOS-6-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/6/extras/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-6-Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/6/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users

[contrib]
name=CentOS-6-Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/6/contrib/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


注意检查上面的每个网址路径,在网页上访问看看是否存在,如果是其他版本,把上面的6更改掉,其他版本可能还有其他配置(如 centos5还有[addons])。

 

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #这个也要对应版本

 

导入gpgkey:(当前是使用第二行导入)

#rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
rpm --import http://ftp.sjtu.edu.cn/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

 

 

 

清除缓存:

yum clean all

测试yum安装:

yum install vim

成功安装!~

 

最快方法:

# cat /etc/redhat-release 
# uname -r

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo




# redhat 使用 Centos 7
curl -o /etc/yum.repos.d/redhat.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/redhat.repo
yum clean all
yum makecache
yum update -y


#若 There are no enabled repos ,或者名字该为 /etc/yum.repos.d/RHEL_7_Disc.repo

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值