Redhat7-配置网络yum源
1、安装之前要先卸载系统本来的yum源,执行以下命令
[root@master tools]# rpm -qa |grep yum
yum-3.4.3-168.el7.noarch
yum-rhn-plugin-2.0.1-10.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
[root@master tools]# rpm -aq|grep yum|xargs rpm -e --nodeps
注:a、xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题
b、--nodeps 强制卸载,不管依赖性
2、查询一下是否完全卸载了
[root@master ~]# rpm -qa |grep yum
3、下载centos的yum安装包,路径同2,可以直接使用下列链接
卸载原先的python-urlgrabber-3.10-4.el7.noarch.rpm
---不执行--------------
[root@backup tools]# rpm -qa |grep python-urlgrabber
python-urlgrabber-3.10-10.el7.noarch
[root@backup tools]# rpm -aq|grep python-urlgrabber|xargs rpm -e --nodeps
[root@backup tools]# rpm -qa |grep python-urlgrabber
-------------------------
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-45.el7.x86_64.rpm
4、先把rpm更新为:
[root@master tools]# rpm -ivh rpm-4.11.3-45.el7.x86_64.rpm --force <br data-filtered="filtered">忽略冲突强制安装。
5、在当前目录下,安装上面下载的rpm包
[root@master tools]# rpm -ivh yum-*
warning: yum-3.4.3-168.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 33%]
2:yum-plugin-fastestmirror-1.1.31-5################################# [ 67%]
3:yum-3.4.3-168.el7.centos ################################# [100%]
[root@master tools]#
6、下载centos源:
[root@master tools]# cd /etc/yum.repos.d/
[root@master yum.repos.d]# ll
total 4
-rw-r--r--. 1 root root 358 Mar 19 03:39 redhat.repo
[root@master yum.repos.d]# mkdir backup
[root@master yum.repos.d]# mv redhat.repo backup/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
vi CentOS7-Base-163.repo
把文件的 $releasever 改为7,如
[root@master yum.repos.d]# more CentOS7-Base-163.repo
[base]
name=CentOS-7 - Base - 163.com
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-7 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-7 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[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
[root@master yum.repos.d]#
7、清除原来的源配置
[root@master yum.repos.d]# yum repolist
[root@master yum.repos.d]# yum clean all
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.
Cleaning repos: base extras updates
Cleaning up list of fastest mirrors
[root@master yum.repos.d]#
8、安装现在的yum源,这一步也是测试新安装的yum源有没有安装成功
[root@master yum.repos.d]# yum install yum
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.
Determining fastest mirrors
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/x86_64/primary_db | 249 kB 00:00:00
(3/4): base/x86_64/primary_db | 6.1 MB 00:00:00
(4/4): updates/x86_64/primary_db | 20 MB 00:00:01
Package yum-3.4.3-168.el7.centos.noarch already installed and latest version
Nothing to do
[root@master yum.repos.d]#
如果这条命令能执行成功,就说明新安装的yum源已经正确配置好了。
9、更新yum源到本地
[root@master yum.repos.d]# yum list
[root@master tools]# rpm -qa |grep yum
yum-3.4.3-168.el7.noarch
yum-rhn-plugin-2.0.1-10.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
[root@master tools]# rpm -aq|grep yum|xargs rpm -e --nodeps
注:a、xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题
b、--nodeps 强制卸载,不管依赖性
2、查询一下是否完全卸载了
[root@master ~]# rpm -qa |grep yum
3、下载centos的yum安装包,路径同2,可以直接使用下列链接
卸载原先的python-urlgrabber-3.10-4.el7.noarch.rpm
---不执行--------------
[root@backup tools]# rpm -qa |grep python-urlgrabber
python-urlgrabber-3.10-10.el7.noarch
[root@backup tools]# rpm -aq|grep python-urlgrabber|xargs rpm -e --nodeps
[root@backup tools]# rpm -qa |grep python-urlgrabber
-------------------------
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-45.el7.x86_64.rpm
4、先把rpm更新为:
[root@master tools]# rpm -ivh rpm-4.11.3-45.el7.x86_64.rpm --force <br data-filtered="filtered">忽略冲突强制安装。
5、在当前目录下,安装上面下载的rpm包
[root@master tools]# rpm -ivh yum-*
warning: yum-3.4.3-168.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 33%]
2:yum-plugin-fastestmirror-1.1.31-5################################# [ 67%]
3:yum-3.4.3-168.el7.centos ################################# [100%]
[root@master tools]#
6、下载centos源:
[root@master tools]# cd /etc/yum.repos.d/
[root@master yum.repos.d]# ll
total 4
-rw-r--r--. 1 root root 358 Mar 19 03:39 redhat.repo
[root@master yum.repos.d]# mkdir backup
[root@master yum.repos.d]# mv redhat.repo backup/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
vi CentOS7-Base-163.repo
把文件的 $releasever 改为7,如
[root@master yum.repos.d]# more CentOS7-Base-163.repo
[base]
name=CentOS-7 - Base - 163.com
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-7 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-7 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[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
[root@master yum.repos.d]#
7、清除原来的源配置
[root@master yum.repos.d]# yum repolist
[root@master yum.repos.d]# yum clean all
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.
Cleaning repos: base extras updates
Cleaning up list of fastest mirrors
[root@master yum.repos.d]#
8、安装现在的yum源,这一步也是测试新安装的yum源有没有安装成功
[root@master yum.repos.d]# yum install yum
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.
Determining fastest mirrors
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/x86_64/primary_db | 249 kB 00:00:00
(3/4): base/x86_64/primary_db | 6.1 MB 00:00:00
(4/4): updates/x86_64/primary_db | 20 MB 00:00:01
Package yum-3.4.3-168.el7.centos.noarch already installed and latest version
Nothing to do
[root@master yum.repos.d]#
如果这条命令能执行成功,就说明新安装的yum源已经正确配置好了。
9、更新yum源到本地
[root@master yum.repos.d]# yum list