Published on

Mirror

Authors
  • avatar
    Name
    ttyS3
    Twitter

老灯常用镜像源

Linux 镜像源

tuna 和 ustc 的源比较全面, 而 sjtug 的源相对来说比较少,比如 RHEL 系常用的 epelrpmfusion 都没有。

ArchLinux 源

/etc/pacman.d/mirrorlist

Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = https://mirror.sjtu.edu.cn/archlinux/$repo/os/$arch

ArchLinux CN 源 编辑 /etc/pacman.conf 在最后加上:

[archlinuxcn]
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$repo/os/$arch
Server = https://mirrors.sjtug.sjtu.edu.cn/archlinux-cn/$arch

注意:sjtug 中间有一个-, 而 ustc 则没有,直接是 archlinuxcn

Fedora 源使用方法(适用于Fedora 32之后)

注意 Fedora 32 之后的将默认的http://download.fedoraproject.org/pub/fedora/linux 变成了 http://download.example/pub/fedora/linux

sjtug

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.sjtug.sjtu.edu.cn/fedora/linux|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo

repo与url对应关系:

fedora                 -> https://mirrors.sjtug.sjtu.edu.cn/fedora/linux/releases/32/Everything/x86_64/
fedora-modular         -> https://mirrors.sjtug.sjtu.edu.cn/fedora/linux/releases/32/Modular/x86_64/

fedora-updates         -> https://mirrors.sjtug.sjtu.edu.cn/fedora/linux/updates/32/Everything/x86_64/
fedora-updates-modular -> https://mirrors.sjtug.sjtu.edu.cn/fedora/linux/updates/32/Modular/x86_64/

注意: ustc 源 和 tuna 源 的url里都没有linux这层目录

ustc源:

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.ustc.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo

tuna源:

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo

rpmfusion源:

http://download1.rpmfusion.org/ 替换为

https://mirrors.ustc.edu.cn/rpmfusion/
https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download1.rpmfusion.org/|baseurl=https://mirrors.ustc.edu.cn/rpmfusion/|g' \
         -i.bak \
         /etc/yum.repos.d/rpmfusion-free.repo \
         /etc/yum.repos.d/rpmfusion-free-updates.repo \
         /etc/yum.repos.d/rpmfusion-free-updates-testing.repo \
         /etc/yum.repos.d/rpmfusion-nonfree.repo \
         /etc/yum.repos.d/rpmfusion-nonfree-steam.repo \
         /etc/yum.repos.d/rpmfusion-nonfree-updates.repo \
         /etc/yum.repos.d/rpmfusion-nonfree-updates-testing.repo \
         /etc/yum.repos.d/rpmfusion-nonfree-nvidia-driver.repo

misc:

sjtug 有提供 Google Fonts 反代, 使用方式举例: https://fonts.googleapis.com/css?family=Roboto 换成 https://google-fonts.mirrors.sjtug.sjtu.edu.cn/css?family=Roboto 即可

ustc 有提供golang下载: https://mirrors.ustc.edu.cn/golang/


docker-registry 反代

2021-01-07 新增加 nwafu dockerhub反代

docker 配置

编辑 /etc/docker/daemon.json, 增加registry-mirrors配置:

{
  "registry-mirrors": [
    "https://docker.mirrors.sjtug.sjtu.edu.cn",
    "https://dockerhub.mirrors.nwafu.edu.cn",
    "https://hub-mirror.c.163.com"
  ]
}

podman 配置

备份原配置 /etc/containers/registries.conf, 修改内容为:

unqualified-search-registries = [
    'docker.io',
    'registry.access.redhat.com',
    'quay.io',
    'registry.fedoraproject.org',
    'registry.centos.org'
]

[[registry]]
prefix = "docker.io"
insecure = false
blocked = false
location = "docker.mirrors.sjtug.sjtu.edu.cn"

[[registry]]
prefix = "docker.io"
location = "dockerhub.mirrors.nwafu.edu.cn"

注意:曾经最好用的azk8s镜像dockerhub.azk8s.cn已经不再对外开放

sjtug docker registry 测试结果: it works!

docker pull docker.mirrors.sjtug.sjtu.edu.cn/library/busybox
Using default tag: latest
latest: Pulling from library/busybox
91f30d776fb2: Pull complete
Digest: sha256:9ddee63a712cea977267342e8750ecbc60d3aab25f04ceacfa795e6fce341793
Status: Downloaded newer image for docker.mirrors.sjtug.sjtu.edu.cn/library/busybox:latest
docker.mirrors.sjtug.sjtu.edu.cn/library/busybox:latest

经测试, utsc 的docker反代实际上是重定向到 https://hub-mirror.c.163.com:

curl -I https://docker.mirrors.ustc.edu.cn
HTTP/1.1 200 Connection established

HTTP/2 302
server: openresty
date: Thu, 09 Jul 2020 16:49:10 GMT
content-type: text/html
content-length: 142
location: https://hub-mirror.c.163.com/

163 docker registry 测试结果: it works!

docker pull hub-mirror.c.163.com/library/busybox
Using default tag: latest
latest: Pulling from library/busybox
Digest: sha256:9ddee63a712cea977267342e8750ecbc60d3aab25f04ceacfa795e6fce341793
Status: Downloaded newer image for hub-mirror.c.163.com/library/busybox:latest
hub-mirror.c.163.com/library/busybox:latest

七牛镜像没有通过测试:

docker pull reg-mirror.qiniu.com/library/busybox
Using default tag: latest
Error response from daemon: manifest for reg-mirror.qiniu.com/library/busybox:latest not found: manifest unknown: manifest unknown

Golang GOPROXY 反代

Go 1.13 或以上版本 (推荐)

打开终端执行一次以下命令即搞定:

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

或者使用老方式:

export GO111MODULE=on
export GOPROXY=https://goproxy.cn

官方文档: https://goproxy.cn/

Rust 反代

  • 环境变量 RUSTUP_DIST_SERVER 用于更新 toolchain
  • 环境变量 RUSTUP_UPDATE_ROOT 用于更新 rustup
  • 配置crates-io镜像则需要修改~/.cargo/config文件

Bytedance RsProxy.cn

RsProxy.cn 目前已支持 sparse 协议

The sparse protocol fetches individual metadata files using plain HTTP requests. Since Cargo only downloads the metadata for relevant crates, the sparse protocol can save significant time and bandwidth.

~/.cargo/config:

[source.crates-io]
replace-with = 'rsproxy-sparse'

[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"

[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"

[net]
git-fetch-with-cli = true

Rustup Mirror

~/.zshrc or ~/.bashrc:

export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"

sjtug

rust-static储存了rust的工具链及rustup本身的镜像。

使用方法:安装rustup,将以下环境变量加入~/.bashrc或类似文件中:

export RUSTUP_DIST_SERVER=https://mirrors.sjtug.sjtu.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.sjtug.sjtu.edu.cn/rust-static/rustup

crates.io

编辑 ~/.cargo/config

[source]

[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index/"

[source.crates-io]
replace-with = "sjtu"

tuna

Rustup 镜像

注意: TUNA 只会保留一段时间的 nightly

使用 rustup 安装 rust 时,若要启用 TUNA 源,执行:

$ # for bash
$ RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install stable # for stable
$ # for fish
$ env RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install stable # for stable
$ # for bash
$ RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly # for nightly
$ # for fish
$ env RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly # for nightly
$ # for bash
$ RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly-YYYY-mm-dd
$ # for fish
$ env RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly-YYYY-mm-dd

若要长期启用 TUNA 源,执行:

$ # for bash
$ echo 'export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup' >> ~/.bash_profile
$ # for fish
$ echo 'set -x RUSTUP_DIST_SERVER https://mirrors.tuna.tsinghua.edu.cn/rustup' >> ~/.config/fish/config.fish

注:rustup 在判断是否需要更新时依赖于 toml 的 sha256 ,由于 toml 内容中相关链接被替换为 TUNA 源,第一次切换到 TUNA 源时各个 channel 会被认为需要更新。

官方文档: https://mirrors.tuna.tsinghua.edu.cn/help/rustup/

Rust crates.io 索引镜像使用帮助

编辑 ~/.cargo/config 文件,添加以下内容:

[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

该镜像可加快 cargo 读取软件包索引的速度。

官方文档: https://mirrors.tuna.tsinghua.edu.cn/help/crates.io-index.git/

ustc

export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup

官方文档: https://mirrors.ustc.edu.cn/help/rust-static.html

编辑 ~/.cargo/config 文件,添加以下内容:

[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

如果所处的环境中不允许使用 git 协议,可以把上述地址改为:

registry = "https://mirrors.ustc.edu.cn/crates.io-index"

警告: cargo search 无法使用镜像

官方文档: https://mirrors.ustc.edu.cn/help/crates.io-index.html

速度测试

我这边是南方电信, 注: 其中ustc没有提供镜像iso下载,而是重定向到了aliyun.

curl -I https://mirrors.ustc.edu.cn/fedora/releases/32/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-32-1.6.iso
HTTP/1.1 200 Connection established

HTTP/2 302
server: openresty
date: Sat, 11 Jul 2020 03:31:19 GMT
content-type: text/html
content-length: 142
location: https://mirrors.aliyun.com/fedora/releases/32/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-32-1.6.iso

虽然都是教育网, 但是速度上还是差异较大的。阿里云的下载速度一般是不错的,但是以老灯以前的使用经验来看,偶尔会出点小问题,同时不及时或者cdn连接问题。

测试命令: 直接采用Fedora上的curl(支持-Z, --parallel Perform transfers in parallel参数以多线程方式下载) ,设置的传输时间为10秒.

curl -m 10 -LZO https://mirrors.sjtug.sjtu.edu.cn/fedora/linux/releases/32/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-32-1.6.iso

DL% UL%  Dled  Uled  Xfers  Live   Qd Total     Current  Left    Speed
 20 --   389M     0     1     1     0  0:00:46  0:00:09  0:00:36 40.3M      curl: (28) Operation timed out after 10000 milliseconds with 426433583 out of 1966178304 bytes received
 21 --   406M     0     1     0     0  0:00:46  0:00:10  0:00:36 40.7M

curl -m 10 -LZO https://mirrors.aliyun.com/fedora/releases/32/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-32-1.6.iso
DL% UL%  Dled  Uled  Xfers  Live   Qd Total     Current  Left    Speed
 11 --   221M     0     1     1     0  0:01:24  0:00:09  0:01:14 22.2M      curl: (28) Operation timed out after 10000 milliseconds with 239353102 out of 1966178304 bytes received
 12 --   228M     0     1     0     0  0:01:26  0:00:10  0:01:15 21.7M

curl -m 10 -LZO https://mirrors.tuna.tsinghua.edu.cn/fedora/releases/32/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-32-1.6.iso
DL% UL%  Dled  Uled  Xfers  Live   Qd Total     Current  Left    Speed
  2 --  52.8M     0     1     1     0  0:09:03  0:00:10  0:08:47 3536k      curl: (28) Operation timed out after 10001 milliseconds with 55427018 out of 1966178304 bytes received
  2 --  52.8M     0     1     0     0  0:16:03  0:00:10  0:15:35 1993k

很明显,下载速度上sjtug打败了其它几家。 但是要注意的是, sjtug 的源支持数量 比 tuna 和 ustc 少很多。