一、簡介
安裝Redhat7並配置了網卡之后,雖然可以直接ping www.baidu.com,但是執行yum install的命令時提示如下信息:
[root@ansible ~]# yum install -y vim Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. There are no enabled repos. Run "yum repolist all" to see the repos you have. To enable Red Hat Subscription Management repositories: subscription-manager repos --enable <repo> To enable custom repositories: yum-config-manager --enable <repo>
原因在於redhat 的更新包只對注冊的用戶生效,所以需要自己手動更改成CentOS 的更新包,CentOS幾乎和redhat是一樣的,所以無需擔心軟件包是否可安裝,安裝之后是否有問題,另外CentOS公司去年已經被Redhat 收購了,下面是安裝步驟
二、配置Redhat7的YUM源
配置Redhat7的YUM源一般有2種方法:1-本地CD源 2-CentOS7源。第一種方式是掛載Redhat7的DVD鏡像作為源,所有的安裝都是在鏡像文件中安裝,這種方式比較簡單,但是不方便。第二種是使用CentOS7的YUM源。下面講的就是第二種方式:
1、首先查看redhat 7.0系統本身所安裝的那些yum 軟件包:
[root@linuxprobe ~]# rpm -qa | grep yum
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
PackageKit-yum-0.8.9-11.el7.x86_64
yum-3.4.3-118.el7.noarch
2、 刪除redhat自帶的yum包
卸載上面顯示的所有yum包:
[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
[root@localhost ~]# rpm -qa |grep yum
[root@localhost ~]#
3、保證本機電腦能上網
[root@linuxprobe ~]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121: icmp_seq=1 ttl=53 time=31.8 ms
64 bytes from 61.135.169.121: icmp_seq=2 ttl=53 time=31.9 ms
64 bytes from 61.135.169.121: icmp_seq=3 ttl=53 time=32.0 ms
4、選擇網絡源
網易163網絡源地址:http://mirrors.163.com/
CentOS網絡源地址:http://centos.ustc.edu.cn/centos/
5、選擇163源(最重要一步)
下載安裝包rpm的地址:http://mirrors.163.com/centos/7/os/x86_64/Packages/
注意下面的鏈接可能會失效,打開上面WEB按照實際的版本下載這5個包即可。
[root@ansible ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
[root@ansible ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@ansible ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
[root@ansible ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-45.el7.noarch.rpm
[root@ansible ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
6、查看下載完成結果
[root@ansible ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg Templates yum-metadata-parser-1.1.4-10.el7.x86_64.rpm.1
Desktop Music Videos yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
Documents Pictures yum-3.4.3-158.el7.centos.noarch.rpm yum-updateonboot-1.1.31-45.el7.noarch.rpm
Downloads Public yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-utils-1.1.31-45.el7.noarch.rpm
7、安裝軟件包:
[root@ansible ~]# rpm -ivh yum-*
warning: yum-3.4.3-158.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
warning: package yum-metadata-parser-1.1.4-10.el7.x86_64 was already added, skipping yum-metadata-parser-1.1.4-10.el7.x86_64
Preparing... ################################# [100%]
Updating / installing...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 20%]
2:yum-plugin-fastestmirror-1.1.31-4################################# [ 40%]
3:yum-3.4.3-158.el7.centos ################################# [ 60%]
4:yum-updateonboot-1.1.31-45.el7 ################################# [ 80%]
5:yum-utils-1.1.31-45.el7 ################################# [100%]
8、新建repo 配置文件,直接復制即可
[root@linuxprobe ~]# vim /etc/yum.repos.d/CentOS-Base.repo
#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-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
9、至此YUM 網絡源已經安裝完成
[root@linuxprobe ~]# yum clean all
10、測試安裝是否正常
[root@ansible ~]# yum -y install vim
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check