努力挣扎的生活 努力挣扎的生活
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • 运维基础
  • 监控
  • 日志系统
  • 安全记录
  • 分布式存储
  • gitlab安装
  • jenkins安装和管理
  • Jenkins工具集成
  • pipeline流水线
  • Docker
  • Kubernetes
  • Nexus
  • Rancher
  • Prometheus
  • ELK(EFK)
  • 虚拟化
  • Mysql
  • PostgreSQL
  • Redis
  • MongoDB
  • clickhouse
关于
  • 分类
  • 标签
  • 归档
  • 收藏
  • 更多
GitHub (opens new window)

yangfk

瑟瑟发抖的小运维
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • 运维基础
  • 监控
  • 日志系统
  • 安全记录
  • 分布式存储
  • gitlab安装
  • jenkins安装和管理
  • Jenkins工具集成
  • pipeline流水线
  • Docker
  • Kubernetes
  • Nexus
  • Rancher
  • Prometheus
  • ELK(EFK)
  • 虚拟化
  • Mysql
  • PostgreSQL
  • Redis
  • MongoDB
  • clickhouse
关于
  • 分类
  • 标签
  • 归档
  • 收藏
  • 更多
GitHub (opens new window)
  • Docker

  • Kubernetes

  • Nexus

    • Nexus3部署
    • Nexus3配置
      • Nexus3 配置
        • 创建Blob Stores
        • 创建Npm Repository
        • 配置docker Repository
        • Nexus的Security
        • Nexus集成ldap
        • Nexus3的Tasks
  • Rancher

  • Prometheus

  • ELK

  • 虚拟化

  • Istio

//
  • 云计算虚拟化
  • Nexus
yangfk
2022-01-16

Nexus3配置

//

# Nexus3 配置

# 创建Blob Stores

configuration => Repository => Blob Stores => Create blob store

nexus_blog1.jpg

  • 添加blob领域

nexus_blog1.jpg

# 创建Npm Repository

configuration => Repository => Repositories => Create repository

仓库类型主要分为hosted/proxy/group三种。

类型 具体说明
hosted 本地存储,像官方仓库一样提供本地私库功能
proxy 提供代理其它仓库的类型
group 组类型,能够组合多个仓库为一个地址提供服务
  • 先创建hosted仓库

只有hosted仓库才能存储缓存包

nexus_blog1.jpg

  • 创建proxy仓库
https://registry.yarnpkg.com
https://registry.npm.taobao.org
https://registry.npmjs.org
1
2
3

nexus_blog1.jpg

  • 创建group仓库

nexus_blob4.jpg

# 配置docker Repository

docker镜像管理除了常用的 registry,harbor,还可以用Nexus3作为私服仓库管理

由于私有仓库时间长了,会存储大量的文件,且使用docker作为私服构建镜像使用,建议数据目录至少1T

模式 pull push
hosted 是 是
proxy 是 否
group 是 否
  • 先创建hosted仓库

nexus_docker1.jpg

  • 创建proxy仓库
https://7bezldxe.mirror.aliyuncs.com
https://docker.mirrors.ustc.edu.cn
https://registry-1.docker.io
http://f1361db2.m.daocloud.io
1
2
3
4

nexus_docker1.jpg

  • 创建group仓库

nexus_docker1.jpg

  • 配置nginx

vi /etc/nginx/sites-enabled/nexus3.conf

upstream nexus_docker_get {
    server 127.0.0.1:8082;
}
 
upstream nexus_docker_put {
    server 127.0.0.1:8083;
}
upstream nexus_dev_docker_put {
    server 127.0.0.1:8084;
}
server {
    listen 80;
    server_name idocker.io;
    client_max_body_size 0;
    client_body_buffer_size  2048m;
    chunked_transfer_encoding on;
    index index.html index.htm index.php;
    
    # 设置默认使用推送代理
    set $upstream "nexus_docker_put";
    # 当请求是GET,也就是拉取镜像的时候,这里改为拉取代理,如此便解决了拉取和推送的端口统一
    if ( $request_method ~* 'GET') {
        set $upstream "nexus_docker_get";
    }
    # 只有本地仓库才支持搜索,所以将搜索请求转发到本地仓库,否则出现500报错
    if ($request_uri ~ '/search') {
        set $upstream "nexus_docker_put";
    }
    
    location / {
        proxy_pass http://$upstream;
        proxy_set_header Host $host;
        proxy_connect_timeout 75;
        proxy_send_timeout 1200;
        proxy_read_timeout 1200;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_buffering off;
        proxy_request_buffering off;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
server {
    listen 80;
    server_name dev.idocker.io;

    listen 443 ssl;
    ssl_certificate         ssl/idocker.io.pem;
    ssl_certificate_key     ssl/idocker.io-key.pem;
    ssl_session_timeout     10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!MD5:!EXPORT56:!EXP;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;

    client_max_body_size 0;
    client_body_buffer_size 4096m;
    chunked_transfer_encoding on;
    underscores_in_headers on;
    index index.html index.htm index.php;
	
    location / {
            proxy_pass http://nexus_dev_docker_put;
            proxy_set_header Host $host;
            proxy_connect_timeout 3600;
            proxy_send_timeout 3600;
            proxy_read_timeout 3600;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_buffering off;
            proxy_request_buffering off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
#           proxy_set_header Authorization $http_authorization;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  • 配置域名解析,测试拉取上传镜像

记录一个push提示内存不够的报错

nexus_docker1.jpg

测试截图

nexus_docker1.jpg

# Nexus的Security

  • 创建Roles,分配部分权限,可以查看所有的仓库内容,可以通过浏览器上传

nexus_roles.jpg

# Nexus集成ldap

nexus_roles.jpg

# Nexus3的Tasks

随着我们之前创建的仓库,默认会创建一些检查的任务,当磁盘不是很充裕的时候,想要删除一些存储文件,但发现删除之后空间未减少

  • 创建compact-blob-store清理空间

nexus_blog1.jpg

设置 => System => Tasks(最下面) => docker-compact-blob-store

nexus_blog1.jpg

  • 添加docker-incomplete uploads

有时候会上传一半然后网络中断

nexus_blog1.jpg

创建完成点击进入,还可以手动执行

借鉴博客realms (opens new window)

借鉴博客docker (opens new window)

//
如果此文章对您有帮助,点击 -->> 请博主喝咖啡 (opens new window)
上次更新: 2024/03/13, 15:03:45
Nexus3部署
rancher部署

← Nexus3部署 rancher部署→

最近更新
01
postgreSQL通过keepalived配置主从自动切换
06-30
02
ubuntu2204编译安装php7.4.33
06-30
03
nginx之resolver解析
06-19
更多文章>
Theme by Vdoing | Copyright © 2019-2025 yangfk | 湘ICP备2021014415号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×
//