Nexus3镜像源搭建

2024-04-18
3分钟阅读时长

docker安装nexus3

mkdir -p /data/nexus/data 
chown -R 200 /data/nexus/data 
docker run -tid \
 --restart=always \
 -p 8081:8081 \
 -p 8082:8082 \
 -p 8083:8083 \
 -v /data/nexus/data:/nexus-data \
 --name nexus3 \
  sonatype/nexus3

nexus3里各类仓库源的持久化目录的UID需要为200 ,否则会启动失败

配置nexus3镜像源

登录nexus ip:8081

image-20241114164925427

首次登陆会提示默认admin用户的密码的位置

这里我们通过下面命令获取

cat /data/nexus/data/admin.password

然后再重置密码

仓库类型说明

group:仓库聚合,默认是releases>snapshots>central,可以在仓库管理界面引入其他配置的库,并设置顺序 hosted:私有仓库,存放自己开发的jar snapshots:本地项目的快照仓库 releases: 本地项目发布的正式版本 proxy:代理类型,可以配置aliyun的仓库 central:中央仓库

conda镜像源

先新建一个存储池,类型可以选择file或者s3 , 这里用了本地的file,填写name为conda(自定义),下面path就自动生成对应文件夹路径,点击Save保存

image-20241114164935330

创建一个conda proxy

image-20241114164943041

image-20241114164948647

pkgs channels

image-20241114164956868

依次填写上图中3个红框内的信息,对于pkgs 的channels,我们使用清华源,最后点击页面底部的“Create repository”菜单创建这个repository

cloud channel

同理cloud channel

image-20241114165005618

nvidia channel

国内目前只有南方科技大学的镜像源提供nvidia channel

image-20241114165012513

客户端配置

~/.condarc

channels:
  - defaults
show_channel_urls: true
default_channels:
  - http://10.11.0.33:8081/repository/conda-pkgs/main
  - http://10.11.0.33:8081/repository/conda-pkgs/r
  - http://10.11.0.33:8081/repository/conda-pkgs/msys2
custom_channels:
  conda-forge: http://10.11.0.33:8081/repository/conda-cloud/
  msys2: http://10.11.0.33:8081/repository/conda-cloud
  bioconda: http://10.11.0.33:8081/repository/conda-cloud
  menpo: http://10.11.0.33:8081/repository/conda-cloud
  pytorch: http://10.11.0.33:8081/repository/conda-cloud
  pytorch-lts: http://10.11.0.33:8081/repository/conda-cloud
  simpleitk: http://10.11.0.33:8081/repository/conda-cloud
  deepmodeling: http://10.11.0.33:8081/repository/conda-cloud
  nvidia: http://10.11.0.33:8081/repository/conda-nvidia

测试

image-20241114165020578

pypi镜像源

同理创建一个pypi存储池

然后创建一个pypi代理仓库源

image-20241114165035816

客户端配置

~/.pip/pip.conf

[global]
timeout = 60
trusted-host =  10.11.0.33
index-url = http://10.11.0.33:8081/repository/pypi/simple

docker images源

docker hub 官方源

参考上面conda创建一个blob存储池

再创建一个docker proxy

image-20241114165044012

依次填选红框内3处信息,其他不用管

image-20241114165050585

再创建一个group

image-20241114165056768

依次填选红框内信息

image-20241114165104630

客户端配置

/etc/docker/daemon.json

{
        "registry-mirrors":["http://10.11.0.33:8082"],
        "insecure-registries":["10.11.0.33:8082"]
}

重启docker

systemctl daemon-reload && systemctl restart docker

NVIDIA GPU Cloud (NGC)

创建一个docker proxy 代理这个地址https://nvcr.io,其他的和上面docker hub官方源一样的操作,最后在docker-group里添加nvcr源

image-20241114165110707

客户端说明

docker pull nvcr.io/nvidia/pytorch:21.12-py3

替换成

docker pull nvidia/pytorch:21.12-py3

Google Container Registry(GCR) & k8s Google Container Registry(K8S GCR)

同上创建一个docker proxy 代理这个地址 https://gcr.nju.edu.cn

gcr客户端说明

docker pull gcr.io/cadvisor/cadvisor:v0.39.3

替换成

docker pull cadvisor/cadvisor:v0.39.3

k8s gcr客户端说明

docker pull k8s.gcr.io/kube-proxy:v1.18.6

替换成

docker pull google-containers/kube-proxy:v1.18.6

Github Container Registry (GHCR)

同上创建一个docker proxy 代理这个地址 https://ghcr.io

客户端说明

docker pull ghcr.io/github/super-linter:latest

替换成

docker pull github/super-linter:latest

Quay Container Registry (Quay)

同上创建一个docker proxy 代理这个地址 https://quay.io

客户端说明

docker pull quay.io/prometheus/prometheus:latest

替换成

docker pull prometheus/prometheus:latest

yum源

centos7官方源

先创建一个blob 名叫centos的存储池

再创建yum proxy,填选下面红框内容

image-20241114165121953

客户端配置

将/etc/yum.repos.d/下所有repo删掉,新建一个centos.rpeo:

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.11.0.33:8081/repository/centos/$releasever/os/$basearch/ 
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.11.0.33:8081/repository/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.11.0.33:8081/repository/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.11.0.33:8081/repository/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://10.11.0.33:8081/repository/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.11.0.33:8081/repository/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://10.11.0.33:8081/repository/centos/RPM-GPG-KEY-CentOS-7

创建新的索引

yum clean all
yum makecache

epel源(centos7)

先创建一个epel存储池

再创建yum proxy

image-20241114165140070

客户端配置

配置前需要

yum install epel-release -y

/etc/yum.repos.d/epel.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://10.11.0.33:8081/repository/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
 
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://10.11.0.33:8081/repository/epel/7/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0
 
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://10.11.0.33:8081/repository/epel/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0

然后建立新的索引

yum clean all
yum makecache

docker-ce (centos7)

创建一个yum proxy仓库源

image-20241114165208320

客户端配置

yum install -y yum-utils device-mapper-persistent-data lvm2

/etc/yum.repos.d/docker-ce.repo

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=http://10.11.0.33:8081/repository/docker-ce-yum/linux/centos/gpg

然后安装docker-ce

yum makecache fast
yum -y install docker-ce

rocky官方源

创建一个rocky的blob,再创建一个yum proxy

image-20240419231653898

客户端配置

sed -e 's|^mirrorlist=|#mirrorlist=|g'     -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=http://10.11.0.33:8081/repository/rockylinux|g'     -i.bak     /etc/yum.repos.d/*.repo

apt源

ubuntu 22.04 官方源

创建一个ubuntu22的blob

再创建一个apt proxy

image-20241114165226690

其中ubuntu22.04 的Distribution 代号是jammy

客户端配置

/etc/apt/sources.list

deb http://10.11.0.33:8081/repository/ubuntu22/ jammy main restricted universe multiverse
deb http://10.11.0.33:8081/repository/ubuntu22/ jammy-updates main restricted universe multiverse
deb http://10.11.0.33:8081/repository/ubuntu22/ jammy-backports main restricted universe multiverse

docker-ce (ubuntu22.04)

创建一个apt proxy

image-20241114165241575

代理这个地址 https://mirrors.aliyun.com/docker-ce/linux/ubuntu

客户端配置

apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL http://10.11.0.33:8081/repository/docekr-ce-ub22/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://10.11.0.33:8081/repository/docekr-ce-ub22/ $(lsb_release -cs) stable"
apt-get -y install docker-ce

nvidia-docker(ubuntu18.04-22.04通用)

新建一个apt 的proxy

image-20241114165351360

代理这个地址https://nvidia.github.io

客户端配置

/etc/apt/sources.list.d/nvdocker.list

deb http://10.11.0.33:8081/repository/nvidia-docker-apt/libnvidia-container/stable/ubuntu18.04/$(ARCH) /
#deb http://10.11.0.33:8081/repository/nvidia-docker-apt/libnvidia-container/experimental/ubuntu18.04/$(ARCH) /
deb http://10.11.0.33:8081/repository/nvidia-docker-apt/nvidia-container-runtime/stable/ubuntu18.04/$(ARCH) /
#deb http://10.11.0.33:8081/repository/nvidia-docker-apt/nvidia-container-runtime/experimental/ubuntu18.04/$(ARCH) /
deb http://10.11.0.33:8081/repository/nvidia-docker-apt/nvidia-docker/ubuntu18.04/$(ARCH) /

nccl cuda源

创建一个apt proxy代理 https://developer.download.nvidia.com/compute/cuda/repos/ 这个地址

image-20241114165402533

客户端配置

/etc/apt/sources.list.d/cuda-ubuntu2204-x86_64.list

deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] http://10.11.0.33:8081/repository/nvidia-cuda-apt/ubuntu2204/x86_64/ /
上一页 Clush运维