Uninstallation and installation of centos7 yum

In the evening of 2020-12-10, in order to achieve a smooth upgrade from php7.1 to php7.3, according to  https://blog.csdn.net/baidu_35297131/article/details/89960654  this article modified yum related configuration files, and the result is php The upgrade is unsuccessful, and yum cannot be used either, only uninstall and reinstall

Uninstall:

# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
# whereis yum |xargs rm -frv

Reinstall:

During reinstallation, an error has been reported due to dependency issues:

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. View the yum installation package

# 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. Uninstall them all

#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

 

3. Download the following 20 packages at http://mirrors.163.com/centos/7/os/x86_64/Packages/ (the following resources can be downloaded in "csdn-my resources" )

 

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. Execute after downloading

#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. Successful installation

 

6. If you change python to python3, you will get an error when running yum

[root@iz2ze3ogy01eqvjs99e8nez python]# yum

  File "/usr/bin/yum", line 30

    except KeyboardInterrupt, e:

                            ^

SyntaxError: invalid syntax



修改 vi /etc/usr/yum 第一行为

#!/usr/bin/python2

Set yum mirror source

1. Enter the yum mirror source configuration folder

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

2. Back up the original image file of the system

[root@localhost yum.repos.d]# mv CentOs-Base.repo CentOs-Base.repo.bak

3. Download the mirror source

163 yum mirror source: http://mirrors.163.com/.help/CentOS7-Base-163.repo

Alibaba cloud yum mirror source: http://mirrors.aliyun.com/repo/Centos-7.repo

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

or

[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# mv Centos-7.repo CentOs-Base.repo  #重命名镜像文件

4. Clear the cache

[root@localhost yum.repos.d]# yum clean all

5. Generate cache

[root@localhost yum.repos.d]# yum makecache

6. Upgrade and update

[root@localhost yum.repos.d]# yum -y update   #升级所有包同时也升级软件和系统内核

or

[root@localhost yum.repos.d]# yum -y upgrade  #只升级所有包,不升级软件和系统内核

 

 

Guess you like

Origin blog.csdn.net/JineD/article/details/111032646