临时小驻

求仁得仁,复无怨怼。

CentOS 7 使用 TUNA 镜像源

2018-08-17 19:51:00 +0800

本文描述如何将 CentOS 源、epel 源、ius 源切换到 TUNA 镜像站的地址。这里 TUNA 源使用的是 mirrors.tuna.tsinghua.edu.cn ,如果需要指定使用 IPv6 线路,可修改为 mirrors6.tuna.tsinghua.edu.cn 。

CentOS 源

CentOS 使用 yum 包管理器,yum 的软件源配置文件存放于 /etc/yum.repos.d/ 目录下。

首先,备份并删除所有的 CentOS-*.repo条目。

创建 centos.repo 文件:

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

注意,这里使用了 RPM-GPG-KEY-CENTOS-7 来验证软件源。该文件默认是已经存在的,如果没有,可以从 TUNA 镜像站的 CentOS 根目录手动获取。

保存,执行命令 yum update,这样就完成了 CentOS 源的切换。

epel 源

epel 源提供了很多有用的软件。

首先,用常规途径安装 epel 源,这会安装 epel-release 软件源,同时安装 RPM-GPG-KEY-EPEL-7

yum install epel-release

接下来,备份并移除所有的 epel*.repo 条目,创建 epel.repo 文件:

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/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

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

保存,执行命令 yum update

ius 源

ius 源提供了很多软件的更新版本。

首先需要从 https://ius.io/GettingStarted/ 下载 rpm 包,当前链接为 https://centos7.iuscommunity.org/ius-release.rpm 。这一步没办法使用 IPv6 免流量。

然后执行命令 yum install ius-release.rpm 安装 ius-release 软件源,同时安装 IUS-COMMUNITY-GPG-KEY

接下来,备份并移除 ius*.repo,创建 ius.repo 文件:

[ius]
name=IUS Community Packages for Enterprise Linux 7 - $basearch
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/ius/stable/CentOS/7/$basearch
#mirrorlist=https://mirrors.iuscommunity.org/mirrorlist?repo=ius-centos7&arch=$basearch&protocol=http
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY

[ius-debuginfo]
name=IUS Community Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/ius/stable/CentOS/7/$basearch/debuginfo
#mirrorlist=https://mirrors.iuscommunity.org/mirrorlist?repo=ius-centos7-debuginfo&arch=$basearch&protocol=http
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY

[ius-source]
name=IUS Community Packages for Enterprise Linux 7 - $basearch - Source
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/ius/stable/CentOS/7/SRPMS
#mirrorlist=https://mirrors.iuscommunity.org/mirrorlist?repo=ius-centos7-source&arch=source&protocol=http
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY

保存,执行命令 yum update,大功告成。

原文链接 https://blog.xupu.name//p/2018-08-using-tuna-mirror-for-centos-7/

如无特别指明,本站原创文章均采用 CC BY-NC-ND 4.0 许可,转载或引用请注明出处,更多许可信息请查阅这里