sonatype nexus3 install linux

First: download

Provide a download version

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

Second: install

  1. Check java environment

    • Requires jdk8, generally linux comes with open-jdk, I don't like it, if there are multiple jdk, you need to bin/nexusspecify jdk in the script

      INSTALL4J_JAVA_HOME_OVERRIDE=/opt/jdk8.12.2

    • jvm modify memory

      How to configure the memory is appropriate, please refer to the official documentation.
      ' Https://help.sonatype.com/repomanager3/installation/configuring-the-runtime-environment '

      Modify location:$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. installation

    Here is the way to use the compressed package, just decompress it directly; you can also use docker, and then get it when you have time

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

Third: run

  1. port

    Default port: 8081

    Modify location: $install-dir/nexus-3.22.1-02/etc/nexus-default.properties

  2. run

    Usually you can start successfully here, there may be errors, insufficient memory problems

    bin/nexus run

  3. Run as a service

    • Create a nexus user

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

    • Modify startup user

      Modify location:$install-dir/nexus-3.22.1-02/bin/nexus.rc

      content:run_as_user="nexus"

    • When /etc/systemd/system/creating the nexus.servicefile, write the following

      Attention to modify the path

        [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
      
    • Activate configuration and start

      Supplementary log file view:tail -f $install-dir/sonatype-work/nexus3/log/nexus.log

      When running as a service, the pid information is generally written in the / tmp / i4jdaemon_ * file.If the pid file is not written, the startup will fail and there is no log reminder.

      Modified location: $install-dir/nexus-3.22.1-02/bin/nexus.vmoptions
      -Dinstall4j.pidDir=somefilepay attention to the file permissions of the nexus user

        #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. access

    ip: port can be the
    default account amdin, the default password location:$install-dir/sonatype-work/nexus3/admin.password

Fourth: use

Relatively simple, roughly describe

  1. Create your own view

    • Create a library file storage location Blob stores
    • Create a host library and choose a storage location
    • Create proxy library-Configurable Alibaba Cloud or other mirror warehouse
    • Create a group groupPublic-join host-proxy
  2. Configure maven-setting file

     #访问私服用户和密码
     <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>
    

Fifth: supplement-upload third-party jar to nexus

Looking at the official documentation, I also stepped on a lot of pits. Here I provide two commands to import in batches. A single package can also be uploaded on the user interface; due to insufficient storage space on my linux server, the experiment of using jar to produce jar packages

  1. method one:

     #类似于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. Method 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"

Guess you like

Origin www.cnblogs.com/laoyin666/p/12744078.html