镜像站
配置方法
CentOS
- CentOS 7 通过默认配置自动选择镜像源,一般不需要再手动配置
- 如果系统更新了 centos-release 包,已做的修改会被覆盖,需要重新配置
```bashcd /etc/yum.repos.d && mkdir -p bak
mv -f *.repo bak
curl -so /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tencent.com/repo/centos7_base.repo
yum clean all
yum makecache
挂载镜像文件
mount -t iso9660 -o ro /dev/sr0 /media
新建 cdrom.repo 文件
cat > /etc/yum.repo.d/cdrom.repo << EOF [cdrom] name=cdrom baseurl=file:///media gpgcheck=0 EOF
yum clean all yum makecache
```bash
cd /etc/yum.repos.d && mkdir -p bak
mv -f *.repo bak
# 定界符 EOF 加引号以关闭文本中的变量扩展
cat > local.repo << 'EOF'
[local-base]
name=local-$releasever - Base
baseurl=http://192.168.88.45/centos/$releasever/os/$basearch/
gpgcheck=0
[local-updates]
name=local-$releasever - Updates
baseurl=http://192.168.88.45/centos/$releasever/updates/$basearch/
gpgcheck=0
[local-extras]
name=local-$releasever - Extras
baseurl=http://192.168.88.45/centos/$releasever/extras/$basearch/
gpgcheck=0
[local-centosplus]
name=local-$releasever - Plus
baseurl=http://192.168.88.45/centos/$releasever/centosplus/$basearch/
gpgcheck=0
EOF
yum clean all
yum makecache
# 切换镜像源
sed -i 's#//[^/]*/#//192.168.88.45/#' /etc/yum.repos.d/local.repo
sed -i 's#//[^/]*/#//mirrors.aliyun.com/#' /etc/yum.repos.d/local.repo
Ubuntu
sudo cp /etc/apt/sources.list{,.orig}
sudo sed -i.bak "s#//.*/ubuntu#//mirrors.ustc.edu.cn/ubuntu#" /etc/apt/sources.list
sudo apt-get clean all
sudo apt-get update
Docker
更换 Docker Hub 镜像源
mkdir -p /etc/docker
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
EOF
重启服务
systemctl daemon-reload
systemctl restart docker
Homebrew
TODO