Redhat使用CentOS的Yum 网络源

Redhat 的更新包只对注册的用户生效,因此咱们本身手动更改为CentOS 的更新包,CentOS几乎和redhat是同样的.node

一、首先查看redhat 7.0系统自己所安装的那些yum 软件包:
[root@localhost ~]# rpm -qa | grep yumcentos

yum-utils-1.1.31-24.el7.noarch
yum-langpacks-0.4.2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-rhn-plugin-2.0.1-4.el7.noarch
yum-3.4.3-118.el7.noarch缓存


二、删除这些软件包;less

[root@localhost ~]# rpm -e yum-3.4.3-118.el7.noarch --nodeps
[root@localhost ~]# rpm -e yum-utils-1.1.31-24.el7.noarch --nodeps
[root@localhost ~]# rpm -e yum-rhn-plugin-2.0.1-4.el7.noarch --nodeps
[root@localhost ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@localhost ~]# rpm -e yum-langpacks-0.4.2-3.el7.noarch --nodeps
[root@localhost ~]# rpm -e PackageKit-yum-0.8.9-11.el7.x86_64 --nodeps网站


三、本机电脑得能上网(废话,不上网怎么用)this

四、本身选择一个合适的镜像网站,找到本身系统所对应的文件包版本更新:url

https://www.centos.org/download/mirrors/spa

我用的aws 美国 NJ州因此选择了http://centos.mirror.constant.com/ssl

五、找到本身所须要的版本下载:rem

wget http://centos.mirror.constant.com/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
wget http://centos.mirror.constant.com/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://centos.mirror.constant.com/7/os/x86_64/Packages/yum-utils-1.1.31-34.el7.noarch.rpm
wget http://centos.mirror.constant.com/7/os/x86_64/Packages/yum-updateonboot-1.1.31-34.el7.noarch.rpm
wget http://centos.mirror.constant.com/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm

六、安装软件包,注意依赖关系:

rpm -ivh yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-utils-1.1.31-34.el7.noarch.rpm
rpm -ivh yum-updateonboot-1.1.31-34.el7.noarch.rpm

七、新建repo 配置文件;
vi /etc/yum.repos.d/CentOS-Base.repo

内容以下:
根据本身的镜像替换掉网址http://centos.mirror.constant.com/为本身的镜像网址


# 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-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://centos.mirror.constant.com/7/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://centos.mirror.constant.com/7/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=http://centos.mirror.constant.com/7/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://centos.mirror.constant.com/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


八、导入RPM-GPG-KEY-CentOS-7

cd /etc/pki/rpm-gpg/
wget http://centos.mirror.constant.com/RPM-GPG-KEY-CentOS-7


九、清理原先缓存,建立新缓存

yum clean all

yum makecache


十、安装试试

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel gd gd-devel

 

后记,注意:

1,莫忘记导入key2,删除或禁用原先的repo文件3,--nodeps4,镜像网址切换5,Centos和Redhat版本

相关文章
相关标签/搜索