转载自:http://blog.csdn.net/zhngjan/article/details/20843465

搜狐镜像库:mirrors.sohu.com

163镜像库:mirrors.163.com

 

查看系统信息:

[admin@server1 ~]$ uname -a

Linux server1 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

在使用redhat linux的yum来安装或者更新软件的时候会提示

  1. [admin@server1 ~]$ sudo yum install gcc
  2. Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  4. Setting up Install Process
  5. No package gcc available.
  6. Error: Nothing to do

[注]请以root身份操作

由于 redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,需将redhat的yum卸载后,重启安装,再配置其他源
解决办法:
1、首先到http://mirrors.163.com/centos下载软件包

## x86 地址:http://mirrors.163.com/centos/6/os/i386/Packages/
## x86_64 地址:http://mirrors.163.com/centos/6/os/x86_64/Packages/
## 必要下载的软件包有(以64位系统为例):
python-iniparse-0.3.-2.1.el6.noarch.rpm
yum-3.2.-.el6.centos.noarch.rpm
yum-metadata-parser-1.1.-.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.-.el6.noarch.rpm

下载命令:

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

[注] :版本不一定要最新的(http://mirrors.163.com/centos/6/os/x86_64/Packages/ 查找对应版本)

2、卸载RedHat自带的yum

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

注:1>   xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题

2>   --nodeps  强制卸载,不管依赖性
 
3、安装下载的centos的yum包:

rpm -ivh python-iniparse-0.3.-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.-.el6.x86_64.rpm
rpm -ivh yum-3.2.-.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.-.el6.noarch.rpm

[注] :最后2个需要一起安装,否则会出现依赖性错误

4、到http://mirrors.163.com的 centos帮助文档 中下载CentOS6-Base-163.repo文件,存放到/etc/yum.repo.d中

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo 

5、编辑CentOS6-Base-163.repo文件,将其中的$releasever更改为centos的版本号

下面是修改好的:

# 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- - Base - .com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates
[updates]
name=CentOS- - Updates - .com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful
[extras]
name=CentOS- - Extras - .com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages
[centosplus]
name=CentOS- - Plus - .com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=
enabled=
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users
[contrib]
name=CentOS- - Contrib - .com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=
enabled=
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

6、yum clean all 清除原有缓存

7、yum makecache  获取yum列表
出现下面提示,表示yum更改完成:
Metadata Cache Created

脚本:

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH # Check if user is root
if [ $(id -u) != "" ]; then
echo "Error: You must be root to run this script"
exit
fi clear
echo "========================================================================="
echo "Replace Redhat Enterprise Yum to CentOS Yum and Repos, Written by Licess"
echo "=========================================================================" # uninstall rhel yum
echo "Uninstall Rhel Yum......"
rpm -qa|grep yum|xargs rpm -e --nodeps
# delete old rpm
echo "Clean old cache......"
rm -rf python-iniparse-0.3.-2.1.el6.noarch.rpm
rm -rf yum-metadata-parser-1.1.-.el6.x86_64.rpm
rm -rf yum-3.2.-.el6.centos.noarch.rpm
rm -rf yum-plugin-fastestmirror-1.1.-.el6.noarch.rpm # download CentOS Yum
echo "Download Python-iniparse......"
wget http://mirrors.163.com/centos/6. ... -2.1.el6.noarch.rpm echo "Download yum-metadata-parse......"
wget http://mirrors.163.com/centos/6. ... 2-16.el6.x86_64.rpm echo "Download yum......"
wget http://mirrors.163.com/centos/6. ... 6.centos.noarch.rpm echo "Download yum fastmirror......"
wget http://mirrors.163.com/centos/6. ... 0-14.el6.noarch.rpm # install CentOS Yum
echo "Installing......"
rpm -ivh python-iniparse-0.3.-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.-.el6.x86_64.rpm
rpm -ivh yum-3.2.-.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.-.el6.noarch.rpm # replace repos
## 将修改改好的CentOS6-Base-163.repo 拷贝到/etc/yum.repo.d/中
##然后执行下面命令
yum clean all
yum makecache
yum update echo "=========================================================================="
echo "You have successfully replace RedhatEnterprise Yum to CentOS yum and repos"
echo "=========================================================================="
 

redhat ent6.5使用centos yum的更多相关文章

  1. redhat centos yum源的安装

    redhat centos yum源的安装 1.除旧 #cd /etc/yum.repos.d #mv rhel-debuginfo.repo rhel-debuginfo.repo.bak 此处将其 ...

  2. Redhat 6 配置CentOS yum source

    由于最近曝出linux的bash漏洞,想更新下bash,于是 想到了配置CentOS yum source. 测试bash漏洞的命令: env x='() { :;}; echo "Your ...

  3. redhat下yum命令安装(替换为centos yum命令)

    redhat默认自带的yum源需要注册,才能更新,报错:This system is not registered to Red Hat Subscription Management. You ca ...

  4. RedHat 更新CentOS Yum源(转)

    经测试,可用.转自:https://www.cnblogs.com/tangsen/p/5151994.html 一.随笔引言 1.1随笔内容: 1.RedHat 配置Centos yum源 2.yu ...

  5. Redhat6.5使用centos yum源

    新安装了redhat6.5.安装后,登录系统,使用yum update 更新系统.提示:This system is not registered to Red Hat Subscription Ma ...

  6. centos yum源配置 与yum配置文件

    参考博客 http://www.cnblogs.com/mchina/archive/2013/01/04/2842275.html 1.centos . yum配置文件在目录 /etc/yum.re ...

  7. redhat7.4 使用centos yum源

    新安装了redhat7.4安装后,登录系统,使用yum update 更新系统.提示: This system is not registered to Red Hat Subscription Ma ...

  8. CentOS yum源设定使用方法的整理(转)

    CentOS yum更新了很多版本更新,我本人认为CentOS yum很好使的文件系统,在此向大家推荐CentOS应该是做为服务器的linux的佼佼者.CentOS采用的二进制包是rpm,不过包的依赖 ...

  9. 卸载Redhat 7自带的yum,安装并使用网易163源

    由于redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,需将redhat的yum卸载后,安装CentOS yum工具,再配置其他源,以下为详细过程:删除redhat原有的yum ...

随机推荐

  1. Direcshow中视频捕捉和參数设置报告

    Direcshow中视频捕捉和參数设置报告 1.      关于视频捕捉(About Video Capture in Dshow) 1视频捕捉Graph的构建 一个能够捕捉音频或者视频的graph图 ...

  2. python——修饰符

    修饰符基础--闭包 什么是闭包呢?标准的概念大家可以看wikipedia上的解释 举个例子: def do_add(base): def add(increase): return base + in ...

  3. Codeforces Round #105 D. Bag of mice 概率dp

    http://codeforces.com/contest/148/problem/D 题目意思是龙和公主轮流从袋子里抽老鼠.袋子里有白老师 W 仅仅.黑老师 D 仅仅.公主先抽,第一个抽出白老鼠的胜 ...

  4. maven modules

    所有用Maven管理的真实的项目都应该是分模块的,每个模块都对应着一个pom.xml.它们之间通过继承和聚合(也称作多模块,multi-module)相互关联.那么,为什么要这么做呢?我们明明在开发一 ...

  5. JavaWeb 发送post请求的2种方式(form、json)

      JavaWeb 发送post请求的2种方式(form.json) CreationTime--2018年6月20日10点15分 Author:Marydon 前提:通过HttpClient来实现 ...

  6. 02-spring学习-配置bean

    在spring的IOC容器中配置Bean 一,在xml中通过bean节点来配置bean: class:bean的类名,通过反射的方式在IOC容器中创建Bean,所以要求bean中必须有无参的构造器 i ...

  7. LNMP环境搭建——MySQL篇

    The world's most popular open source database 1.Install MySQL root@kallen:~# apt-get install mysql-s ...

  8. Linux 压缩文件的命令行总结

    Linux压缩文件的读取 ·    *.Z       compress 程序压缩的档案: ·    *.bz2     bzip2 程序压缩的档案: ·    *.gz      gzip 程序压缩 ...

  9. FastDFS这种架构,如何配置?

    FastDFS这种架构,如何配置?才能让欧洲用户可以就近下载Storage Server1的文件,而不是到中国的Storage Server 2下载?

  10. PHP的session存储对PHP运行环境的影响

    转于:http://hmw.iteye.com/blog/1704020 这个问题的引入是由于公司一个项目里需要使用单点登录的功能,为了方便起见,就使用redis来替换php默认的文件存储sessio ...