Nexus oss 3.29.x安装如下
1,准备服务器资源
服务器:10.100.19.66
2,安装jdk环境,需要jdk1.8以上,并配置环境变量
3,安装nexus oss,安装免费版,pro版本是收费版本
下载地址:https://www.sonatype.com/nexus/repository-oss-download
上传到服务器并解压
tar -zxvf nexus-3.29.2-02.tar.gz /opt/local
4,修改配置文件nexus.rc,启动用户修改为nexus,不建议root启动
run_as_user="nexus"
5,创建nexus用户并设置密码
useradd nexus
passwd nexus
6,为nexus用户设置可执行权限
chmod a+x /opt/local/nexus-3.29.2-02/bin/nexus
7,通过命令启动nexus服务
cd /opt/local/nexus-3.29.2-02/bin
su nexus
./nexus run
run:可以看到控制台启动日志
start:后台启动
restart:重启服务
stop:停止服务
启动成功后看到如下日志
8,开放8081端口,端口占用可以修改/opt/local/nexus-3.29.2-02/etc/nexus-default.properties
firewall-cmd --zone=public --add-port=8081/tcp --permanent
#-permanent #永久生效,没有此参数重启后失效
#注:开启后需要重启防火墙才生效
firewall-cmd --reload
firewall-cmd --list-ports
开通端口后结果如下
9,将nexus设置为开机启动
// 进入/etc/init.d
cd /etc/init.d/
// 新建脚本文件nexus
vim nexus
脚本如下:
#!/bin/bash
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
export JAVA_HOME=/opt/local/jdk1.8.0_45
case $1 in
start) su nexus /opt/local/nexus-3.29.2-02/bin/nexus start;;
stop) su nexus /opt/local/nexus-3.29.2-02/bin/nexus stop;;
status) su nexus /opt/local/nexus-3.29.2-02/bin/nexus status;;
restart) su nexus /opt/local/nexus-3.29.2-02/bin/nexus restart;;
fore-reload) su nexus /opt/local/nexus-3.29.2-02/bin/nexus fore-reload;;
run) su root /opt/local/nexus-3.29.2-02/bin/nexus run;;
*) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
esac