虚拟机部署Neo4j踩坑记录

参考官网文档,将neo4j-5.26.0部署在在VMware® Workstation 17 ProCentOS7上。

注意要提前安装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)

1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "DebugLog" for logger config "root"
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "HttpLog" for logger config "HttpLogger"
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "QueryLog" for logger config "QueryLogger"
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "SecurityLog" for logger config "SecurityLogger"
1228 20:38:36 localhost.localdomain neo4j[6368]: Configuration file validation failed.
1228 20:38:36 localhost.localdomain neo4j[6368]: Configuration contains errors. This validation can be performed again using 'neo4j-admin server validate-config'.
1228 20:38:36 localhost.localdomain neo4j[6368]: Run with '--verbose' for a more detailed error message.
1228 20:38:36 localhost.localdomain systemd[1]: neo4j.service: main process exited, code=exited, status=1/FAILURE
1228 20:38:36 localhost.localdomain systemd[1]: Unit neo4j.service entered failed state.
1228 20:38:36 localhost.localdomain systemd[1]: neo4j.service failed.

参考官网文档查看systemd日志

[root@localhost ~]# journalctl -e -u neo4j
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Cannot access RandomAccessFile java.io.FileNotFoundException: /var/log/neo4j/http.log (权限不够)
1228 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
1228 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
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Cannot access RandomAccessFile java.io.FileNotFoundException: /var/log/neo4j/query.log (权限不够)
1228 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
1228 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
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Cannot access RandomAccessFile java.io.FileNotFoundException: /var/log/neo4j/security.log (权限不够)
1228 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
1228 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
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Null object returned for RollingRandomAccessFile in Appenders.
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "DebugLog" for logger config "root"
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "HttpLog" for logger config "HttpLogger"
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "QueryLog" for logger config "QueryLogger"
1228 20:38:36 localhost.localdomain neo4j[6368]: Warning: Unable to locate appender "SecurityLog" for logger config "SecurityLogger"
1228 20:38:36 localhost.localdomain neo4j[6368]: Configuration file validation failed.
1228 20:38:36 localhost.localdomain neo4j[6368]: Configuration contains errors. This validation can be performed again using 'neo4j-admin server validate-config'.
1228 20:38:36 localhost.localdomain neo4j[6368]: Run with '--verbose' for a more detailed error message.
1228 20:38:36 localhost.localdomain systemd[1]: neo4j.service: main process exited, code=exited, status=1/FAILURE
1228 20:38:36 localhost.localdomain systemd[1]: Unit neo4j.service entered failed state.
1228 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)

1228 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]
1228 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]
1228 21:06:32 localhost.localdomain neo4j[8366]: ... 5 more
1228 21:06:32 localhost.localdomain neo4j[8366]: 2024-12-28 13:06:32.473+0000 INFO  Neo4j Server shutdown initiated by request
1228 21:06:32 localhost.localdomain neo4j[8366]: 2024-12-28 13:06:32.474+0000 INFO  Stopped.
1228 21:06:32 localhost.localdomain neo4j[8366]: Neo4j web server failed to start. See log for more info.
1228 21:06:32 localhost.localdomain neo4j[8366]: Run with '--verbose' for a more detailed error message.
1228 21:06:32 localhost.localdomain systemd[1]: neo4j.service: main process exited, code=exited, status=1/FAILURE
1228 21:06:32 localhost.localdomain systemd[1]: Unit neo4j.service entered failed state.
1228 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...

1228 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)
1228 21:18:23 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:23.162+0000 INFO  ======== Neo4j 5.26.0 ========
1228 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/
1228 21:18:27 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:27.263+0000 INFO  Bolt enabled on localhost:7687.
1228 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.333+0000 INFO  HTTP enabled on localhost:7474.
1228 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.335+0000 INFO  Remote interface available at http://localhost:7474/
1228 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.340+0000 INFO  id: 3DE12D590B19617A22755F2209973E9AE8F7E5D5A3FA1136DBBC23DFA2237E4C
1228 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.341+0000 INFO  name: system
1228 21:18:28 localhost.localdomain neo4j[9396]: 2024-12-28 13:18:28.341+0000 INFO  creationDate: 2024-12-28T08:12:13.002Z
1228 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值