centos7中 yum的安装

自己误将yum卸载,
在重装时由于依赖问题一直报错:
error: Failed dependencies:
    /usr/bin/python is needed by yum-3.4.3-163.el7.centos.noarch
    python >= 2.4 is needed by yum-3.4.3-163.el7.centos.noarch
    python(abi) = 2.7 is needed by yum-3.4.3-163.el7.centos.noarch
    python-iniparse is needed by yum-3.4.3-163.el7.centos.noarch
    python-sqlite is needed by yum-3.4.3-163.el7.centos.noarch
    python-urlgrabber >= 3.10-8 is needed by yum-3.4.3-163.el7.centos.noarch
    rpm-python is needed by yum-3.4.3-163.el7.centos.noarch
    libpython2.7.so.1.0()(64bit) is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
    python(abi) = 2.7 is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
 
 
1、查看yum安装包
# rpm -qa | grep yum
yum-plugin-fastestmirror-1.1.31-52.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-utils-1.1.31-52.el7.noarch   
 
2、将其全部卸载
#rpm -e yum-plugin-fastestmirror-1.1.31-52.el7.noarch --nodeps
#rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
#rpm -e yum-utils-1.1.31-52.el7.noarch --nodeps
 
 
libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm                    
python-ipaddress-1.0.16-2.el7.noarch.rpm  
lvm2-python-libs-2.02.185-2.el7.x86_64.rpm
python-kitchen-1.1.1-5.el7.noarch.rpm     
yum-3.4.3-163.el7.centos.noarch.rpm
python-2.7.5-86.el7.x86_64.rpm                                
python-libs-2.7.5-86.el7.x86_64.rpm       
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm  
python-pycurl-7.19.0-19.el7.x86_64.rpm    
yum-plugin-aliases-1.1.31-52.el7.noarch.rpm
python-chardet-2.2.1-3.el7.noarch.rpm                         
python-setuptools-0.9.8-7.el7.noarch.rpm  
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
python-devel-2.7.5-86.el7.x86_64.rpm                          
python-urlgrabber-3.10-9.el7.noarch.rpm   
yum-plugin-protectbase-1.1.31-52.el7.noarch.rpm
python-iniparse-0.4-9.el7.noarch.rpm                          
rpm-python-4.11.3-40.el7.x86_64.rpm       
yum-utils-1.1.31-52.el7.noarch.rpm
 
 
4、下载完成后执行
#rpm -Uvh --replacepkgs lvm2-python-libs*.rpm --nodeps --force
#rpm -Uvh --replacepkgs libxml2-python*.rpm --nodeps --force
#rpm -Uvh --replacepkgs python*.rpm --nodeps --force
#rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm --nodeps --force
 
 
5、包安装完成了,我们还需要配置yum的源地址

[root@hear oracle]# cd /etc/yum.repos.d/
[root@hear yum.repos.d]# ls
redhat.repo
[root@hear yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
--2019-12-12 16:13:50-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 27.185.6.243, 27.185.6.239, 27.185.5.240, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|27.185.6.243|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘Centos-7.repo’

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

2019-12-12 16:13:50 (223 MB/s) - ‘Centos-7.repo’ saved [2523/2523]

6.修改$releasever的值

[root@hear yum.repos.d]# ls
Centos-7.repo redhat.repo
[root@hear yum.repos.d]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/Centos-7.repo
[root@hear yum.repos.d]# pwd
/etc/yum.repos.d
[root@hear yum.repos.d]# cat /etc/yum.conf

替换distroverpkg=centos-release   

替换成

distroverpkg=redhat-release 

 

6、最后执行yum makecache生成缓存

[root@hear yum.repos.d]# yum makecache
Loaded plugins: aliases, fastestmirror, langpacks, product-id, protectbase, 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: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
base/x86_64/primary_db FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/04efe80d41ea3d94d36294f7107709d1c8f70db11e152d6ef562da344748581a-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
(1/10): base/x86_64/group_gz | 165 kB 00:00:00
(2/10): extras/x86_64/other_db | 100 kB 00:00:00
(3/10): extras/x86_64/filelists_db | 207 kB 00:00:00
(4/10): base/x86_64/other_db | 2.6 MB 00:00:01
(5/10): updates/x86_64/other_db | 356 kB 00:00:00
(6/10): updates/x86_64/filelists_db | 3.3 MB 00:00:01
(7/10): base/x86_64/primary_db | 6.0 MB 00:00:01
base/x86_64/filelists_db FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/41232548001a78473ae0f2d4b92e1ec28f7a0593e0495056515887fe2a39b416-filelists.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/41232548001a78473ae0f2d4b92e1ec28f7a0593e0495056515887fe2a39b416-filelists.sqlite.bz2: (28, 'Connection timed out after 30002 milliseconds')
Trying other mirror.
extras/x86_64/primary_db FAILED
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/e87982a7d437db5420d7a3821de1bd4a7b145d57a64a3a464cdeed198c4c1ad5-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/e87982a7d437db5420d7a3821de1bd4a7b145d57a64a3a464cdeed198c4c1ad5-primary.sqlite.bz2: (28, 'Connection timed out after 30002 milliseconds')
Trying other mirror.
updates/x86_64/primary_db FAILED ] 83 kB/s | 14 MB 00:02:24 ETA
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/ce9b17323a0afa62b0a6a193c0596365a64f4fee9e0e441736e05a8b11044251-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/ce9b17323a0afa62b0a6a193c0596365a64f4fee9e0e441736e05a8b11044251-primary.sqlite.bz2: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
(8/10): extras/x86_64/primary_db | 153 kB 00:00:00
(9/10): base/x86_64/filelists_db | 7.3 MB 00:00:01
(10/10): updates/x86_64/primary_db

 全部注释后,再次执行 yum clean all;  yum makecache
.查看当前可用的仓库 yum repolist all

[root@hear yum.repos.d]# yum repolist all
Loaded plugins: aliases, fastestmirror, langpacks, product-id, protectbase, 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
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
0 packages excluded due to repository protections
repo id repo name status
base/x86_64 CentOS-7 - Base - mirrors.aliyun.com enabled: 10,097
centosplus/x86_64 CentOS-7 - Plus - mirrors.aliyun.com disabled
contrib/x86_64 CentOS-7 - Contrib - mirrors.aliyun.com disabled
extras/x86_64 CentOS-7 - Extras - mirrors.aliyun.com enabled: 305
updates/x86_64 CentOS-7 - Updates - mirrors.aliyun.com enabled: 972
repolist: 11,374

 
 
 
 
posted @ 2019-12-12 16:29  Hear7  阅读(1959)  评论(0编辑  收藏  举报