maven私服安装配置

软件安装及基本配置

安装配置

# 安装jdk,参考其他教程
mkdir -p /app/nexus2
# 创建目录
wget https://download.sonatype.com/nexus/oss/nexus-2.14.8-01-bundle.tar.gz
# 解压
tar -zxvf nexus-2.14.8-01-bundle.tar.gz
# 修改配置, 在头部添加配置"export RUN_AS_USER=root"
vim /etc/profile
source /etc/profile
# 进入目录
cd /app/nexus2/nexus-2.14.8-01/bin
# 启动maven
./nexus start
# 浏览器访问http://172.16.48.129:8081/nexus/

配置文件夹以及路径

/app/nexus2/nexus-2.14.8-01/conf

日志文件夹以及路径

/app/nexus2/nexus-2.14.8-01/logs

软件索引配置

索引数据目录:sonatype-work/nexus/indexer

  1. nexus更新索引,设置中进行同步设定
  2. 手动更新索引

手动更新所需文件准备:

  1. nexus-maven-repository-index.gz
  2. nexus-maven-repository-index.properties
  1. indexer-cli-5.1.1.jar

更新索引:

# 安装jdk先决条件,后续需要使用java命令进行索引解压缩处理
# 进行这些操作的时候,最好停止nexus服务器,./nexus stop 防止出现异常情况
# 创建索引压缩包放置目录
mkdir -p /app/nexus/index
# 将文件上传到服务器在同一个目录下面
ll
# 运行结果
-rw-r--r-- 1 root root 6576184 11月 1 10:34 indexer-cli-5.1.1.jar
-rw-r--r-- 1 root root 578261578 11月 1 10:34 nexus-maven-repository-index.gz
-rw-r--r-- 1 root root 1130 11月 1 10:34 nexus-maven-repository-index.properties
# 解压缩索引文件,需要等待完成,中途中断,请删除生成文件夹重新执行命令
java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer
# 运行结果
Index Folder: /app/nexus/index
Output Folder: /app/nexus/index/indexer
Total time: 7 min 7 sec
Final memory: 77M/131M
# 将解压出来的/app/nexus/index/indexer的所有文件,拷贝到nexus工作目录中的indexer的/app/nexus/sonatype-work/nexus/indexer/central-ctx中央仓库的索引目录中
rm -rf /app/nexus/sonatype-work/nexus/indexer/central-ctx/*
cp -r /app/nexus/index/indexer/* /app/nexus/sonatype-work/nexus/indexer/central-ctx
# 启动nexus,./nexus start进入中央仓库,刷新所有即可,并且设置与中央仓库的同步

仓库迁移设置

Nexus的构件仓库都保存在sonatype-work目录中,该目录的位置由nexus/conf/nexus.properties配置文件指定。

仓库迁移需要两个过程:备份和还原

备份仓库:将sonatype-work文件夹整体备份即可,也可以选择只备份最重要的两个文件夹索引(indexer)和仓库(storage)

还原仓库:将备份好的sonatype-work文件拷贝到新的服务器中。然后修改nexus/conf/nexus.properties配置文件,重新指定仓库的目录。

Jar包搜索优化

将public仓库关联上所有的仓库,方便查找,如下图:

【运维技术】Nexus私服安装配置常用问题-LMLPHP

快照版本清理设定

添加任务:http://crabdave.iteye.com/blog/2358012

官方博客介绍:https://blog.sonatype.com/2009/09/nexus-scheduled-tasks/

参考资料:

设定开机启动:https://blog.csdn.net/zsg88/article/details/76099807

常用配置:https://blog.csdn.net/kinglyjn/article/details/53585721

04-14 18:37