环境概述
操作系统:CentOS Linux release 7.5.1804 (Core)
软件版本:nexus-3.16.2-01-unix.tar.gz
系统要求
强烈建议阅读官方的「System Requirements」文档。
重点关注:专有账户;文件句柄数;内存;磁盘文件系统;
安装方法
下载并解压安装包
### 安装Java运行环境 yum install -y java-1.8.0-openjdk.x86_64 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
启动并访问服务
# 添加用户 useradd nexus # 通常是名为nexus的用户,并且必须可以创建一个可用的shell # 启动服务 bin/nexus run # 当显示「Started Sonatype Nexus OSS」时,表示启动成功 # 如果要停止服务,可以Ctrl+C 停止 # 也可通过start, stop, restart, force-reload, status等命令来管理 # 访问服务 firefox http://localhost:8081/ # 默认账户:amdin / admin123
常用配置
通过 systemd 管理
详细内容参考官方「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; } } }
安装后的检查清单
参考文献
System Requirements
Download Archives – Repository Manager 3
Accessing the User Interface