• sonatype nexus3 install linux


    第一:下载

    提供一个版本的下载

    `wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz`
    

    第二:安装

    1. 检查java环境

      • 要求jdk8,一般linux自带open-jdk,本人不喜欢,如果有多个jdk,需要在bin/nexus脚本里面指定jdk

        INSTALL4J_JAVA_HOME_OVERRIDE=/opt/jdk8.12.2

      • jvm修改内存

        内存如何配置多少合适,自己参照官方文档吧
        'https://help.sonatype.com/repomanager3/installation/configuring-the-runtime-environment'

        修改位置:$install-dir/nexus-3.22.1-02/bin/nexus.vmoptions

          -Xms256m
          -Xmx256m
          -XX:MaxDirectMemorySize=2703m
          -XX:+UnlockDiagnosticVMOptions
          -XX:+LogVMOutput
          -XX:LogFile=../sonatype-work/nexus3/log/jvm.log
          -XX:-OmitStackTraceInFastThrow
          -Djava.net.preferIPv4Stack=true
          -Dkaraf.home=.
          -Dkaraf.base=.
          -Dkaraf.etc=etc/karaf
          -Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
          -Dkaraf.data=../sonatype-work/nexus3
          -Dkaraf.log=../sonatype-work/nexus3/log
          -Djava.io.tmpdir=../sonatype-work/nexus3/tmp
          -Dkaraf.startLocalConsole=false
          -Djava.endorsed.dir=lib/endorsed
        
    2. 安装

      这里介绍使用压缩包的方式,直接解压即可;还可以使用docker,有时间再弄

      tar -zvxf ./nexus-3.22.1-02-unix.tar.gz

    第三:运行

    1. 端口

      默认端口:8081

      修改位置: $install-dir/nexus-3.22.1-02/etc/nexus-default.properties

    2. 运行

      通常到这里就可以启动成功了,可能会出现的错误,内存不够的问题

      bin/nexus run

    3. 以服务的方式运行

      • 创建nexus用户

        adduser nexus
        chown -R nexus:nexus $install-dir/nexus-3.22.1-02/
        chown -R nexus:nexus $install-dir/sonatype-work/

      • 修改启动用户

        修改位置:$install-dir/nexus-3.22.1-02/bin/nexus.rc

        内容:run_as_user="nexus"

      • /etc/systemd/system/创建nexus.service文件,写入以下内容

        路径注意修改

          [Unit]
          Description=nexus service
          After=syslog.target network.target
            
          [Service]
          Type=forking
          LimitNOFILE=65536
          ExecStart=/opt/nexusDir/nexus-3.22.1-02/bin/nexus start
          ExecStop=/opt/nexusDir/nexus-3.22.1-02/bin/nexus stop
          User=nexus
          Group=nexus
          Restart=on-abort
            
          [Install]
          WantedBy=multi-user.target
        
      • 激活配置并启动

        补充日志文件查看:tail -f $install-dir/sonatype-work/nexus3/log/nexus.log

        作为服务运行时,一般会在/tmp/i4jdaemon_*文件中写入pid信息,如果pid文件没有被写入,启动会失败而且没有日志提醒, 需要自己创建并配置

        修改位置:$install-dir/nexus-3.22.1-02/bin/nexus.vmoptions
        -Dinstall4j.pidDir=somefile 注意nexus用户文件权限

          #Reload systemctl
          sudo systemctl daemon-reload
        
          #激活该服务,回开机自动启动的,不想开机启动的话,systemctl disable nexus.service
          #补充:查看开机启动的服务 systemctl list-unit-files | grep enable
          sudo systemctl enable nexus.service
        
          sudo systemctl start nexus.service
        
    4. 访问

      ip:port即可
      默认账户amdin,默认密码位置:$install-dir/sonatype-work/nexus3/admin.password

    第四:使用

    相对比较简单,大概描述一下

    1. 创建自己的查看

      • 创建库文件存贮位置Blob stores
      • 创建host库,并选择存储位置
      • 创建proxy库-可配置阿里云或别的镜像仓库
      • 创建一个组groupPublic-加入host-proxy
    2. 配置maven-setting文件

       #访问私服用户和密码
       <server>
         <id>nexus</id>
         <username>admin</username>
         <password>*****</password>
       </server>
       #配置镜像-加入group
       <mirror>
         <id>nexus</id>
         <mirrorOf>*</mirrorOf>
         <name>Human Readable Name for this Mirror.</name>
         <url>http://localhost:8081/repository/groupPublic/</url>
       </mirror>
      

    第五:补充-上传第三方jar到nexus中

    看官方文档,也踩了不少坑,在此提供两种命令的方式批量导入,单个包也可以在用户界面自己上传;由于本人的linux服务器存储空间不够,生产jar包使用window做的实验

    1. 方式一:

       #类似于maven手动导包到本地仓库的命令
       # 注意:http://localhost:8081/service/rest/v1/components?repository=localItemOne-release
       #这个是别人的api,我们修改的地方就是自己的库名localItemOne-release
       curl -v -u admin:123456 -F "maven2.generate-pom=true" -F "maven2.groupId=com.talkweb.alipay" -F "maven2.artifactId=commons-codec" -F "maven2.packaging=jar" -F "version=1.6" -F "maven2.asset1=@E:/hytWork/code/jar/com.talkweb.alipay-commons-codec-1.6.jar;" -F "maven2.asset1.extension=jar" "http://localhost:8081/service/rest/v1/components?repository=localItemOne-release" 
      
       curl -v -u admin:123456 -F "maven2.generate-pom=true" -F "maven2.groupId=com.talkweb.alipay" -F "maven2.artifactId=jaxen" -F "maven2.packaging=jar" -F "version=1.1" -F "maven2.asset1=@E:/hytWork/code/jar/jaxen-1.1.jar;type=application/java-archive" -F "maven2.asset1.extension=jar" "http://localhost:8081/service/rest/v1/components?repository=localItemOne-release"
      
    2. 方式二:

       #一pom的方式
       #注意:pom中只有maven的依赖信息,不要头尾,否则会解析失败
       #多个文件放一个pom中,总是只执行一个,试验多次,只好指定多个pom文件
       curl -v -u admin:123456 -F "maven2.generate-pom=false" -F "maven2.asset1=@E:/localService/pom.xml" -F "maven2.asset1.extension=pom" -F "maven2.asset2=@E:/hytWork/code/jar/core-3.0.0.jar;type=application/java-archive" -F "maven2.asset2.extension=jar" "http://localhost:8081/service/rest/v1/components?repository=localItemOne-release"
  • 相关阅读:
    [模板] 循环数组的最大子段和
    [最短路][几何][牛客] [国庆集训派对1]-L-New Game
    [洛谷] P1866 编号
    1115 Counting Nodes in a BST (30 分)
    1106 Lowest Price in Supply Chain (25 分)
    1094 The Largest Generation (25 分)
    1090 Highest Price in Supply Chain (25 分)
    树的遍历
    1086 Tree Traversals Again (25 分)
    1079 Total Sales of Supply Chain (25 分 树
  • 原文地址:https://www.cnblogs.com/laoyin666/p/12744078.html
Copyright © 2020-2023  润新知