「Nexus」- 安装 @20210312

本文详细介绍如何在CentOS 7环境下部署Nexus 3版本3.16.2,包括配置Java运行环境、下载及解压安装包、启动与访问服务等步骤,并提供了以服务方式运行Nexus的服务配置示例及Nginx反向代理配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境概述

操作系统:CentOS Linux release 7.5.1804 (Core)

软件版本:nexus-3.16.2-01-unix.tar.gz

系统要求

强烈建议阅读官方的「System Requirements」文档。

重点关注:专有账户;文件句柄数;内存;磁盘文件系统;

安装方法

# 安装Java运行环境

#!/bin/sh

yum install -y java-1.8.0-openjdk.x86_64

# 下载并解压安装包

#!/bin/sh

cd /opt/
wget http://download.sonatype.com/nexus/3/nexus-3.16.2-01-unix.tar.gz
tar -xf nexus-3.16.2-01-unix.tar.gz

# 解压后会生成两个目录:应用目录;数据目录;
# 有关各个目录的作用,参考:https://help.sonatype.com/repomanager3/installation/directories

# 启动并访问服务

#!/bin/sh

################################################################################
# 添加用户
# 通常是名为nexus的用户,并且必须可以创建一个可用的shell
################################################################################
useradd nexus

################################################################################
# 启动服务
################################################################################
bin/nexus run
# 当显示「Started Sonatype Nexus OSS」时,表示启动成功。

# 如果要停止服务,可以Ctrl+C来停止
# 也可以通过start, stop, restart, force-reload, status等命令来管理

################################################################################
# 访问服务
################################################################################
# 打开浏览器,默认监听的端口号是8081,即访问http://localhost:8081/即可。
# 默认的用户名:amdin;密码:admin123;

高级部分

# 以服务的方式运行

详细内容参考官方「Run as a Service」文档。下面是systemd的示例:

#!/bin/sh

cat > /etc/systemd/system/nexus.service <<EOF
[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/nexus/bin/nexus start
ExecStop=/opt/nexus/nexus/bin/nexus stop
User=nexus
Restart=on-abort

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable nexus.service
systemctl start nexus.service

# 使用Nginx反向代理

详细参考官方「Run Behind a Reverse Proxy」文档。下面是Nginx反向代理的示例:

http {

  proxy_send_timeout 120;
  proxy_read_timeout 300;
  proxy_buffering    off;
  keepalive_timeout  5 5;
  tcp_nodelay        on;

  server {
    listen   *:80;
    server_name  www.example.com;

    # allow large uploads of files
    client_max_body_size 1G;

    # optimize downloading files larger than 1G
    #proxy_max_temp_file_size 2G;

    location / {
      # Use IPv4 upstream address instead of DNS name to avoid attempts by nginx to use IPv6 DNS lookup
      proxy_pass http://127.0.0.1:8081/;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }
}

# 安装后的检查清单

Post Install Checklist

参考文献

System Requirements
Download Archives - Repository Manager 3
Accessing the User Interface

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值