Linux nexus 搭建私服和安装索引

1: Nexus 下载

Nexus 官方下载, 最新版下载: nexus-2.8.0-05-bundle.tar.gz

Nexus war下载: nexus-2.8.0-05.war


nexus有两种安装实现方式,一种是war包的方式,将它直接放在例如tomcat下就可以启用的,还有一种源码的方式,

要求JDK7以上


2: Nexus 安装

 解压tar.gz文件: 

#cd /opt/lzw/tools

#tar zxvf nexus-2.8.0-05-bundle.tar.gz

移动目录

#mv nexus-2.8.0-05 /opt/lzw/nexus


3: Nexus 启动

nexus启动是在bin目录下,首先看一下启动/关闭/重启等命令, 输入命令:

#cd /opt/lzw/nexus/bin

#./nexus

出现如下选项:

[root@localhost bin]# ./nexus

Usage: ./nexus { console | start | stop | restart | status | dump }

启动nexus:

#./nexus  start

关闭nexus: 

#./nexus  stop


4: 问题

问题:启动maven私服nexus时报错

[root@localhost bin]# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.


解决方法:修改vi nexus 的 RUN_AS_USER=root


启动nexus:

#./nexus  start


输入:http://218.10.56.29:8081/nexus/#welcome


Linux nexus 搭建私服和安装索引_第1张图片


5: 手动更新索引

访问http://repo.maven.apache.org/maven2/.index/下载中心仓库最新版本的索引文件,在一长串列表中,我们需要下载如下两个文件(一般在列表的末尾位置)

nexus-maven-repository-index.gz

nexus-maven-repository-index.properties

下载完成之后最好是通过md5或者sha1校验一下文件是否一致,因为服务器并不在国内,网络传输可能会造成文件损坏。

下面就是解压这个索引文件,虽然后缀名为gz,但解压方式却比较特别,我们需要下载一个jar包indexer-cli-5.1.1.jar,我们需要通过这个特殊的jar来解压这个索引文件

注:indexer-cli-5.1.1.jar是专门用来解析和发布索引的工具,关于它的详细信息请见这里。前往maven中央仓库下载indexer-cli-5.1.1.jar

将上面三个文件(.gz & .properties & .jar)放置到同一目录下,运行如下命令


java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer

定位到 F:\index下,执行解压命令之后,会在F:\index自动生成一个 indexer文件夹,大概十多分钟吧,cmd命令执行完毕,indexer文件大小会达到700M多点


Linux nexus 搭建私服和安装索引_第2张图片


然后indexer内的文件拷贝到私服{nexus-home}/sonatype-work/nexus/indexer/central-ctx目录下(先删除改目录下的东西),重新启动nexus,登陆查看,索引更新完毕!


Linux nexus 搭建私服和安装索引_第3张图片


你可能感兴趣的:(maven,环境搭建)