neo4j自启服务
1 创建neo4j启动脚本
在neo4j的目录里创建脚本
[root@node1 neo4j]# vim /usr/local/neo4j/start.sh
#!/bin/bash
# JDK的安装目录
export JAVA_HOME=/opt/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH
sh /usr/local/neo4j/bin/neo4j start
2 创建neo4j结束脚本
在neo4j的目录里创建脚本
[root@node1 neo4j]# vim /usr/local/neo4j/stop.sh
#!/bin/bash
# JDK的安装目录
export JAVA_HOME=/opt/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH
sh /usr/local/neo4j/bin/neo4j stop
3 将脚本赋予可执行权限
[root@node1 neo4j]# chmod +x /usr/local/neo4j/start.sh
[root@node1 neo4j]# chmod +x /usr/local/neo4j/stop.sh
4 创建系统服务文件
[root@node1 neo4j]# cd /usr/lib/systemd/system
[root@node1 system]# vim neo4j.service
[Unit]
Description=neo4j
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/neo4j/start.sh
ExecStop=/usr/local/neo4j/stop.sh
PrivateTpm=true
[Install]
WantedBy=multi-user.target
4 服务初始化
[root@node1 system]# systemctl daemon-reload
[root@node1 system]# systemctl enable neo4j.service