1.编写开机启动文件
vim /lib/systemd/system/nacos.service
[Unit]
Description=nacos
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nacos/bin/startup.sh -m standalone
ExecReload=/usr/local/nacos/bin/shutdown.sh
ExecStop=/usr/local/nacos/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
2.修改nacos的startup.sh
- 修改JAVA_HOME路径并注销之后的3行配置,如下:
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/local/jdk1.8.0_191
3.设置开机启动
systemctl daemon-reload
systemctl enable nacos.service
systemctl start nacos.service
systemctl stop nacos.service
systemctl status nacos.service