nexus搭建maven私有仓库教程(linux)

nexus3.x 搭建
说明:最新版本依赖jdk1.8+

软件下载

进入官网下载nexus最新版本,https://www.sonatype.com/download-oss-sonatype
或者直接下载最新版本 https://sonatype-download.global.ssl.fastly.net/nexus/3/latest-unix.tar.gz

软件安装

准备工作 :

  • 把下载好的软件拷贝到 /opt/install 目录中
  • 查看jdk版本是否最小1.8

安装步骤

  1. 创建安装目录
    1
    2
    mkdir /opt/software
    mkdir /opt/software/nexus
  2. 解压nexus安装包
    1
    tar -zxvf /opt/install/nexus-3.6.0-02-unix.tar.gz /opt/software/nexus/
  3. 启动或关闭
    1
    2
    3
    4
    5
    6
    #进入启动目录
    cd /opt/software/nexus/nexus-3.6.0-02/bin
    #启动服务
    ./nexus start
    #关闭服务
    ./nexus stop

启动成功后,就可以通过访问nexus了:http://ip:8081
管理员默认账号:admin 默认密码:admin123

配置说明

端口修改

nexus 默认端口为8081,可以找到以下文件修改
文件:/opt/software/nexus/nexus-3.6.0-02/etc/nexus-default.properties
编辑 application-port

1
2
3
4
5
6
7
8
9
10
11
12
13
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
nexus-pro-feature

java虚拟机配置

nexus 默认java虚拟机配置2g内存,可以根据实际情况修改
文件:/opt/software/nexus/nexus-3.6.0-02/bin/nexus.vmoptions

-Xms512M
-Xmx512M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false