vim /lib/systemd/system/nacos.service [Unit] Description=nacos After=network.target [Service] Type=forking ExecStart=/usr/local/nacos/distribution/target/nacos-server-2.0.4/nacos/bin/startup.sh -m standalone ExecReload=/usr/local/nacos/distribution/target/nacos-server-2.0.4/nacos/bin/shutdown.sh ExecStop=/usr/local/nacos/distribution/target/nacos-server-2.0.4/nacos/bin/shutdown.sh PrivateTmp=true [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable nacos.service
由于Nacos是基于java开发而成,在启动的时候需要JDK版本1.8,虽然在系统环境中已经配置了JAVA_HOME 但是在service脚本中,会从/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin这些路径中寻找javac 只需要将我们自己的java目录软链接到/usr/bin/java即可,否则可能会启动失败
which javac
ln -s /usr/local/jdk8u322-b06/bin/javac /usr/bin/javac
systemctl start nacos.service systemctl stop nacos.service
systemctl status nacos.service ![](https://www.www.weizhi.cc/i/l/?n=22&i=blog/2165133/202207/2165133-20220715092814844-869598789.png)