Sonatype Nexus3安装配置及使用

1、简介

     Sonatype Nexus Repository Manager 是一款强大的仓库管理工具,用于存储、管理和发布软件组件。它能够支持多种格式的仓库,如 Maven、npm、Docker 等。在企业开发中,私有 Maven 仓库常用于存储自定义依赖和发布组件,确保代码安全性和内部共享。

      本文将从服务器环境搭建、Nexus 安装与配置、仓库创建、依赖上传,再到 Maven 项目中使用私有仓库的全过程,帮助你掌握如何高效管理 Maven 依赖。

2、环境准备与Nexus3安装

2.1、系统要求

  • 操作系统:Linux 或 Windows(推荐使用 Linux,如 CentOS、Ubuntu)
  • Java JDK:Nexus 需要 Java JDK 8 以上版本支持(推荐 JDK 11)。
  • 硬件需求:至少 4GB 内存,50GB 硬盘空间,取决于你要管理的包的数量。

2.2、Nexus3 安装步骤

2.2.1、下载 Nexus Repository Manager

前往 Sonatype Nexus 官网 下载最新版的 Nexus Repository Manager:

wget http://download.sonatype.com/nexus/3/latest-unix.tar.gz

或去 官网 下载安装包,然后再上传到服务器。

本次安装以 nexus-3.22.1-02-unix.tar.gz 为例。

如果通过wget和官网下载失败,可以去百度云下载,百度云链接: https://pan.baidu.com/s/1vIRkFG8G7_WSPwUNP60HmQ 提取码: nnhn

2.2.2、 安装与配置

解压安装包:

tar -zxvf nexus-3.22.1-02-unix.tar.gz

进入解压目录,启动 Nexus:

cd nexus-3.22.1-02

./bin/nexus start

#允许命令,可以打印启动日志
./bin/nexus run

设定 Nexus 为系统服务,以便服务器启动时自动启动:

ln -s /path/to/nexus-3.22.1-02/bin/nexus /etc/init.d/nexus

踩坑】启动报错

 Error occurred while executing a write operation to database 'OSystem' due to limited free space on the disk (233 MB). The database is now working in read-only mode. Please close the database (or stop OrientDB), make room on your hard drive and then reopen the database. The minimal required space is 4096 MB. Required space is now set to 4096MB (you can change it by setting parameter storage.diskCache.diskFreeSpaceLimit) .

解决方法:设置storage.diskCache.diskFreeSpaceLimit变量

根据提示信息可知:nexus要求最少有4096MB的磁盘空间,而当前磁盘只剩3188MB,我们可以通过设置{yourpath}/nexus/bin/nexus.vmoptions中的storage.diskCache.diskFreeSpaceLimit参数来指定剩余磁盘空间的容忍度。

你可能感兴趣的:(nexus)