redhat6 改 centos yum 源
**redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,需将redhat的yum卸载后,重启安装其他yum源,再配置其他源.**
本文包括配置本地源及第三方源。第三方源包括:网易,epel,repoforge ,rpmfusion 以下为详细过程:
1. 删除原yum
删除redhat原有的yum rpm -aq|grep yum|xargs rpm -e --nodeps
2. 下载centos yum文件
下载yum安装文件 注意,如果下载时找不到文件,就登录到:http://mirrors.163.com/centos/6/os/x86_64/ 上查找相应的文件。然后再下载以下4个rpm包(版本可能会不一样)。
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.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-plugin-fastestmirror-1.1.30-41.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/.help/CentOS6-Base-163.repo
3. 进行安装yum
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
rpm -ivh yum-3.2.27-14.el6.centos.noarch.rpm um-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm 注意最后两个包必需同时安装,否则会相互依赖
4. 下载第三方yum源
这里给出网易 http://mirrors.163.com/.help/CentOS6-Base-163.repo。
还可以有sohu的,自己找找。就爱那个下载后的文件放入/etc/yum.repos.d/下面。如果不用其他的repo文件,最好将其他的repo文件删除。
5. 注意事项
(1)如果你的baseurl不能访问到则会出现http://mirrors.163.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found" 说明baseurl有问题。将下载后的repo文件中所baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ 中的所有$releasever改成 6
(2)机器要能联网,ping www.baidu.com试下
(3)执行命令 yum clean all
(4)yum install gcc-c++.能安装说明安装成功。
6. 写了一个一键初始化的脚本
#!/bin/bash # Redhat6.8 改 CentOS6 yum源 #yum rpm -aq|grep yum|xargs rpm -e --nodeps #wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.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-plugin-fastestmirror-1.1.30-41.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/.help/CentOS6-Base-163.repo #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-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm # dir_path=/etc/yum.repos.d # mkdir $dir_path/bak # echo $dir_path/bak # mv $dir_path/*.repo $dir_path/bak # cp -r /root/yum/CentOS6-Base-163.repo $dir_path/ # sed -i s/'$releasever'/6/g $dir_path/CentOS6-Base-163.repo # sed -i s/'$basearch'/x86_64/g $dir_path/CentOS6-Base-163.repo # yum clear all # yum makecache # yum install -y epel-release # comple=`yum list | grep bash-completion` # echo $comple