多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
**1\.** **备份现有的** **YUM** **仓库配置文件** 首先,建议备份现有的 YUM 仓库配置文件,以防万一需要恢复。 **bash**复制代码 <table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="background:#14131B;border-collapse:collapse;mso-yfti-tbllook:1184; mso-padding-alt:0cm 0cm 0cm 0cm"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#E7CE56;mso-font-kerning:0pt">mkdir<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"> /etc/yum.repos.d.backup<p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#E7CE56;mso-font-kerning:0pt">mv<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"> /etc/yum.repos.d/*.repo /etc/yum.repos.d.backup/ <hr/> **2\.** **下载新的** **YUM** **仓库配置文件** 你可以从 CentOS 官方或其他可靠的镜像源网站下载新的 YUM 仓库配置文件。但是,对于 CentOS 7,通常的做法是编辑现有的文件或创建新的文件来指定新的镜像源。 **方法一:编辑现有的文件** 如果只想修改现有的仓库(如 base, updates, extras),你可以直接编辑这些文件。但是,由于你已经备份了它们,你可以选择删除它们并创建新的。 **方法二:创建新的** **YUM** **仓库配置文件** 你可以创建一个或多个.repo文件在/etc/yum.repos.d/目录下,每个文件代表一个或多个仓库。 以下是一个示例,展示了如何为 CentOS 7 的 base, updates, extras 和 epel 仓库创建新的.repo文件: **bash**复制代码 <table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="background:#14131B;border-collapse:collapse;mso-yfti-tbllook:1184; mso-padding-alt:0cm 0cm 0cm 0cm"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#B6B18B;mso-font-kerning:0pt"># <span style="font-size:11.5pt; font-family:宋体;mso-ascii-font-family:Consolas;mso-hansi-font-family:Consolas; mso-bidi-font-family:宋体;color:#B6B18B;mso-font-kerning:0pt">创建一个新的<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#B6B18B;mso-font-kerning:0pt"> base.repo <span style="font-size:11.5pt;font-family:宋体;mso-ascii-font-family:Consolas; mso-hansi-font-family:Consolas;mso-bidi-font-family:宋体;color:#B6B18B; mso-font-kerning:0pt">文件<span style="font-size:11.5pt;font-family: Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#B6B18B; mso-font-kerning:0pt"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#E7CE56;mso-font-kerning:0pt">cat<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"> &gt; /etc/yum.repos.d/CentOS-Base.repo &lt;&lt; <span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#4FB4D7;mso-font-kerning:0pt">EOF<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">[base]<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">name=CentOS-\$releasever - Base<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">baseurl=http://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgcheck=1<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">#released updates<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">[updates]<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">name=CentOS-\$releasever - Updates<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">baseurl=http://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgcheck=1<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">#additional packages that may be useful<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">[extras]<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">name=CentOS-\$releasever - Extras<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">baseurl=http://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgcheck=1<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">#additional packages that extend functionality of existing packages<span lang="EN-US" style="font-size: 11.5pt;font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family: 宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">[centosplus]<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">name=CentOS-\$releasever - Plus<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">baseurl=http://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgcheck=1<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">enabled=0<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">EOF<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#B6B18B;mso-font-kerning:0pt"># <span style="font-size:11.5pt; font-family:宋体;mso-ascii-font-family:Consolas;mso-hansi-font-family:Consolas; mso-bidi-font-family:宋体;color:#B6B18B;mso-font-kerning:0pt">如果你还需要<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#B6B18B;mso-font-kerning:0pt"> EPEL <span style="font-size:11.5pt;font-family:宋体;mso-ascii-font-family:Consolas; mso-hansi-font-family:Consolas;mso-bidi-font-family:宋体;color:#B6B18B; mso-font-kerning:0pt">仓库<span style="font-size:11.5pt;font-family: Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#B6B18B; mso-font-kerning:0pt"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#E7CE56;mso-font-kerning:0pt">cat<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"> &gt; /etc/yum.repos.d/epel.repo &lt;&lt; <span lang="EN-US" style="font-size: 11.5pt;font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family: 宋体;color:#4FB4D7;mso-font-kerning:0pt">EOF<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">[epel]<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">name=Extra Packages for Enterprise Linux 7 - \$basearch<span lang="EN-US" style="font-size:11.5pt;font-family: Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE; mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">baseurl=http://mirrors.aliyun.com/epel/7/\$basearch<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">failovermethod=priority<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family: 宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">enabled=1<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgcheck=1<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas; mso-fareast-font-family:宋体;mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning: 0pt"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#4FB4D7;mso-font-kerning:0pt">EOF<span lang="EN-US" style="font-size:11.5pt;font-family:Consolas;mso-fareast-font-family:宋体; mso-bidi-font-family:宋体;color:#C0C5CE;mso-font-kerning:0pt"> <hr/> **3\.** **清理** **YUM** **缓存并测试** 在修改了 YUM 仓库配置文件后,你需要清理 YUM 的缓存,并尝试搜索一些包来测试新的仓库是否工作正常。 **bash**复制代码 <table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="background:#14131B;border-collapse:collapse;mso-yfti-tbllook:1184; mso-padding-alt:0cm 0cm 0cm 0cm"><p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#C0C5CE;mso-font-kerning:0pt">yum clean all<p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#C0C5CE;mso-font-kerning:0pt">yum makecache<p class="MsoNormal" align="left" style="text-align:left;line-height:18.0pt; mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:11.5pt; font-family:Consolas;mso-fareast-font-family:宋体;mso-bidi-font-family:宋体; color:#C0C5CE;mso-font-kerning:0pt">yum repolist 如果yum repolist命令成功显示了仓库列表,并且没有错误消息,那么你的 YUM 镜像源就已经成功更换了 <hr/> 4\.**安装必要的软件包以及设置 Docker 的稳定仓库**: **yum install -y yum-utils device-mapper-persistent-data lvm2 && \\** **yum-config-manager --add-repo [**http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo**](http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo) <hr/> 5.**安装Docker CE**: sudo dnf install -y docker-ce docker-ce-cli containerd.io <hr/> 6.**启动 Docker 服务并设置开机自启**: sudo systemctl start docker sudo systemctl enable docker sudo systemctl status docker #查看版本号 docker -v <hr/>