redhat7.0安装yum

由于redhat自带的yum须注册方可使用,于是我们安装centos7.0的yum用以代替

一、查看系统版本:cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)

二、删除系统自带yum
rpm -qa | grep yum | xargs rpm -e –nodeps

三、下载相关安装包RPM(http://mirrors.163.com/centos/7/os/x86_64/Packages/)
1、python-iniparse-0.4-9.el7.noarch.rpm
2、 python-urlgrabber-3.10-8.el7.noarch.rpm
3、yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
4、yum-updateonboot-1.1.31-40.el7.noarch.rpm
5、yum-3.4.3-150.el7.centos.noarch.rpm
6、yum-utils-1.1.31-40.el7.noarch.rpm
7、yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
由于更新,根据相应版本自己选择

之后安装,注意要如此:rpm -ivh yum-* python-*
随着版本升级,可能安装yum可能还会依赖其他的python-*,

注意:上面几步是坑

我开始以为在官网中下载最新版安装包然后根据需要下载相应的依赖文件即可,谁知下了yum-3.4.3-150.el7.centos.noarch.rpm 这个最新版之后,依赖好多文件,然后我就一个个下,结果最后安装时还是生成不了yum,简直无语。。

后来我下了yum-3.4.3-132.el7.centos.0.1.noarch.rpm,依赖
1、python-iniparse-0.4-9.el7.noarch.rpm
2、yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
3、yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm

之后rpm -ivh yum-* 即可生成yum

[root@localhost yum.repos.d]# rpm -aq|grep yum
yum-plugin-fastestmirror-1.1.31-40.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-132.el7.centos.0.1.noarch

四、将centOS中的repo导入redhat中的/etc/yum.repos.d中(注意:只有yum安装好后,etc下才会有yum.repos.d文件夹)
http://mirrors.163.com/.help/centos.html

打开上面网址,下载CentOS-Base-163.repo,将其放到/etc/yum.repos.d目录下,并
vim /etc/yum.repos.d/CentOS-Base-163.repo,进行修改如下所示:

[base]
name=CentOS-7 - Base

baseurl=http://mirror.centos.org/centos/7/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-7- Updates

baseurl=http://mirror.centos.org/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-7 - Extras

baseurl=http://mirror.centos.org/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-7 - Plus

baseurl=http://mirror.centos.org/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

五、 yum clean all 清除原有缓存

[root@dockerServer yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: base epel extras updates
Cleaning up everything

六、yum makecache 获取yum列表

[root@dockerServer yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 5.7 kB 00:00:00
epel | 4.4 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/16): base/x86_64/other_db | 2.1 MB 00:00:04
(2/16): base/x86_64/primary_db | 4.9 MB 00:00:04
epel/x86_64/primary_db FAILED ] 2.1 MB/s | 12 MB 00:00:15 ETA
http://ftp6.sjtu.edu.cn/fedora/epel/7/x86_64/repodata/abd574868d90db0a564394f31fe3b35368870700fca013beff3d8fe9a0b84b64-primary.sqlite.bz2: [Errno 14] curl#7 - “Failed to connect to 2001:da8:8000:6023::230: Network is unreachable”
Trying other mirror.
(3/16): base/x86_64/filelists_db | 5.8 MB 00:00:05
(4/16): extras/x86_64/filelists_db | 92 kB 00:00:00
(5/16): epel/x86_64/group_gz | 250 kB 00:00:05
(6/16): extras/x86_64/prestodelta | 1.7 kB 00:00:00
(7/16): extras/x86_64/other_db | 67 kB 00:00:00
(8/16): extras/x86_64/primary_db | 35 kB 00:00:00
(9/16): updates/x86_64/prestodelta | 184 kB 00:00:00
(10/16): base/x86_64/group_gz | 157 kB 00:00:06
(11/16): epel/x86_64/filelists_db | 4.9 MB 00:00:01
(12/16): epel/x86_64/other_db | 1.7 MB 00:00:01
(13/16): epel/x86_64/primary_db | 3.5 MB 00:00:01
(14/16): updates/x86_64/filelists_db | 2.7 MB 00:00:02
(15/16): updates/x86_64/primary_db | 4.7 MB 00:00:03
(16/16): updates/x86_64/other_db | 14 MB 00:01:56
(1/2): epel/x86_64/updateinfo | 129 kB 00:00:00
(2/2): epel/x86_64/pkgtags | 1.3 MB 00:00:00
Determining fastest mirrors
* base: mirrors.yun-idc.com
* epel: mirrors.yun-idc.com
* extras: mirrors.yun-idc.com
* updates: mirrors.yun-idc.com
Metadata Cache Created

到此yum就可以在线安装软件了。

你可能感兴趣的:(redhat)