有部分等centos在初始化实例完毕之后是没有配置yum源的,这个时候需要手动配置了
vim /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
这个时候保存文件
然后执行yum install的时候你会发现报错
获取 GPG 密钥失败:[Errno 14] curl#37 - "Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7"
这个时候你需要进入到/etc/pki/rpm-gpg/目录下安装密钥即可
cd /etc/pki/rpm-gpg/
wget https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
然后执行 yum install epel-release 就ok啦
'