Linux 常用软件国内镜像

lework · 2019年11月14日 · 最后由 lework 回复于 2019年11月14日 · 375 次阅读
本帖已被设为精华帖!

国内的热门的镜像站点

centos

sed -e 's!^#baseurl=!baseurl=!g' \
       -e  's!^mirrorlist=!#mirrorlist=!g' \
       -e 's!mirror.centos.org!mirrors.ustc.edu.cn!g' \
       -i  /etc/yum.repos.d/CentOS-Base.repo

yum install -y epel-release
sed -e 's!^mirrorlist=!#mirrorlist=!g' \
    -e 's!^#baseurl=!baseurl=!g' \
    -e 's!^metalink!#metalink!g' \
    -e 's!//download\.fedoraproject\.org/pub!//mirrors.ustc.edu.cn!g' \
    -e 's!http://mirrors\.ustc!https://mirrors.ustc!g' \
    -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo

debain

cp /etc/apt/sources.list{,-bak}
cat > /etc/apt/sources.list <<EOF
deb http://mirrors.aliyun.com/debian/ stretch main
deb-src http://mirrors.aliyun.com/debian/ stretch main
deb http://mirrors.aliyun.com/debian/ stretch-updates main
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
EOF
apt-get update

也可以直接替换源

sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

ubuntu

sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

alpine

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

pip

使用 pip 的时候在后面加上-i 参数,指定 pip 的下载源

pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

上面命令每次运行需要指定网址,可进行永久修改:

windows 下: 在 user 目录中创建一个 pip 目录,如:C:\Users(用户)\xx\pip,新建文件 pip.ini,内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

linux 下: 修改 ~/.pip/pip.conf(如果没有自己创建一个), 内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

easy_install 源

cat >> ~/.pydistutils.cfg  <<EOF
[easy_install]
index-url = https://mirrors.ustc.edu.cn/pypi/web/simple
EOF

ruby

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
bundle config mirror.https://rubygems.org https://gems.ruby-china.com

npm

npm config set registry https://registry.npm.taobao.org

go 代理

export GO111MODULE=on
export GO_PROXY=https://mirrors.aliyun.com/goproxy/,https://goproxy.io,https://gorpoxy.cn

1.使用 go1.11 以上版本并开启 go module 机制 2.导出 GOPROXY 环境变量

export GOPROXY=https://mirrors.aliyun.com/goproxy/

jenkins

游览器访问 jenkins 例如 [http://localhost:8080/pluginManager/advanced]

修改为国内源 https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

docker-ce

CentOS/RHEL

curl -o /etc/yum.repos.d/docker-ce.repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
sed -i 's#download.docker.com#mirrors.ustc.edu.cn/docker-ce#g' /etc/yum.repos.d/docker-ce.repo

Debian

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] http://mirrors.ustc.edu.cn/docker-ce/linux/debian \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce

Ubuntu

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce

容器镜像

docker 客户端

指定registry-mirrors

cp  /etc/docker/daemon.json{,-bak}
cat > /etc/docker/daemon.json <<EOF
{
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "100m",
        "max-file": "3"
    },
    "live-restore": true,
    "max-concurrent-downloads": 10,
    "max-concurrent-uploads": 10,
    "storage-driver": "overlay2",
    "storage-opts": [
        "overlay2.override_kernel_check=true"
    ],
    "exec-opts": ["native.cgroupdriver=systemd"],
    "registry-mirrors": [
        "https://docker.mirrors.ustc.edu.cn/",
        "registry.docker-cn.com"
    ]
}
EOF

docker.io 镜像加速

docker pull dockerhub.azk8s.cn/library/centos

gcr.io 镜像加速

docker pull gcr.azk8s.cn/google_containers/kube-apiserver:v1.16.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.16.3

quay.io 镜像加速

docker pull quay.azk8s.cn/coreos/kube-state-metrics:v1.7.2

也可以使用脚本自动下载镜像

# 下载gcr镜像
curl -sSL https://git.io/getgcr | bash -s gcr.io/google_containers/kube-apiserver:v1.16.3

# 下载k8s镜像
curl -sSL https://git.io/getgcr | bash -s k8s.gcr.io/pause-amd64:3.1

# 指定k8s版本,下载全套件
curl -sSL https://git.io/getgcr | bash -s - -t v1.16.3

# 下载quay.io镜像
curl -sSL https://git.io/getgcr | bash -s quay.io/coreos/kube-state-metrics:v1.7.2

kubernetes

Debian / Ubuntu

apt-get update && apt-get install -y apt-transport-https
curl 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  
apt-get update
apt-get install -y kubelet kubeadm kubectl

CentOS / RHEL / Fedora

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[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
setenforce 0
yum install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet

Cygwin

选择 Install from Internet, 在” User URL” 处输入以下地址:

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

maven

maven 的 settings.xml

<mirrors>
<mirror>
    <id>aliyunmaven</id>
    <mirrorOf>*</mirrorOf>
    <name>阿里云公共仓库</name>
    <url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>

maven 项目的pom.xml

<repositories>
    <repository>
        <id>nexus-163</id>
        <name>Nexus 163</name>
        <url>http://mirrors.163.com/maven/repository/maven-public/</url>
        <layout>default</layout>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>nexus-163</id>
        <name>Nexus 163</name>
        <url>http://mirrors.163.com/maven/repository/maven-public/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>

gradle

build.gradle 文件

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/public/' }
        mavenLocal()
        mavenCentral()
    }
}
lework 将本帖设为了精华贴 11月14日 06:29
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册