一.报错信息
找了很多种方法:
有说:改 vi /etc/sysconfig/network-scripts/ifcfg-ens33 网络配置文件的 重启网络的
还有说:在 /etc/yum.repos.d/CentOS-Base.repo 文件中,找到并修改 baseurl 和 mirrorlist 为其他可用的镜像源地址。
各种方法:都不得行,究其原因 就是镜像源 的问题
该文章讲述centos7 无法使用yum 和 wget 报以下类似错误的问题
[root@contos7 ~]# sudo yum -y update
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
联不通网的可以参考以下:
https://blog.csdn.net/wxnshuai/article/details/108492257?spm=1001.2014.3001.5506
联网后 ping 下面 地址能ping通的
ping www.baidu.com
二.下载安装包(建议使用阿里云)
网易镜像库 http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages
阿里云镜像库 https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages
阿里链接进来的会到这个界面:
在这个界面 Ctrl+F 直接搜
不理解,也先别急,跟就行了
找到的这个wget-1.14-18.el7_6.1.x86_64.rpm 下载下来
三.安装wget(离线和联网操作一样的步骤)
cd /home 进去 mkdir wget 创建一个wget 的(目录)文件夹
我这里用的finalshell
直接上传到你刚才建的目录里边
cd wget 命令进入目录 然后执行命令rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm
cd wget/
rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm
四.安装yum
这里为了防止后续出问题,我们全部删除干净(命令一个一个来)
4.1:卸载python
##强制删除已安装程序及其关联
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python |xargs rm -frv -rf
##验证删除,返回无结果
whereis python
4.2:删除yum
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum |xargs rm -frv -rf
[root@contos7 wget]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
软件包准备中...
python-firewall-0.5.3-5.el7.noarch
python-slip-dbus-0.4.0-4.el7.noarch
python-slip-0.4.0-4.el7.noarch
python-urlgrabber-3.10-9.el7.noarch
python-decorator-3.4.0-3.el7.noarch
python-pyudev-0.15-9.el7.noarch
python-iniparse-0.4-9.el7.noarch
python-configobj-4.7.2-7.el7.noarch
python-linux-procfs-0.4.9-4.el7.noarch
python-schedutils-0.4-6.el7.x86_64
python-pycurl-7.19.0-19.el7.x86_64
rpm-python-4.11.3-35.el7.x86_64
python-perf-3.10.0-957.el7.x86_64
newt-python-0.52.15-4.el7.x86_64
libselinux-python-2.5-14.1.el7.x86_64
dbus-python-1.1.1-9.el7.x86_64
python-gobject-base-3.22.0-1.el7_4.1.x86_64
python-2.7.5-76.el7.x86_64
python-libs-2.7.5-76.el7.x86_64
[root@contos7 wget]# whereis python |xargs rm -frv -rf
已删除"/usr/lib/python2.7/site-packages/rpmUtils/__init__.py"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/__init__.pyc"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/arch.py"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/arch.pyc"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/miscutils.py"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/miscutils.pyc"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.py"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyc"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/transaction.py"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/transaction.pyc"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/updates.py"
已删除"/usr/lib/python2.7/site-packages/rpmUtils/updates.pyc"
已删除目录:"/usr/lib/python2.7/site-packages/rpmUtils"
已删除"/usr/lib/python2.7/site-packages/yum/Errors.py"
已删除"/usr/lib/python2.7/site-packages/yum/Errors.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/__init__.py"
已删除"/usr/lib/python2.7/site-packages/yum/transactioninfo.py"
已删除"/usr/lib/python2.7/site-packages/yum/__init__.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/sqlutils.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/callbacks.py"
已删除"/usr/lib/python2.7/site-packages/yum/transactioninfo.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/callbacks.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/comps.py"
已删除"/usr/lib/python2.7/site-packages/yum/comps.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/config.py"
已删除"/usr/lib/python2.7/site-packages/yum/config.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/update_md.py"
已删除"/usr/lib/python2.7/site-packages/yum/constants.py"
已删除"/usr/lib/python2.7/site-packages/yum/constants.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/depsolve.py"
已删除"/usr/lib/python2.7/site-packages/yum/depsolve.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/drpm.py"
已删除"/usr/lib/python2.7/site-packages/yum/drpm.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/failover.py"
已删除"/usr/lib/python2.7/site-packages/yum/failover.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/fssnapshots.py"
已删除"/usr/lib/python2.7/site-packages/yum/fssnapshots.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/history.py"
已删除"/usr/lib/python2.7/site-packages/yum/history.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/i18n.py"
已删除"/usr/lib/python2.7/site-packages/yum/i18n.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/igroups.py"
已删除"/usr/lib/python2.7/site-packages/yum/igroups.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/logginglevels.py"
已删除"/usr/lib/python2.7/site-packages/yum/logginglevels.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/mdparser.py"
已删除"/usr/lib/python2.7/site-packages/yum/mdparser.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/metalink.py"
已删除"/usr/lib/python2.7/site-packages/yum/metalink.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/misc.py"
已删除"/usr/lib/python2.7/site-packages/yum/misc.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/packageSack.py"
已删除"/usr/lib/python2.7/site-packages/yum/packageSack.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/packages.py"
已删除"/usr/lib/python2.7/site-packages/yum/packages.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/parser.py"
已删除"/usr/lib/python2.7/site-packages/yum/parser.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/pgpmsg.py"
已删除"/usr/lib/python2.7/site-packages/yum/pgpmsg.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/pkgtag_db.py"
已删除"/usr/lib/python2.7/site-packages/yum/pkgtag_db.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/plugins.py"
已删除"/usr/lib/python2.7/site-packages/yum/plugins.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/repoMDObject.py"
已删除"/usr/lib/python2.7/site-packages/yum/repoMDObject.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/repos.py"
已删除"/usr/lib/python2.7/site-packages/yum/repos.pyc"
已删除"/usr/lib/python2.7/site-packages/yum/rpmsack.py"
已删除"/usr/lib/python2.7/site-packages/yum/rpmsack.pyc"
已删除"/usr/lib/py