安装Sonatype Nexus 2即服务

Lor*_*ate 1 linux debian redhat centos nexus

我想知道如何在GNU/Linux上安装Sonatype Nexus 2作为服务,以便正确配置并在启动时自动启动.

Lor*_*ate 5

创建具有足够访问权限的nexus用户来运行该服务

useradd nexus
Run Code Online (Sandbox Code Playgroud)

将$ NEXUS_HOME/bin/nexus复制到/etc/init.d/nexus使/etc/init.d/nexus脚本可执行并由root用户拥有:

chmod 755 /etc/init.d/nexus
chown root /etc/init.d/nexus
Run Code Online (Sandbox Code Playgroud)

编辑此脚本更改以下变量:

  • 将NEXUS_HOME更改为绝对文件夹位置(例如,NEXUS_HOME ="/ usr/local/nexus")
  • 将RUN_AS_USER设置为nexus或您要用于运行服务的具有受限权限的任何其他用户.您不应该以root身份运行存储库管理器.
  • 将PIDDIR更改为此用户具有读/写权限的目录(例如,PIDDIR ="/ home/nexus /").如果它不存在则创建它.

- 将存储库管理器使用的目录的所有者和组(包括在nexus.properties中配置的nexus-work默认为sonatype-work/nexus)更改为将运行该应用程序的nexus用户.

chown nexus:nexus NEXUS_HOME -R
Run Code Online (Sandbox Code Playgroud)

- 如果Java不在运行存储库管理器的用户的默认路径上,请添加指向本地Java安装的JAVA_HOME变量,并将$ JAVA_HOME/bin添加到PATH.

在Red Hat,Fedora和CentOS上作为服务运行

此脚本具有相应的chkconfig指令,因此您需要做的就是添加存储库管理器作为服务运行以下命令:

cd /etc/init.d
chkconfig --add nexus
chkconfig --levels 345 nexus on
service nexus start
    Starting Nexus Repository Manager Pro...
tail -f NEXUS_HOME/logs/wrapper.log
Run Code Online (Sandbox Code Playgroud)

第二个命令将nexus添加为要使用service命令启动和停止的服务.chkconfig管理/etc/rc[0-6].d中的符号链接,它控制在操作系统重新启动或在运行级别之间转换时要启动和停止的服务.第三个命令将nexus添加到运行级别3,4和5. service命令启动存储库管理器,最后一个命令将wrapper.log用于验证它是否已成功启动.如果存储库管理器已成功启动,您应该会看到一条消息,通知您它正在侦听HTTP.

在Ubuntu和Debian上作为服务运行

在Ubuntu上将存储库管理器设置为服务的过程与Red Hat变体上使用的过程略有不同.在/etc/init.d中配置启动脚本后,应该运行以下命令序列,而不是运行chkconfig.

cd /etc/init.d
update-rc.d nexus defaults
service nexus start
    Starting Nexus Repository Manager Pro...
tail -f NEXUS_HOME/logs/wrapper.log
Run Code Online (Sandbox Code Playgroud)