1. 程式人生 > >maven私服 nexus-3.14.0-04在CentOS7搭建

maven私服 nexus-3.14.0-04在CentOS7搭建

Nexus介紹:
    Nexus 是Maven倉庫管理器,如果你使用Maven,你可以從Maven中央倉庫 下載所需要的構件(artifact),
    但這通常不是一個好的做法,你應該在本地架設一個Maven倉庫伺服器,在代理遠端倉庫的同時維護本地倉庫,
    以節省頻寬和時間,Nexus就可以滿足這樣的需要。此外,他還提供了強大的倉庫管理功能,構件搜尋功能,
    它基於REST,友好的UI是一個extjs的REST客戶端,它佔用較少的記憶體,基於簡單檔案系統而非資料庫。
    這些優點使其日趨成為最流行的Maven倉庫管理器。
Nexus下載:
    下載地址:http://www.sonatype.org/nexus/,https://www.sonatype.com/download-oss-sonatype
    下載開源版本
NEXUS OSS [OSS = Open Source Software,開源軟體——免費]
NEXUS PROFESSIONAL -FREE TRIAL [專業版本——收費]。
Nexus安裝:
   1、建立使用者、資料夾並修改資料夾所屬使用者:
      useradd nexus
      mkdir /opt/nexus
      chown -R nexus:nexus /opt/nexus/
   2、解壓檔案:
    將nexus-3.14.0-04-unix.tar.gz複製到linux中,解壓
    tar -zxf nexus-3.14.0-04-unix.tar.gz
   3、修改配置:
    ./nexus-3.14.0-04/bin/nexus
      #去掉註釋,配置java_home路徑
      INSTALL4J_JAVA_HOME_OVERRIDE=/opt/jdk1.8.0_171
    ./nexus-3.14.0-04/bin/nexus.rc
      run_as_user="用來啟動nexus的使用者"
    ./nexus-3.14.0-04/bin/nexus.vmoptions配置檔案修改nexus引數
      -XX:MaxDirectMemorySize=1G #修改記憶體大小
   4、啟動nexus:
      ./nexus-3.14.0-04/bin/nexus start
   5、製作系統服務:
      cd /etc/systemd/systemd/
      vi nexus.service
      #新增一下內容
      [Unit]
      Description=Nexus server
      After=network.target remote-fs.target nss-lookup.target
      
      [Service]
      User=nexus
      Group=nexus
      Type=forking
      LimitNOFILE=65536
      ExecStart=/opt/nexus/nexus-3.14.0-04/bin/nexus start
      ExecReload=/opt/nexus/nexus-3.14.0-04/bin/nexus restart
      ExecStop=/opt/nexus/nexus-3.14.0-04/bin/nexus stop
      PrivateTmp=true
      
      [Install]
      WantedBy=multi-user.target
      
      給nesux.service檔案賦予執行許可權
      chmod +x nexus.service
      使用系統服務操作nexus,進行啟動
      systemctl start nexus.service出現錯誤:
        Jobfornexus.service failed because the control process exited with error code. See"systemctl status nexus.service"and"journalctl -xe"fordetails.
      提示找不到JVM,上文配置的INSTALL4J_JAVA_HOME_OVERRIDE在服務啟動模式下不啟作用,暫不清楚原因。
      檢視./nexus-3.14.0-04/bin/nexus從common_jvm_locations中查詢jvm,可以看到是從/usr/local下查詢的java,因為jvm沒有安裝在/usr/local下,所以找不到jvm;建立一個link到/usr/local下:
      ln -s /opt/jdk1.8.0_171 /usr/local/java
      再次使用系統服務systemctl啟動nexus就ok了

注意:nexus3和nexus2有很大不同,在nexus3私服倉庫中找不到jar包位置,只有一個個的byte檔案。

位置:./nexus3/blobs/default/content/...