docker-compose安裝Nexus


一、Nexus

Nexus是一個強大的Maven倉庫管理器,它極大地簡化了自己內部倉庫的維護和外部倉庫的訪問。利用Nexus你可以只在一個地方就能夠完全控制訪問 和部署在你所維護倉庫中的每個Artifact。Nexus是一套“開箱即用”的系統不需要數據庫,它使用文件系統加Lucene來組織數據。Nexus 使用ExtJS來開發界面,利用Restlet來提供完整的REST APIs,通過m2eclipse與Eclipse集成使用。Nexus支持WebDAV與LDAP安全身份認證。

Nexus官網

二、部署規划

服務器IP 192.168.113.48
端口 8931
安裝目錄 /home/work/docker-nexus
數據映射目錄 /home/work/docker-nexus/data

三、安裝Nexus

  • 創建安裝目錄,進入到安裝目錄中編輯並保存docker-compose.yml文件

    vim docker-compose.yml
    
    version: '3'
    services:
      nexus:
        image: 'sonatype/nexus3'
        container_name: nexus
        restart: always
        environment:
          - TZ=Asia/Shanghai
        ports:
          - '8931:8081'
        volumes:
          - '/home/work/docker-nexus/data:/nexus-data'
    
  • 在安裝目錄下啟動服務

    [root@node03 docker-nexus]# docker-compose up -d
    Creating network "docker-nexus_default" with the default driver
    Creating nexus ... done
    [root@node03 docker-nexus]# docker-compose logs -f
    Attaching to nexus
    nexus    | mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied
    nexus    | mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied
    nexus    | OpenJDK 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to No such file or directory
    nexus    | 
    nexus    | Warning:  Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
    nexus    | Warning:  Forcing option -XX:LogFile=/tmp/jvm.log
    nexus    | java.io.FileNotFoundException: ../sonatype-work/nexus3/tmp/i4j_ZTDnGON8hezynsMX2ZCYAVDtQog=.lock (No such file or directory)
    nexus    | 	at java.io.RandomAccessFile.open0(Native Method)
    nexus    | 	at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
    nexus    | 	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
    nexus    | 	at com.install4j.runtime.launcher.util.SingleInstance.check(SingleInstance.java:72)
    nexus    | 	at com.install4j.runtime.launcher.util.SingleInstance.checkForCurrentLauncher(SingleInstance.java:31)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.checkSingleInstance(UnixLauncher.java:88)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:67)
    nexus    | java.io.FileNotFoundException: /nexus-data/karaf.pid (Permission denied)
    nexus    | 	at java.io.FileOutputStream.open0(Native Method)
    nexus    | 	at java.io.FileOutputStream.open(FileOutputStream.java:270)
    nexus    | 	at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    nexus    | 	at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
    nexus    | 	at org.apache.karaf.main.InstanceHelper.writePid(InstanceHelper.java:127)
    nexus    | 	at org.apache.karaf.main.Main.launch(Main.java:243)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.launch(NexusMain.java:113)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.main(NexusMain.java:52)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    nexus    | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    nexus    | 	at java.lang.reflect.Method.invoke(Method.java:498)
    nexus    | 	at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:85)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:69)
    nexus    | java.lang.RuntimeException: /nexus-data/log/karaf.log (No such file or directory)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java:102)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlersInternal(BootstrapLogManager.java:137)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlers(BootstrapLogManager.java:70)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.configureLogger(BootstrapLogManager.java:75)
    nexus    | 	at org.apache.karaf.main.Main.launch(Main.java:244)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.launch(NexusMain.java:113)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.main(NexusMain.java:52)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    nexus    | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    nexus    | 	at java.lang.reflect.Method.invoke(Method.java:498)
    nexus    | 	at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:85)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:69)
    nexus    | Caused by: java.io.FileNotFoundException: /nexus-data/log/karaf.log (No such file or directory)
    nexus    | 	at java.io.FileOutputStream.open0(Native Method)
    nexus    | 	at java.io.FileOutputStream.open(FileOutputStream.java:270)
    nexus    | 	at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.open(BootstrapLogManager.java:193)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.<init>(BootstrapLogManager.java:182)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java:100)
    nexus    | 	... 12 more
    nexus    | Error creating bundle cache.
    nexus    | Unable to update instance pid: Unable to create directory /nexus-data/instances
    nexus    | mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied
    nexus    | mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied
    nexus    | OpenJDK 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to No such file or directory
    nexus    | 
    nexus    | Warning:  Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
    nexus    | Warning:  Forcing option -XX:LogFile=/tmp/jvm.log
    nexus    | java.io.FileNotFoundException: ../sonatype-work/nexus3/tmp/i4j_ZTDnGON8hezynsMX2ZCYAVDtQog=.lock (No such file or directory)
    nexus    | 	at java.io.RandomAccessFile.open0(Native Method)
    nexus    | 	at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
    nexus    | 	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
    nexus    | 	at com.install4j.runtime.launcher.util.SingleInstance.check(SingleInstance.java:72)
    nexus    | 	at com.install4j.runtime.launcher.util.SingleInstance.checkForCurrentLauncher(SingleInstance.java:31)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.checkSingleInstance(UnixLauncher.java:88)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:67)
    nexus    | java.io.FileNotFoundException: /nexus-data/karaf.pid (Permission denied)
    nexus    | 	at java.io.FileOutputStream.open0(Native Method)
    nexus    | 	at java.io.FileOutputStream.open(FileOutputStream.java:270)
    nexus    | 	at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    nexus    | 	at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
    nexus    | 	at org.apache.karaf.main.InstanceHelper.writePid(InstanceHelper.java:127)
    nexus    | 	at org.apache.karaf.main.Main.launch(Main.java:243)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.launch(NexusMain.java:113)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.main(NexusMain.java:52)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    nexus    | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    nexus    | 	at java.lang.reflect.Method.invoke(Method.java:498)
    nexus    | 	at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:85)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:69)
    nexus    | java.lang.RuntimeException: /nexus-data/log/karaf.log (No such file or directory)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java:102)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlersInternal(BootstrapLogManager.java:137)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlers(BootstrapLogManager.java:70)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.configureLogger(BootstrapLogManager.java:75)
    nexus    | 	at org.apache.karaf.main.Main.launch(Main.java:244)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.launch(NexusMain.java:113)
    nexus    | 	at org.sonatype.nexus.karaf.NexusMain.main(NexusMain.java:52)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    nexus    | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    nexus    | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    nexus    | 	at java.lang.reflect.Method.invoke(Method.java:498)
    nexus    | 	at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:85)
    nexus    | 	at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:69)
    nexus    | Caused by: java.io.FileNotFoundException: /nexus-data/log/karaf.log (No such file or directory)
    nexus    | 	at java.io.FileOutputStream.open0(Native Method)
    nexus    | 	at java.io.FileOutputStream.open(FileOutputStream.java:270)
    nexus    | 	at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.open(BootstrapLogManager.java:193)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.<init>(BootstrapLogManager.java:182)
    nexus    | 	at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java:100)
    nexus    | 	... 12 more
    nexus    | Error creating bundle cache.
    nexus    | Unable to update instance pid: Unable to create directory /nexus-data/instances
    
  • 啟動后查看日志,發現提示權限不足,為數據映射目錄加上權限即可

    [root@node03 docker-nexus]# chmod 777 /home/work/docker-nexus/data/
    You have new mail in /var/spool/mail/root
    [root@node03 docker-nexus]# docker-compose ps
    Name               Command               State           Ports         
    -----------------------------------------------------------------------
    nexus   sh -c ${SONATYPE_DIR}/star ...   Up      0.0.0.0:8931->8081/tcp
    

四、驗證Nexus

  • 在瀏覽器中輸入IP:端口,點擊頁面右上角登錄,根據頁面提示查找到初始密碼,然后將初始密碼復制

    若輸入ip:端口后,瀏覽器無法訪問頁面,可以稍等一會,查看日志確保nexus啟動完成后再訪問

    [root@node03 docker-nexus]# cat data/admin.password 
    b05c1771-6be1-4cb2-9b4e-5cffb610099d
    

    BuV6Df.png

  • 登錄后會有一個彈窗,要求給admin用戶重新設置一個新的密碼,請記住這個設置的密碼(本次安裝設置的密碼為admin_qazwsx

    BuVcb8.png

  • 點擊"next",彈窗提示是否允許匿名用戶訪問,根據自己需求選擇即可,本次安裝選擇"開啟匿名訪問"

    BuV2VS.png

  • Nexus安裝成功,再根據需求進行相關配置即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM