1. 程式人生 > >centos 安裝私服 nexus3

centos 安裝私服 nexus3

1、下載nexus

http://www.sonatype.org/nexus/downloads/

 說明:
[OSS = Open Source Software,開源軟體 – 免費]
[FREE TRIAL,專業版本 – 收費]

 

2、Centos下安裝Nexus

安裝JDK,此處略,檢查自己虛擬機器上的JDK版本如下:

使用xftp將nexus上傳到:/home/wangyong/nexus

2.1、首先解壓下載到的檔案:tar

[[email protected] nexus]# tar -zxvf nexus-3.14.0-04-unix.tar.gz

2.2、編輯環境變數

[[email protected]  software]# vi /etc/profile

新增Nexus的路徑,一定要注意路徑不能錯

 

修改完成之後,最後執行下面的命令:使環境變數生效

[[email protected]  bin]# source /etc/profile

修改nexus-3.6.0-02下的bin/nexus.rc檔案

[[email protected]  bin]# vim nexus.rc
  • 1

設定啟動該服務的使用者,Nexus不推薦使用root,這裡暫時設定為root

run_as_user="root"

2.3、設定nexus使用的jdk

啟動nexus服務時出現 Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.錯誤時,表示nexus所使用的jdk無效

需要設定nexus的java_home

編輯nexus啟動引數

# vi /home/wangyong/nexus/nexus-3.14.0-04/bin/nexus

2.4、新增系統啟動項:(待驗證)

# cp /home/wangyong/nexus/nexus-3.14.0-04/bin/nexus /etc/init.d/nexus

2.5、開啟遠端訪問埠

[[email protected]  bin]# firewall-cmd --zone=public --add-port=8081/tcp --permanent
[[email protected] bin]# firewall-cmd --reload

2.6 修改 NEXUS3 資料以及相關日誌的儲存位置 (可選):

1
2
[[email protected] bin]# cd /usr/local/nexus-3.6.0-02/bin/
[[email protected] bin]# vim nexus.vmoptions
1
2
3
-XX:LogFile=./sonatype-work/nexus3/log/jvm.log
-Dkaraf.data=./sonatype-work/nexus3
-Djava.io.tmpdir=./sonatype-work/nexus3/tmp

3、設定開機自啟動

    建立服務

[[email protected]  ~]# vim /usr/lib/systemd/system/nexus.service

 填入相關內容

[Unit]                                                 
Description=nexus service

[Service]
Type=forking
LimitNOFILE=65536 #警告處理
ExecStart=/home/wangyong/nexus/nexus-3.14.0-04/bin/nexus start
ExecReload=/home/wangyong/nexus/nexus-3.14.0-04/bin/nexus restart
ExecStop=/home/wangyong/nexus/nexus-3.14.0-04/bin/nexus stop
Restart=on-failure


[Install]
WantedBy=multi-user.target

#重新載入服務

sudo systemctl daemon-reload 

#開啟開機自啟動服務

sudo systemctl enable nexus.service

 

#啟動服務 

sudo systemctl start nexus.service

3.2、修改nexus3預設埠(可選)

[[email protected]  etc]# cd /usr/local/nexus-3.6.0-02/etc/
[[email protected]  etc]# vim nexus-default.properties 
application-port=8081

3.3、 修改nexus3資料以及相關日誌的儲存位置(可選)

[[email protected] bin]# cd /usr/local/nexus-3.6.0-02/bin/
[[email protected]  bin]# vim nexus.vmoptions 
-XX:LogFile=./sonatype-work/nexus3/log/jvm.log
-Dkaraf.data=./sonatype-work/nexus3
-Djava.io.tmpdir=./sonatype-work/nexus3/tmp

3.4、 配置本地maven的setting.xml檔案

<mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://192.168.1.11:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>

 

預設埠是8081
預設使用者名稱是admin,密碼admin123
修改埠在:/home/tuzq/software/nexus-3.6.0-02/etc/nexus-default.properties

在瀏覽器中訪問:http://192.168.106.100:8081/