将nexus设置成systemd服务,可以开机自启

本文介绍了如何在CentOS 7.6上将Nexus配置为systemd服务,以便系统重启后能自动启动。通过创建服务文件并设置开机自启,确保Nexus在服务器启动时运行。
摘要由CSDN通过智能技术生成

在使用nexus搭建了私服以后,经常会遇到服务器重启需要再手动启动nexus服务的情况,很不方便。于是搜集了将nexus设置成系统sytemd服务的方法,可以开机自启。

操作系统版本:CentOS Linux release 7.6.1810 (Core)

首先需要确认nexus的安装目录,这里使用的目录为/home/nexus/nexus-2.13.0-01,权限配置为nexus用户所有。
/usr/lib/systemd/system/目录下,创建nexus.service文件,文件内容如下:

[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
ExecStart=/home/nexus/nexus-2.13.0-01/bin/nexus start
ExecStop=
要将 Nexus3 配置为 systemd 服务,请按照以下步骤进行操作: 1. 编写 Nexus3 的 systemd 配置文件 `/etc/systemd/system/nexus.service`,内容如下: ``` [Unit] Description=Nexus3 Service After=network.target [Service] Type=forking LimitNOFILE=65536 ExecStart=/opt/nexus/bin/nexus start ExecStop=/opt/nexus/bin/nexus stop User=nexus Group=nexus Restart=on-abort [Install] WantedBy=multi-user.target ``` 请注意,您需要将 `ExecStart` 和 `ExecStop` 中的 `/opt/nexus` 替换为您实际的 Nexus3 安装位置。 2. 执行以下命令启动 Nexus3 服务并设置开机自启: ``` systemctl daemon-reload systemctl start nexus systemctl enable nexus ``` 3. 验证 Nexus3 是否已正常启动: ``` systemctl status nexus ``` 如果 Nexus3 正常运行,则该命令的输出应该类似于下面的内容: ``` ● nexus.service - Nexus3 Service Loaded: loaded (/etc/systemd/system/nexus.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-09-10 16:18:14 UTC; 2min 14s ago Process: 2363 ExecStop=/opt/nexus/bin/nexus stop (code=exited, status=0/SUCCESS) Process: 2370 ExecStart=/opt/nexus/bin/nexus start (code=exited, status=0/SUCCESS) Main PID: 2373 (java) Tasks: 79 (limit: 1074) CGroup: /system.slice/nexus.service └─2373 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Dinstall4j.jvmDir=/usr/lib/jvm/java-8-openjdk-amd64/jre -Dexe4j.moduleName=/opt/nexus/bin/nexus -Dexe4j... Sep 10 16:18:17 ubuntu1804 nexus[2370]: WrapperManager: Initializing... Sep 10 16:18:17 ubuntu1804 nexus[2370]: --> Wrapper Started as Daemon Sep 10 16:18:18 ubuntu1804 nexus[2370]: Java Service Wrapper Standard Edition 64-bit 3.5.43 Sep 10 16:18:18 ubuntu1804 nexus[2370]: Copyright (C) 1999-2016 Tanuki Software, Ltd. All Rights Reserved. Sep 10 16:18:18 ubuntu1804 nexus[2370]: http://wrapper.tanukisoftware.com Sep 10 16:18:18 ubuntu1804 nexus[2370]: Licensed to Sonatype Inc. for Nexus Repository Manager Sep 10 16:18:18 ubuntu1804 nexus[2370]: WrapperManager: JVM #1 Sep 10 16:18:18 ubuntu1804 nexus[2370]: Running a 64-bit JVM. Sep 10 16:18:18 ubuntu1804 nexus[2370]: WrapperManager: Registering shutdown hook ``` 这样,您就已经成功地将 Nexus3 配置为 systemd 服务了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值