设置国内的centos 7 yum源

本人在帝都,觉得首都在线(yun-idc.com)的yum源速度不错,故选它了。具体操作方法是将以下文件保存到 /etc/yum.repos.d/yun-idc.repo 即可。

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.yun-idc.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.yun-idc.com/centos/$releasever/updates/$basearch/
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=http://mirrors.yun-idc.com/centos/$releasever/extras/$basearch/
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=http://mirrors.yun-idc.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

还可以用脚本的方式去跑

#!/bin/bash

cat > /etc/yum.repos.d/yun-idc.repo << EOF
[base]
name=CentOS-\$releasever - Base
baseurl=http://mirrors.yun-idc.com/centos/\$releasever/os/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-\$releasever - Updates
baseurl=http://mirrors.yun-idc.com/centos/\$releasever/updates/\$basearch/
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=http://mirrors.yun-idc.com/centos/\$releasever/extras/\$basearch/
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=http://mirrors.yun-idc.com/centos/\$releasever/centosplus/\$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF

echo [$(date '+%Y-%m-%d %H:%M:%S')] - done.

 

运行以下命令生成缓存
yum clean all
yum makecache

除此以外,还有网易的centos yum源

http://mirrors.163.com/.help/centos.html

 

本文到此结束,谢谢~

你可能感兴趣的:(设置国内的centos 7 yum源)