maven nexus 私服搭建 Linux版

准备工作

已安装jdk

已安装maven

下载Nexus Repository OSS:https://www.sonatype.com/download-oss-sonatype

如果无法下载成功,可访问百度网盘:

Linux版链接:https://pan.baidu.com/s/1OYTfIfEuIQgD4QDH2d5LLA ,提取码:whwh

Windows版链接:https://pan.baidu.com/s/12yfQ4M5bk2G-v-2idLiumA,提取码:0hx5

验证JDK和MAVEN

java -version
mvn -v

解压Nexus安装包

cd /opt
mkdir nexus3
cd nexus3/
tar zxf /tmp/nexus-3.17.0-01-unix.tar.gz
ls
nexus-3.17.0-01  sonatype-work

查看运行端口和开放防火墙

vi /opt/nexus3/nexus-3.17.0-01/etc/nexus-default.properties 
## DO NOT EDIT
- CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties ## # Jetty section application-port=8081 默认的运行端口为8081,如果该端口已占用,可在此修改。 application-host=0.0.0.0 nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml nexus-context-path=/ # Nexus section nexus-edition=nexus-pro-edition nexus-features=\ nexus-pro-feature nexus.hazelcast.discovery.isEnabled=true
开放8081端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent
重启防火墙 firewall
-cmd --reload

作为服务运行

添加用户nexus(不推荐使用root用户启动nexus)
useradd nexus
修改nexus的运行用户
vi /opt/nexus3/nexus-3.17.0-01/bin/nexus.rc 
取消注释,并修改为如下内容
run_as_user="nexus"
修改nexus3文件的所有者
chown -R nexus:nexus /opt/nexus3/
在/etc/systemd/system/下创建nexus.service文件,并编辑为如下内容
vi /etc/systemd/system/nexus.service

[Unit]
Description=nexus service
After=network.target
  
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus3/nexus-3.17.0-01/bin/nexus start
ExecStop=/opt/nexus3/nexus-3.17.0-01/bin/nexus stop
User=nexus
Restart=on-abort
  
[Install]
WantedBy=multi-user.target
更新systemctl
sudo systemctl daemon-reload 设置开机启动 sudo systemctl enable nexus.service 启动nexus服务 sudo systemctl start nexus.service 查看nexus服务状态 sudo systemctl status nexus.service 查看日志 tail -f /opt/nexus3/sonatype-work/nexus3/log/nexus.log
在日志中最后看到如下内容表示启动成功

  -------------------------------------------------

  Started Sonatype Nexus OSS 3.17.0-01

  -------------------------------------------------

提示:

       如果不增加新用户,而是修改/opt/nexus3/nexus-3.17.0-01/bin/nexus.rc文件run_as_user="root",启动nexus服务时,会出现如下警告:

WARNING: ************************************************************ 
WARNING: Detected execution as "root" user.  This is NOT recommended! 
WARNING: ************************************************************ 

登录访问

通过浏览器访问http://ip:8081,可以看到nexus的欢迎页,表示启动成功

点击上图右上角的,,弹出登录对话框

可以看到admin初始密码是在/opt/nexus3/sonatype-work/nexus3/admin.password 文件中

查看登录对话框中告知的admin用户密码所在文件admin.password
cat
/opt/nexus3/sonatype-work/nexus3/admin.password
看到如下很长的字符串,该串即为admin用户初始登录密码,用该密码登录后,admin.password文件即会被自动删除 5846b85c
-07c9-4979-876a-3e68908cfe1c

点击登录后,弹出修改密码的提示,根据指示完成密码的修改。

启动、停止、查看运行状态命令

systemctl start nexus.service
systemctl stop nexus.service
systemctl status nexust.service

 

posted @ 2019-07-08 11:02  wztone  阅读(1215)  评论(0编辑  收藏  举报