问题描述
在vm虚拟机新装的Centos7.9,因为使用的是最小化安装,内部没有netstat或vim命令,需要安装。
在使用yum -y install wget命令安装wget工具的时候,报错“Could not resolve host: mirrorlist.centos.org; 未知的错误”,如下图所示
在这里插入图片描述
原因分析:
该问题的原因为在国内无法连接到国外的仓库,所以报错,有时就算连上了,下载速度也很慢
解决方案:
针对报错及下载慢的问题,需要使用国内的镜像仓库来进行安装,常见的有阿里云或清华大学的镜像仓库,以下以阿里云为例进行展示。
从阿里云下载新的配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1
2
如果提示wget没有安装的话,使用curl,效果一样,都是下载远程文件到指定目录
清理缓存和重新生产缓存
yum clean all
yum makecache
1
2
成功后如下图所示,全程几十秒
在这里插入图片描述
安装需要的工具
#这里把常用的工具都写进来了
yum install -y tree vim wget bash-completion bash- completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc httpd-tools bind-utils nethogs expect