Nexus仓库简介及安装

1、Nexus仓库(Nexus Repository)
Nexus是Sonatype公司发布的一款仓库(Repository)管理软件,常用来搭建Maven私服,所以也有人将Nexus称为“Maven仓库管理器”。

官方文档地址:
Repository Manager 2
https://help.sonatype.com/repomanager2
Repository Manager 3
https://help.sonatype.com/repomanager3

Nexus3除了支持Java的Maven仓库外,还支持:

  • .Net的NuGet仓库(.NET Package Repositories with NuGet)
  • Python的Pipy仓库(PyPI Repositories)
  • Ruby的Gem仓库(Ruby, RubyGems and Gem Repositories)
  • Nodejs的npm仓库(Node Packaged Modules and npm Registries)
  • javascript的bower仓库(Bower Repositories)
  • docker的registry仓库(Docker Registry)
  • rpm包及yum源(RPM Packages and YUM Repositories)
  • 普通的文件仓库
    ...

Nexus3支持详细说明:
https://help.sonatype.com/repomanager3/nexus-repository-administration/formats

2、Repository Manager 2安装

Nexus2下载地址:
https://help.sonatype.com/repomanager2/download/download-archives---repository-manager-oss

2.1、Linux

(1)解压缩:
$ tar xvzf nexus-2.14.5-02-bundle.tar.gz

(2)进入目录:
cd /usr/local/nexus/bin

./nexus -h 查看命令参数
Usage: ./nexus { console | start | stop | restart | status | dump }

./nexus console 启动服务并显示输出日志

./nexus start 启动服务

(3)配置Nexus为服务:
https://help.sonatype.com/repomanager2/installing-and-running/configuring-nexus-repository-manager-as-a-service

测试地址:http://localhost:8081
账号/密码:admin/admin123

2.2、Windows系统

Java Service Wrapper (JSW)不同平台可执行目录如下:

$ cd /usr/local/nexus/bin/jsw
$ ls -1
conf
lib
license
linux-ppc-64
linux-x86-32
linux-x86-64
macosx-universal-32
macosx-universal-64
solaris-sparc-32
solaris-sparc-64
solaris-x86-32
windows-x86-32
windows-x86-64

3、Repository Manager 3安装

Nexus3下载地址:
https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

3.1、Linux

(1)解压缩:

$ tar xvzf nexus-2.14.5-02-bundle.tar.gz

(2)进入bin目录:

./nexus -h    查看nexus命令参数
./nexus run    前台启动
./nexus start    后台启动
./nexus stop    后台关闭

(3)注册服务:
https://help.sonatype.com/repomanager3/installation-and-upgrades/run-as-a-service

3.2、Windows系统

(1)解压缩工具解压;
(2)进入bin目录,查看nexus.exe命令参数:
bin>nexus.exe --help
Usage: nexus.exe /install | /uninstall | /stop | /start | /status | /run | /run-redirect

nexus.exe /install        注册nexus服务
nexus.exe /uninstall    卸载nexus服务
nexus.exe /status        查看nexus服务状态
nexus.exe /start        启动nexus服务
nexus.exe /stop            关闭nexus服务
nexus.exe /run            前台启动nexus,ctrl+c关闭

4、Docker安装

拉取镜像:
docker pull sonatype/nexus3

运行nexus容器
$ docker run -d -p 8081:8081 --name nexus sonatype/nexus3

关闭nexus容器(确保保留足够的时间以便数据库完全关闭)
docker stop --time=120 <CONTAINER_NAME>

浏览器访问地址测试:http://localhost:8081/

docker参考文档:
https://hub.docker.com/r/sonatype/nexus3/

(完)

最后修改于:2022年10月14日 19:48

添加新评论