redhat 6.8 配置yum源

时间:2023-12-20 14:57:32

一般安装好redhat后,不能注册的话,不能使用系统自带的yum源。但是我们可以自己配置yum源来解决这一问题。下面介绍下redhat配置163yum源。

1. 检查是否安装yum包

rpm -qa |grep yum

2. 删除自带的yum包

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

因为一些包之间可能会有依赖关系,所以我们需要加上参数 --nodeps 无视依赖关系。

3. 下载yum包

Yum包下载地址http://mirrors.163.com/centos/

在这个网站里,你可以自己选择需要下载的文件,进入形如5/或者6/的文件下载,其他的无法下载。  (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-3.2.29-73.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-37.el6.noarch.rpm 

4. 解压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-73.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm

5. 替换yum源

cd  /etc/yum.repos.d/

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

vi CentOS6-Base-163.repo

注意原来的yum源配置文件是rhel-source.repo。这里把CentOS6-Base-163.repo替换掉rhel-source.repo。

mv rhel-source.repo rhel-source.repo.bak
mv CentOS6-Base-163.repo rhel-source.repo

6. 编辑替换后的rhel-source.repo。

#rhel-source.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

7. 清理并重建缓存

yum clean all
yum makecache

8. 更新yum

yum update

至此,redhat配置163yum源完成