Ubuntu 将Nacos添加为Service

1、创建service文件

        在/lib/systemd/system目录下创建nacos.service文件

[Unit]
Description=alibaba nacos
After=network.target
Documentation=https://nacos.io/zh-cn/

[Service]
User=root
Group=root
Type=forking
Environment="JAVA_HOME=/usr/local/programs/jdk-8u333-linux-x64/jdk1.8.0_333"
ExecStart=/bin/bash /usr/local/programs/nacos/bin/startup.sh -m standalone
ExecStop=/bin/bash /usr/local/programs/nacos/bin/shutdown.sh
Restart=on-failure
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Alias=nacos.service
 2. 启动服务并检查状态
$ systemctl daemon-reload
$ systemctl start nacos
$ systemctl status nacos
$ systemctl restart nacos

3. 开机自启动

$ systemctl enable nacos

你可能感兴趣的:(Ubuntu20,ubuntu,linux,运维)