RedHat6 使用CentOS yum源

网友投稿 604 2022-05-30

简单介绍下什么是yum:

Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

redhat 系统中,yum是要授权才能使用的,但幸运地,我们可以将RedHat6使用CentOS的yum源,具体操作如下:

本文以redhat6.9为例

login as: root

root@1.3.1.21's password:

Last login: Tue Jan 15 15:49:17 2019 from 10.30.6.6     登录操作系统

[root@hrapp2 ~]# rpm -qa |grep yum                 查看已安装的yum

yum-3.2.29-81.el6.centos.noarch

yum-metadata-parser-1.1.2-16.el6.x86_64

yum-plugin-fastestmirror-1.1.30-41.el6.noarch

[root@hrapp2 ~]# rpm -qa|grep yum|xargs rpm -e --nodeps        删除已安装的redhat yum

[root@hrapp2 ~]#  rpm -qa |grep yum               查看删除成功

[root@hrapp2 ~]# wget -c http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm   下载centos yum软件及工具(共4个)

--2019-01-17 14:49:27--  http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm

正在解析主机 mirrors.163.com... 59.111.0.251

正在连接 mirrors.163.com|59.111.0.251|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 416 Requested Range Not Satisfiable

文件已下载完成;不会进行任何操作。

[root@hrapp2 ~]#  wget -c http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

--2019-01-17 14:49:50--  http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

正在解析主机 mirrors.163.com... 59.111.0.251

正在连接 mirrors.163.com|59.111.0.251|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 416 Requested Range Not Satisfiable

文件已下载完成;不会进行任何操作。

[root@hrapp2 ~]#  wget -c http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

--2019-01-17 14:50:00--  http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

正在解析主机 mirrors.163.com... 59.111.0.251

正在连接 mirrors.163.com|59.111.0.251|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 416 Requested Range Not Satisfiable

文件已下载完成;不会进行任何操作。

[root@hrapp2 ~]# wget -c http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

--2019-01-17 14:50:08--  http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

正在解析主机 mirrors.163.com... 59.111.0.251

正在连接 mirrors.163.com|59.111.0.251|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 416 Requested Range Not Satisfiable

文件已下载完成;不会进行任何操作。

[root@hrapp2 ~]# ls        查看已经下载好的文件

anaconda-ks.cfg                                    模板

install.log                                        视频

install.log.syslog                                 图片

python-iniparse-0.3.1-2.1.el6.noarch.rpm           文档

yum-3.2.29-81.el6.centos.noarch.rpm                下载

yum-metadata-parser-1.1.2-16.el6.x86_64.rpm        音乐

yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm  桌面

公共的

[root@hrapp2 ~]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm    安装下载好的四个软件

warning: python-iniparse-0.3.1-2.1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY

Preparing...                ########################################### [100%]

package python-iniparse-0.3.1-2.1.el6.noarch is already installed

[root@hrapp2 ~]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

warning: yum-metadata-parser-1.1.2-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

Preparing...                ########################################### [100%]

1:yum-metadata-parser    ########################################### [100%]

[root@hrapp2 ~]# rpm -ivh yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm

warning: yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

Preparing...                ########################################### [100%]

1:yum                    ########################################### [ 50%]

2:yum-plugin-fastestmirro########################################### [100%]

[root@hrapp2 ~]# rpm -qa |grep yum      查看centos yum软件已经安装好了

yum-3.2.29-81.el6.centos.noarch

yum-metadata-parser-1.1.2-16.el6.x86_64

yum-plugin-fastestmirror-1.1.30-41.el6.noarch

[root@hrapp2 ~]# cd /etc/yum.repos.d

[root@hrapp2 yum.repos.d]#  mkdir bak.lyj.201902    新建备份文件夹

[root@hrapp2 yum.repos.d]# mv *.repo bak.lyj.201902    将yum源备份至文件夹

[root@hrapp2 yum.repos.d]# ls

bak.lyj.201902

[root@hrapp2 yum.repos.d]#  wget http://mirrors.163.com/.help/CentOS6-Base-163.repo      下载centos6的yum源文件

--2019-01-17 15:09:13--  http://mirrors.163.com/.help/CentOS6-Base-163.repo

正在解析主机 mirrors.163.com... 59.111.0.251

正在连接 mirrors.163.com|59.111.0.251|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:2006 (2.0K) [application/octet-stream]

正在保存至: “CentOS6-Base-163.repo”

100%[=======================================================>] 2,006       --.-K/s   in 0s

2019-01-17 15:09:13 (214 MB/s) - 已保存 “CentOS6-Base-163.repo” [2006/2006])

[root@hrapp2 yum.repos.d]# ls          查看yum源文件已经下载好了

bak.lyj.201902  CentOS6-Base-163.repo

[root@hrapp2 yum.repos.d]# vim  CentOS7-Base-163.repo            编辑yum源文件

# 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 - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates

[updates]

name=CentOS-$releasever - Updates - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&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-$releasever - Extras - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib

gpgcheck=1

enabled=0

把文件里面的$releasever全部替换为版本号,即6 ,最后保存。

更改后的文件如下:

# 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 - 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-$releasever - 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-$releasever - 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

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus - 163.com

baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib - 163.com

baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

"CentOS6-Base-163.repo" 52L, 1906C

保存

[root@hrapp2 yum.repos.d]#  yum clean all   清除原有缓存

已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Cleaning repos: base extras updates

清理一切

Cleaning up list of fastest mirrors

[root@hrapp2 yum.repos.d]#  yum makecache   将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度

已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Determining fastest mirrors

base                                                     | 3.7 kB     00:00

base/group_gz                                            | 242 kB     00:00

base/filelists_db                                        | 6.4 MB     00:01

base/primary_db                                          | 4.7 MB     00:01

base/other_db                                            | 2.8 MB     00:00

extras                                                   | 3.4 kB     00:00

extras/filelists_db                                      |  24 kB     00:00

extras/prestodelta                                       | 1.1 kB     00:00

extras/primary_db                                        |  27 kB     00:00

extras/other_db                                          |  28 kB     00:00

RedHat6 使用CentOS yum源

updates                                                  | 3.4 kB     00:00

updates/filelists_db                                     | 2.0 MB     00:00

updates/prestodelta                                      | 104 kB     00:00

updates/primary_db                                       | 3.0 MB     00:00

updates/other_db                                         |  42 MB     00:14

元数据缓存已建立

如图已经可以是用centos yum源了

yum CentOS

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:计算器核心算法
下一篇:Excel表格中大于等于号输入方法有哪些
相关文章