1212
1313<!-- TOC depthFrom:2 depthTo:3 -->
1414
15- - [ 安装 Nexus] ( #安装-nexus )
16- - [ 启动/停止 Nexus] ( #启动停止-nexus )
17- - [ 使用 Nexus 搭建 Maven 私服] ( #使用-nexus-搭建-maven-私服 )
18- - [ 配置仓库] ( #配置仓库 )
19- - [ 配置 settings.xml] ( #配置-settingsxml )
20- - [ 配置 pom.xml] ( #配置-pomxml )
21- - [ 执行 maven 构建] ( #执行-maven-构建 )
22- - [ 将 Nexus 设置为服务] ( #将-nexus-设置为服务 )
23- - [ Nexus 备份和迁移] ( #nexus-备份和迁移 )
24- - [ 备份] ( #备份 )
25- - [ 迁移] ( #迁移 )
26- - [ 参考资料] ( #参考资料 )
15+ - [ 1. 安装 Nexus] ( #1-安装-nexus )
16+ - [ 2. 启动/停止 Nexus] ( #2-启动停止-nexus )
17+ - [ 3. 搭建 Maven 私服] ( #3-搭建-maven-私服 )
18+ - [ 3.1. 配置仓库] ( #31-配置仓库 )
19+ - [ 3.2. 配置 settings.xml] ( #32-配置-settingsxml )
20+ - [ 3.3. 配置 pom.xml] ( #33-配置-pomxml )
21+ - [ 3.4. 执行 maven 构建] ( #34-执行-maven-构建 )
22+ - [ 4. 开机自启动] ( #4-开机自启动 )
23+ - [ 5. Nexus 备份和迁移] ( #5-nexus-备份和迁移 )
24+ - [ 5.1. 备份] ( #51-备份 )
25+ - [ 5.2. 迁移] ( #52-迁移 )
26+ - [ 6. FAQ] ( #6-faq )
27+ - [ 6.1. 配置 INSTALL4J_JAVA_HOME] ( #61-配置-install4j_java_home )
28+ - [ 7. 参考资料] ( #7-参考资料 )
2729
2830<!-- /TOC -->
2931
30- ## 安装 Nexus
32+ ## 1. 安装 Nexus
3133
3234进入[ 官方下载地址] ( https://www.sonatype.com/download-oss-sonatype ) ,选择合适版本下载。
3335
@@ -47,7 +49,7 @@ tar -zxf nexus-unix.tar.gz
4749- nexus-3.13.0-01 - 包含了 Nexus 运行所需要的文件。是 Nexus 运行必须的。
4850- sonatype-work - 包含了 Nexus 生成的配置文件、日志文件、仓库文件等。当我们需要备份 Nexus 的时候默认备份此目录即可。
4951
50- ## 启动/停止 Nexus
52+ ## 2. 启动/停止 Nexus
5153
5254进入 nexus-3.13.0-01/bin 目录,有一个可执行脚本 nexus。
5355
@@ -68,9 +70,9 @@ Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload}
6870
6971点击右上角 Sign in 登录,默认用户名/密码为:admin/admin123。
7072
71- ## 使用 Nexus 搭建 Maven 私服
73+ ## 3. 搭建 Maven 私服
7274
73- ### 配置仓库
75+ ### 3.1. 配置仓库
7476
7577Nexus 中的仓库有以下类型:
7678
@@ -96,7 +98,7 @@ Nexus 中的仓库有以下类型:
9698
9799<div align =" center " ><img src =" http://dunwu.test.upcdn.net/snap/20181127203156.png!zp " /></div >
98100
99- ### 配置 settings.xml
101+ ### 3.2. 配置 settings.xml
100102
101103如果要使用 Nexus,还必须在 settings.xml 和 pom.xml 中配置认证信息。
102104
@@ -171,7 +173,7 @@ Nexus 中的仓库有以下类型:
171173</settings >
172174```
173175
174- ### 配置 pom.xml
176+ ### 3.3. 配置 pom.xml
175177
176178在 pom.xml 中添加如下配置:
177179
@@ -195,7 +197,7 @@ Nexus 中的仓库有以下类型:
195197> - ` <repository> ` 和 ` <snapshotRepository> ` 的 id 必须和 ` settings.xml ` 配置文件中的 ` <server> ` 标签中的 id 匹配。
196198> - ` <url> ` 标签的地址需要和 maven 私服的地址匹配。
197199
198- ### 执行 maven 构建
200+ ### 3.4. 执行 maven 构建
199201
200202如果要使用 settings.xml 中的私服配置,必须通过指定 ` -P zp ` 来激活 profile。
201203
@@ -209,9 +211,9 @@ $ mvn clean package -Dmaven.skip.test=true -P zp
209211$ mvn clean deploy -Dmaven.skip.test=true -P zp
210212```
211213
212- ## 将 Nexus 设置为服务
214+ ## 4. 开机自启动
213215
214- 将 Nexus 添加为服务 ,以便开机自启动。
216+ 将 Nexus 设置为 systemd 服务 ,以便开机自启动。
215217
216218在 ` /lib/systemd/system ` 目录下创建 ` nexus.service ` 文件,内容如下:
217219
@@ -242,7 +244,7 @@ WantedBy=multi-user.target
242244- ` systemctl stop nexus ` - 停止 nexus 服务
243245- ` systemctl restart nexus ` - 重启 nexus 服务
244246
245- ## Nexus 备份和迁移
247+ ## 5. Nexus 备份和迁移
246248
247249Nexus 三个重要目录:
248250
@@ -252,15 +254,27 @@ Nexus 三个重要目录:
252254| sonatype-work 目录 | sonatype-work | nexus/conf/nexus.xml 里面有 storage 的地址 |
253255| storage 目录 | storage | 里面主要是各种程序的 jar 包等 |
254256
255- ### 备份
257+ ### 5.1. 备份
256258
257259Nexus 的数据都存储在 sonatype-work 目录,备份 Nexus 数据只需要将其打包即可。
258260
259- ### 迁移
261+ ### 5.2. 迁移
260262
261263将原 Nexus 服务器中的 sonatype-work 目录迁移到新 Nexus 服务器的 sonatype-work 目录下。
262264
263- ## 参考资料
265+ ## 6. FAQ
266+
267+ ### 6.1. 配置 INSTALL4J_JAVA_HOME
268+
269+ 我在工作中遇到 nexus systemctl 服务无法自启动的问题,通过查看状态,发现以下报错:
270+
271+ ```
272+ Please define INSTALL4J_JAVA_HOME to point to a suitable JVM
273+ ```
274+
275+ 通过排查,找到原因:即使环境上已安装 JDK,且配置了 JAVA_HOME,但 nexus 仍然无法正确找到 JDK,需要在 ` /bin/nexus ` 中指定 ` INSTALL4J_JAVA_HOME_OVERRIDE=<JDK安装路径> `
276+
277+ ## 7. 参考资料
264278
265279- [ maven 私库 nexus3 安装及使用] ( https://blog.csdn.net/clj198606061111/article/details/52200928 )
266280- [ Nexus 安装 使用说明] ( https://www.cnblogs.com/jtlgb/p/7473837.html )
0 commit comments