参考官网文档,将neo4j-5.26.0
部署在在VMware® Workstation 17 Pro
的CentOS7
上。
注意要提前安装jdk17,如果是oracle jdk还要需要安装适配器,参考以上官网文档
直接启动成功
[root@localhost ~]# neo4j start
Directories in use:
home: /var/lib/neo4j
config: /etc/neo4j
logs: /var/log/neo4j
plugins: /var/lib/neo4j/plugins
import: /var/lib/neo4j/import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
licenses: /var/lib/neo4j/licenses
run: /var/lib/neo4j/run
Starting Neo4j.
WARNING: Max 4096 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
Started neo4j (pid:5829). It is available at http://localhost:7474
There may be a short delay until the server is ready.
杀掉进程后,启动服务失败
[root@localhost ~]# systemctl start neo4j
[root@localhost ~]# systemctl status neo4j
● neo4j.service - Neo4j Graph Database
Loaded: loaded (/usr/lib/systemd/system/neo4j.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 六 2024-12-28 20:38:36 CST; 546ms ago
Process: 6368 ExecStart=/usr/share/neo4j/bin/neo4j console (code=exited, status=1/FAILURE)
Main PID: 6368 (code=exited, status=1/FAILURE)
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "DebugLog" for logger config "root"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "HttpLog" for logger config "HttpLogger"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "QueryLog" for logger config "QueryLogger"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "SecurityLog" for logger config "SecurityLogger"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Configuration file validation failed.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Configuration contains errors. This validation can be performed again using 'neo4j-admin server validate-config'.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Run with '--verbose' for a more detailed error message.
12月 28 20:38:36 localhost.localdomain systemd[1]: neo4j.service: main process exited, code=exited, status=1/FAILURE
12月 28 20:38:36 localhost.localdomain systemd[1]: Unit neo4j.service entered failed state.
12月 28 20:38:36 localhost.localdomain systemd[1]: neo4j.service failed.
参考官网文档查看systemd日志
[root@localhost ~]# journalctl -e -u neo4j
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Cannot access RandomAccessFile java.io.FileNotFoundException: /var/log/neo4j/http.log (权限不够)
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile: java.lang.Il
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile: java.lang
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Cannot access RandomAccessFile java.io.FileNotFoundException: /var/log/neo4j/query.log (权限不够)
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile: java.lang.Il
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile: java.lang
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Cannot access RandomAccessFile java.io.FileNotFoundException: /var/log/neo4j/security.log (权限不够)
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile: java.lang.Il
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile: java.lang
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "DebugLog" for logger config "root"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "HttpLog" for logger config "HttpLogger"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "QueryLog" for logger config "QueryLogger"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "SecurityLog" for logger config "SecurityLogger"
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Configuration file validation failed.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Configuration contains errors. This validation can be performed again using 'neo4j-admin server validate-config'.
12月 28 20:38:36 localhost.localdomain neo4j[6368]: Run with '--verbose' for a more detailed error message.
12月 28 20:38:36 localhost.localdomain systemd[1]: neo4j.service: main process exited, code=exited, status=1/FAILURE
12月 28 20:38:36 localhost.localdomain systemd[1]: Unit neo4j.service entered failed state.
12月 28 20:38:36 localhost.localdomain systemd[1]: neo4j.service failed.
参考systemd官网文档,配置service参数,添加用户组
然后根据gpt,修改文件权限
sudo chown neo4j:neo4j /var/log/neo4j/*.log
sudo chmod 644 /var/log/neo4j/*.log
还是出错
[root@localhost ~]# sudo systemctl status neo4j
● neo4j.service - Neo4j Graph Database
Loaded: loaded (/usr/lib/systemd/system/neo4j.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/neo4j.service.d
└─override.conf
Active: failed (Result: exit-code) since 六 2024-12-28 21:06:32 CST; 1s ago
Process: 8366 ExecStart=/usr/share/neo4j/bin/neo4j console (code=exited, status=1/FAILURE)
Main PID: 8366 (code=exited, status=1/FAILURE)
12月 28 21:06:32 localhost.localdomain neo4j[8366]: at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:91) ~[neo4j-common-5.26.0.jar:5.26.0]
12月 28 21:06:32 localhost.localdomain neo4j[8366]: at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:279) ~[neo4j-5.26.0.jar:5.26.0]
12月 28 21:06:32 localhost.localdomain neo4j[8366]: ... 5 more
12月 28 21:06:32 localhost.localdomain neo4j[8366]: 2024-12-28 13:06:32.473+0000 INFO Neo4j Server shutdown initiated by request
12月 28 21:06:32 localhost.localdomain neo4j[8366]: 2024-12-28 13:06:32.474+0000 INFO Stopped.
12月 28 21:06:32 localhost.localdomain neo4j[8366]: Neo4j web server failed to start. See log for more info.
12月 28 21:06:32 localhost.localdomain neo4j[8366]: Run with '--verbose' for a more detailed error message.
12月 28 21:06:32 localhost.localdomain systemd[1]: neo4j.service: main process exited, code=exited, status=1/FAILURE
12月 28 21:06:32 localhost.localdomain systemd[1]: Unit neo4j.service entered failed state.
12月 28 21:06:32 localhost.localdomain systemd[1]: neo4j.service failed.
继续检查日志
vim /var/log/neo4j/neo4j.log
发现还是权限问题,不过是另外的文件
Caused by: java.nio.file.AccessDeniedException: /var/lib/neo4j/data/databases/store_lock
问了gpt修改权限
sudo chown neo4j:neo4j /var/lib/neo4j/data/databases/store_lock
还是出错,检查日志,又是权限问题
Caused by: java.nio.file.AccessDeniedException: /var/lib/neo4j/data/databases/system/neostore
修改上级文件夹权限
sudo chown -R neo4j:neo4j /var/lib/neo4j/data
终于启动成功
[root@localhost ~]# sudo systemctl status neo4j
● neo4j.service - Neo4j Graph Database
Loaded: loaded (/usr/lib/systemd/system/neo4j.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/neo4j.service.d
└─override.conf
Active: active (running) since 六 2024-12-28 21:18:16 CST; 19s ago
Main PID: 9396 (java)
Tasks: 82
Memory: 550.9M
CGroup: /system.slice/neo4j.service
├─9396 /usr/bin/java -Xmx128m -classpath /usr/share/neo4j/lib/*:/usr/share/neo4j/etc:/usr/share/neo4j/repo/* -Dapp.name=neo4j -Dapp.pid=9396 -Dapp.repo=/usr/share/neo4j/repo -Dapp.home=/usr/share/neo4j -Db...
└─9447 /usr/lib/jvm/jdk-17-oracle-x64/bin/java -cp /var/lib/neo4j/plugins/*:/etc/neo4j/*:/usr/share/neo4j/lib/* -XX:+UseG1GC -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOpti...
12月 28 21:18:21 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:21.522+0000 INFO This instance is ServerId{f90e42f9} (f90e42f9-ee96-4ab9-974f-ec0e9ecb0f50)
12月 28 21:18:23 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:23.162+0000 INFO ======== Neo4j 5.26.0 ========
12月 28 21:18:27 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:27.216+0000 INFO Anonymous Usage Data is being sent to Neo4j, see https://neo4j.com/docs/usage-data/
12月 28 21:18:27 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:27.263+0000 INFO Bolt enabled on localhost:7687.
12月 28 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.333+0000 INFO HTTP enabled on localhost:7474.
12月 28 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.335+0000 INFO Remote interface available at http://localhost:7474/
12月 28 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.340+0000 INFO id: 3DE12D590B19617A22755F2209973E9AE8F7E5D5A3FA1136DBBC23DFA2237E4C
12月 28 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.341+0000 INFO name: system
12月 28 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.341+0000 INFO creationDate: 2024-12-28T08:12:13.002Z
12月 28 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.342+0000 INFO Started.
如果neo4j安装在虚拟机,从本机浏览器访问,要修改配置
vim /etc/neo4j/neo4j.conf
server.default_listen_address=0.0.0.0