Centos7 Neo4j开机自启动

1.启动关闭脚本

vi start.sh

#!/bin/bash

export JAVA_HOME=/opt/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH

sh /opt/neo4j-enterprise-3.5.3/bin/neo4j start

vi stop.sh

#!/bin/bash

export JAVA_HOME=/opt/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH

sh /opt/neo4j-enterprise-3.5.3/bin/neo4j stop

2.开机启动脚本服务neo4j.servic

cd /usr/lib/systemd/system #服务目录
vi neo4j.service

[Unit]
Description=neo4j #描述
After=network.target remote-fs.target nss-lookup.target #执行前验证网络等服务是否正常

[Service]
Type=forking #开启后台进程
ExecStart=/opt/neo4j/bin/start.sh #启动脚本
ExecStop=/opt/neo4j/bin/stop.sh  #停止脚本
PrivateTpm=true #临时缓存文件开启默认缓存到/tmp下

[Install]
WantedBy=multi-user.target

3.开启服务

systemctl enable neo4j.service

4.验证

reboot

 

参考:

http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html

https://www.cnblogs.com/gaoyuechen/p/8991091.html

posted @ 2021-04-22 15:30  aongao  阅读(750)  评论(0编辑  收藏  举报