yum安装出现错误:

[root@cdh205 network-scripts]# yum -y install ntp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-28.el7.centos will be installed
--> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-28.el7.centos.x86_64
--> Running transaction check
---> Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================
 Package               Arch         Version                      Repository  Size
==================================================================================
Installing:
 ntp                   x86_64       4.2.6p5-28.el7.centos        base       549 k
Installing for dependencies:
 autogen-libopts       x86_64       5.18-5.el7                   base        66 k

Transaction Summary
==================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 615 k
Installed size: 1.5 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
autogen-libopts-5.18-5.el7.x86 FAILED                                          
http://ftp.sjtu.edu.cn/centos/7.5.1804/os/x86_64/Packages/autogen-libopts-5.18-5.el7.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: ftp.sjtu.edu.cn; Unknown error"
Trying other mirror.
ntp-4.2.6p5-28.el7.centos.x86_ FAILED                                          
http://ftp.sjtu.edu.cn/centos/7.5.1804/os/x86_64/Packages/ntp-4.2.6p5-28.el7.centos.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: ftp.sjtu.edu.cn; Unknown error"
Trying other mirror.
autogen-libopts-5.18-5.el7.x86 FAILED                                          
http://mirrors.huaweicloud.com/repository/centos/7.5.1804/os/x86_64/Packages/autogen-libopts-5.18-5.el7.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.huaweicloud.com; Unknown error"
Trying other mirror.
autogen-libopts-5.18-5.el7.x86 FAILED                                          
http://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/Packages/autogen-libopts-5.18-5.el7.x86_64.rpm: 
.....
Error downloading packages:
  autogen-libopts-5.18-5.el7.x86_64: [Errno 256] No more mirrors to try.
  ntp-4.2.6p5-28.el7.centos.x86_64: [Errno 256] No more mirrors to try.
  • 报错信息,没有配置域名解析。为了验证,可以ping www.baidu.com网站进行检测。
  • 解决方法:CentOS 7中DNS地址解析配置是下的文件是/etc/resolv.conf,但是我们不应该对其直接配置,而是应该使用systemctl restart network命令,它会根据文件/etc/sysconfig/network-scripts/ifcfg-eth0自动生成etc/resolv.conf。