zoukankan      html  css  js  c++  java
  • 九、微服务学习笔记-docker compose 部署Nexus

    一、什么是Nexus

    Nexus是一个强大的Maven仓库管理器,极大简化了内部仓库的维护和外部仓库的访问。

    1、对底层代码进行了大规模重构,提升性能,增加可扩展性以及改善用户体验。

    2、升级界面,极大的简化了用户界面的操作和管理。

    3、提供新的安装包,让部署更加简单

    4、增加对Docker、NeGet、npm、Bower的支持。

    5、提供新的管理接口,以及增强对自动任务的管理

    二、部署Nexus

    官方教程文档:https://hub.docker.com/r/sonatype/nexus3

    部署命令如下:

    #拉取镜像
    docker pull sonatype/nexus3

    #cd local目录下,并创建docker,在docker目录下创建nexus
    cd /usr/local/
    mkdir docker
    mkdir nexus

    #编辑docker-compose.yml
    vi docker-compose.yml
    #启动
    docker-compose up -d

    docker-compose.yml配置文件内容如下:

    version: '3.1'
    services:
      nexus:
        restart: always
        image: sonatype/nexus3
        container_name: nexus
        ports:
          - 8082:8081
        volumes:
          - nexus-data:/nexus-data
    volumes:
      nexus-data:

    三、访问Nexus

    四、Nexus配置和使用

    官方文档:https://help.sonatype.com/repomanager3/formats/maven-repositories#MavenRepositories-ConfiguringGradle

    mvn仓库配置:

    <distributionManagement>
            <repository>
                <id>nexus-releases</id>
                <name>Nexus Releases Repository</name>
                <url>http://192.168.121.131:8082/repository/maven-releases/</url>
            </repository>
            <snapshotRepository>
                <id>nexus-snapshots</id>
                <name>Nexus Snapshot Repository</name>
                <url>http://192.168.121.131:8082/repository/maven-snapshots/</url>
            </snapshotRepository>
        </distributionManagement>
        <repositories>
            <repository>
                <id>nexus</id>
                <name>Nexus Repository</name>
                <url>http://192.168.121.131:8082/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>nexus</id>
                <name>Nexus Plugin Repository</name>
                <url>http://192.168.121.131:8082/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>

    maven setting认证配置:(只需要配置账号密码,请求地址是在pom里面)

    <server>
          <id>nexus-releases</id>
          <username>admin</username>
          <password>admin123</password>
    </server>
    <server>
          <id>nexus-snapshots</id>
          <username>admin</username>
          <password>admin123</password>
     </server>

     上传命令:

    mvn deploy -Dmaven.test.skip=true

    五、遇到问题

    1、提示没有文件夹权限

    2、账号密码错误,不是默认admin123

    (1)通过docker ps命令获取容器id,

    (2)docker exec -it 容器ID  /bin/bash 命令进入容器

    (3)vi /nexus-data/admin.password 查看密码(就是密码不是加密串)

    3、打包上传mvn时,出现异常

     分析问题:

    1、防火墙导致访问失败

    通过telnet,可以排除

    2、认证出现异常

    查看账号的ID是否跟仓库的ID一致

    解决方式:maven setting中的账号ID和pom文件中的ID不一致导致的,修改后成功运行

    MAVEN-central  中央仓库(没有会去官网仓库获取包)
    MAVEN-Public  公共仓库 组(包含其他仓库)

    MAVEN-RELEASES  发行

    MAVEN-SNAPSHOTS  快照(开发版)

    面向修改关闭,面向扩展开发

    语义化版本 V1.0.0(架构、功能、bug数)外部版本号

  • 相关阅读:
    基于Asp.Net webApi owin oauth2的实现
    动态赋值
    C#生成二维码
    深度学习中反卷积层(转置卷积)引起的棋盘格噪声
    batch normalization 批归一化 --- 一个硬币的两面
    FFMPEG常用命令-格式转换-持续更新中
    [译]CRF和QP的区别
    读懂NCHW和NHWC
    [译]GPUView
    有一次接口设计
  • 原文地址:https://www.cnblogs.com/myLeisureTime/p/13494565.html
Copyright © 2011-2022 走看看