0x0034's Blog.

开发资源加速

字数统计: 809阅读时长: 4 min
2021/12/09

Github资源加速

你还在为github限速而烦恼吗? 你还在为没有机场而烦恼吗? 你还在为回到家下载源慢,不想卷而烦恼吗?
注: 仅面向没有机场的普通开发者, 有机场的大佬请当没看到.

Clone加速

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 方法一:手动替换地址
#原地址
git clone https://github.com/kubernetes/kubernetes.git

# 将github.com 替换为github.com.cnpmjs.org 或者 hub.fastgit.org 哪个快用哪个

git clone https://github.com.cnpmjs.org/kubernetes/kubernetes.git
#或者
git clone https://hub.fastgit.org/kubernetes/kubernetes.git


# gitclone.com 是将原url 拼接到 gitclone.com/的uri中
# 示例: https://gitclone.com/+github.com/kubernetes/kubernetes.git
git clone https://gitclone.com/github.com/kubernetes/kubernetes.git


# 方法二:配置git自动替换(不建议)

git config --global url."https://hub.fastgit.org".insteadOf https://github.com
# 取消设置
git config --global --unset url.https://github.com/.insteadof

Release 加速

1
2
3
4
5
6
7
# 同样将url中的 github.com 替换为 download.fastgit.org 或者 hub.fastgit.org 
# 同样那个快用哪个.

wget https://github.com/chaosblade-io/chaosblade/releases/download/v1.4.0/chaosblade-1.4.0-linux-amd64.tar.gz
# 替换为
wget https://download.fastgit.org/chaosblade-io/chaosblade/releases/download/v1.4.0/chaosblade-1.4.0-linux-amd64.tar.gz
wget https://hub.fastgit.org/chaosblade-io/chaosblade/releases/download/v1.4.0/chaosblade-1.4.0-linux-amd64.tar.gz

Raw 文件加速

1
2
3
4
5
6
7
# 同样将url中的 raw.githubusercontent.com 替换为 raw.staticdn.net 或者 raw.fastgit.org
# 同样那个快用哪个.

wget https://raw.githubusercontent.com/kubernetes/kubernetes/master/README.md
# 替换为
wget https://raw.staticdn.net/kubernetes/kubernetes/master/README.md
wget https://raw.fastgit.org/kubernetes/kubernetes/master/README.md

Golang 国内加速

Go 1.13 及以上(推荐)

打开你的终端并执行

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

macOS 或 Linux

打开你的终端并执行

1
2
3
4
5
6
7
8
export GO111MODULE=on
export GOPROXY=https://goproxy.cn

# 或者

echo "export GO111MODULE=on" >> ~/.profile
echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
source ~/.profile

Maven 加速

修改setting.xml,添加如下内容.

阿里云

1
2
3
4
5
6
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>

腾讯云

1
2
3
4
5
6
<mirror>
<id>nexus-tencentyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus tencentyun</name>
<url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
</mirror>

pip

修改文件~/.pip/pip.conf

1
2
3
4
5
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

CentOS Yum加速

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 备份是个好的习惯
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cVersion=$(cat /etc/redhat-release |awk -F'release ' '{print $2}'| awk -F. '{print $1}')


# 阿里云
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-${cVersion}.repo

# 腾讯云
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos${cVersion}_base.repo


# 清理并重新生成缓存

yum clean all && yum makecache

Ubuntu apt加速

https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b113cPbgN
自己看吧

alpine apk加速

sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

参考文章

https://blog.frytea.com/archives/504/

https://goproxy.cn/

https://developer.aliyun.com/mirror/

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

CATALOG
  1. 1. Github资源加速
    1. 1.1. Clone加速
    2. 1.2. Release 加速
    3. 1.3. Raw 文件加速
  2. 2. Golang 国内加速
    1. 2.1. Go 1.13 及以上(推荐)
    2. 2.2. macOS 或 Linux
  3. 3. Maven 加速
    1. 3.1. 阿里云
    2. 3.2. 腾讯云
  4. 4. pip
  5. 5. CentOS Yum加速
  6. 6. Ubuntu apt加速
  7. 7. alpine apk加速
  8. 8. 参考文章