说明

Linux软件源、开发语言依赖源、容器镜像源基本都在国外,因此国内访问非常慢

国内各大云厂商基本都做了对应的镜像源,如无特殊情况,都使用清华的源https://mirrors.tuna.tsinghua.edu.cn作为展示

北大源 http://mirrors.pku.edu.cn

Linux系统

CentOS 6/7/8

系统源配置

export REPO_MIRROR="https://mirrors.tuna.tsinghua.edu.cn/centos"
sed -e "s!#baseurl!baseurl!g" \
      -e "s!mirrorlist!#mirrorlist!g" \
      -e "s!http://mirror.centos.org!${REPO_MIRROR}!g" \
      -i /etc/yum.repos.d/CentOS-Base.repo

EPEL源配置

export REPO_MIRROR="https://mirrors.tuna.tsinghua.edu.cn/epel"
sed -e "s!^metalink=!#metalink=!g" \
      -e "s!^#baseurl=!baseurl=!g" \
      -e "s!https://download.fedoraproject.org/pub/epel!${REPO_MIRROR}!g" \
      -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo

Debian9/10

配置说明

export REPO_MIRROR="https://mirrors.tuna.tsinghua.edu.cn"
sed -e "s@http://deb.debian.org@${REPO_MIRROR}@g" \
      -e "s@http://security.debian.org@${REPO_MIRROR}@g" \
      -e "s@^deb-src@# deb-src@g" \
      -i /etc/apt/sources.list

Ubuntu16.04/18.04/20.04

配置说明

export REPO_MIRROR="https://mirrors.tuna.tsinghua.edu.cn"
sed -e "s@http://.*archive.ubuntu.com@${REPO_MIRROR}@g" \
      -e "s@http://.*security.ubuntu.com@${REPO_MIRROR}@g" \
      -e "s@^deb-src@# deb-src@g" \
      -i /etc/apt/sources.list

开发语言

Python pip 临时使用

pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple some-package

配置方法

直接写配置文件

mkdir -p ~/.pip
cat > ~/.pip/pip.conf <<EOF
[global]
index-url = https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
trusted-host = mirrors.tuna.tsinghua.edu.cn
timeout = 120
[install]
trusted-host = mirrors.tuna.tsinghua.edu.cn
EOF

pip命令配置(针对较新版本的pip)

清华大学

pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
pip config set global.trusted-host mirrors.tuna.tsinghua.edu.cn
pip config set global.timeout 120
pip config set install.trusted-host mirrors.tuna.tsinghua.edu.cn

阿里云公网

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set global.trusted-host mirrors.aliyun.com
pip config set global.timeout 120
pip config set install.trusted-host mirrors.aliyun.com

阿里云内网

pip config set global.index-url http://mirrors.cloud.aliyuncs.com/pypi/simple/
pip config set global.trusted-host mirrors.cloud.aliyuncs.com
pip config set global.timeout 120
pip config set install.trusted-host mirrors.cloud.aliyuncs.com

conda

Linux系统保存到~/.condarc

MacOS系统保存到~/.condarc

Windows系统保存到%HOMEPATH%/.condarc

channels:
     - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

NPM

淘宝(网站证书已过期)

https://npm.taobao.org/mirrors/npm/
# 设置nodejs工具的镜像地址
http://npm.taobao.org/mirrors/node
# 设置alinode镜像
http://npm.taobao.org/mirrors/alinode
# 设置浏览器引擎驱动镜像地址
http://npm.taobao.org/mirrors/phantomjs
http://npm.taobao.org/mirrors/chromedriver
http://npm.taobao.org/mirrors/operadriver
http://npm.taobao.org/mirrors/selenium
# 设置Electron和node-inspector的镜像地址
https://npm.taobao.org/mirrors/electron/
https://npm.taobao.org/mirrors/node-inspector/

可调整为 npm config set registry https://registry.npmmirror.com

华为云

https://mirrors.huaweicloud.com/repository/npm/
# 设置nodejs工具的镜像地址
https://mirrors.huaweicloud.com/nodejs
# 设置Node-Sass的镜像地址
https://mirrors.huaweicloud.com/node-sass
# 设置浏览器引擎驱动镜像地址
https://mirrors.huaweicloud.com/phantomjs
https://mirrors.huaweicloud.com/chromedriver
https://mirrors.huaweicloud.com/operadriver
# 设置Electron和Python的镜像地址
https://mirrors.huaweicloud.com/electron/
https://mirrors.huaweicloud.com/python

配置方法

npm config set registry https://mirrors.huaweicloud.com/repository/npm/
npm config set disturl https://mirrors.huaweicloud.com/nodejs
npm config set sass_binary_site https://mirrors.huaweicloud.com/node-sass
npm config set phantomjs_cdnurl https://mirrors.huaweicloud.com/phantomjs
npm config set chromedriver_cdnurl https://mirrors.huaweicloud.com/chromedriver
npm config set operadriver_cdnurl https://mirrors.huaweicloud.com/operadriver
npm config set electron_mirror https://mirrors.huaweicloud.com/electron/
npm config set python_mirror https://mirrors.huaweicloud.com/python 
npm cache clean -f

Golang

要求

  • Golang 1.11+
  • 开启Go Module
  • Golang 1.13+里面的GOPROXY变成了数组,可以定义多个Proxy

阿里云

https://mirrors.aliyun.com/goproxy/
https://mirrors.cloud.aliyuncs.com/goproxy/

华为云

https://mirrors.huaweicloud.com/goproxy

腾讯云

https://mirrors.cloud.tencent.com/go/

七牛云

https://goproxy.cn

针对Golang 1.11

go env -w GO111MODULE=on
go env -w GOPROXY='https://mirrors.aliyun.com/goproxy'

针对Golang 1.13+

go env -w GO111MODULE=on
go env -w GOPROXY='https://goproxy.cn,https://mirrors.aliyun.com/goproxy,direct'
# 这里把git.example.com设置为私有的git服务器
go env -w GOPRIVATE="git.example.com"
# 如果是纯内网环境可以把GOSUMDB设置为off
go env -w GOSUMDB="sum.golang.google.cn"
go env -w GONOSUMDB=none

Maven

阿里云

阿里云代理了Maven的公共仓库,这里是说明文档

腾讯云

华为云

Maven配置

打开 Maven 的配置文件(windows机器一般在maven安装目录的conf/settings.xml),在<mirrors></mirrors>标签中添加 mirror 子节点:

<mirrors>
  <mirror>
    <id>aliyunmaven</id>
    <mirrorOf>*</mirrorOf>
    <url>https://maven.aliyun.com/repository/public</url>
  </mirror>
  <mirror>
    <id>huaweicloud</id>
    <mirrorOf>*</mirrorOf>
    <url>https://mirrors.huaweicloud.com/repository/maven/</url>
  </mirror>
  <mirror>
    <id>nexus-tencentyun</id>
    <mirrorOf>*</mirrorOf>
    <url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
  </mirror> 
</mirrors>

如果想使用其它代理仓库,可在<repository></repository>节点中加入对应的仓库使用地址。以使用spring代理仓为例:

<repository>
  <id>spring</id>
  <url>https://maven.aliyun.com/repository/spring</url>
  <releases>
    <enabled>true</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

Gradle配置

在 build.gradle 文件中加入以下代码:

allprojects {
  repositories {
    maven { url 'https://maven.aliyun.com/repository/public/' }
    mavenLocal()
    mavenCentral()
  }
}


如果想使用 maven.aliyun.com 提供的其它代理仓,以使用 spring 仓为例,代码如下:

allprojects {
  repositories {
    maven { url 'https://maven.aliyun.com/repository/public/' }
    maven { url 'https://maven.aliyun.com/repository/spring/'}
    mavenLocal()
    mavenCentral()
  }
}

容器

DockerHub

说明

  • docker配置文件路径/etc/docker/daemon.json
  • 多个mirrors地址可以合并

配置方法

{
  "registry-mirrors": [
    "https://pqbap4ya.mirror.aliyuncs.com",
    "https://mirror.ccs.tencentyun.com",
    "https://05f073ad3c0010ea0f4bc00b7105ec20.mirror.swr.myhuaweicloud.com"
  ]
}
{
  "registry-mirrors": [
    "https://swr.cn-south-1.myhuaweicloud.com",
    "https://r9xxm8z8.mirror.aliyuncs.com",
    "https://registry.docker-cn.com",
    "https://docker.nju.edu.cn/",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://r9xxm8z8.mirror.aliyuncs.com",
    "https://docker.m.daocloud.io"
   ]
}

Kubernetes软件源

说明

  • 这里用阿里云的源

CentOS 7/8

cat > /etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

Debian 9/10

curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-stretch main
EOF

Ubuntu 16.04/18.04/20.04

curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF

k8s.gcr.io

第三方维护的,项目地址

registry.aliyuncs.com/k8sxio

quay.io

quay.azk8s.cn(于 2020年4月2日限制了对 Azure China 之外的 IP访问)
quay.mirrors.ustc.edu.cn (从中科大校外对 Quay Container Registry 的镜像缓存的访问会被 302 重定向至源站)
quay-mirror.qiniu.com (已停止公网DNS解析)

JDK 直接下载

清华镜像 

https://mirrors.tuna.tsinghua.edu.cn/Adoptium/

关于重命名 AdoptOpenJDK 镜像为 Adoptium 的通知

编程宝库

http://www.codebaoku.com/jdk/jdk-index.html

这个镜像站,包含Oracle JDK,、OpenJDK、AdoptOpenJDK、阿里的OpenJDK( Dragonwell)和华为的OpenJDK(毕昇 JDK ),目前是国内最全的Java JDK镜像导航站。

华为镜像

https://repo.huaweicloud.com/java/jdk/

injdk(个人站点)

https://www.injdk.cn/

Archived OpenJDK General-Availability Releases

https://jdk.java.net/archive/

  • 无标签
写评论...