我在Docker中遇到Neo4j的怪异问题。这是我的docker-compose文件:
version: '3'
services:
neo4j:
ports:
- "7473:7473"
- "7474:7474"
- "7687:7687"
volumes:
- neo4j_data:/data
image: neo4j:3.3
volumes:
neo4j_data: {}
我正在Windows 10上使用Docker Toolbox。我已经在两台不同的机器上对其进行了测试,并且可以完美运行。但是,在一台计算机上,容器在创建后总是会崩溃几秒钟。这是此容器的日志:
$ docker container logs database_neo4j_1
Active database: graph.db
Directories in use:
home: /var/lib/neo4j
config: /var/lib/neo4j/conf
logs: /var/lib/neo4j/logs
plugins: /var/lib/neo4j/plugins
import: /var/lib/neo4j/import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/lib/neo4j/run
Starting Neo4j.
2018-11-18 12:50:41.954+0000 WARN Unknown config option: causal_clustering.discovery_listen_address
2018-11-18 12:50:41.965+0000 WARN Unknown config option: causal_clustering.raft_advertised_address
2018-11-18 12:50:41.965+0000 WARN Unknown config option: causal_clustering.raft_listen_address
2018-11-18 12:50:41.967+0000 WARN Unknown config option: ha.host.coordination
2018-11-18 12:50:41.968+0000 WARN Unknown config option: causal_clustering.transaction_advertised_address
2018-11-18 12:50:41.968+0000 WARN Unknown config option: causal_clustering.discovery_advertised_address
2018-11-18 12:50:41.969+0000 WARN Unknown config option: ha.host.data
2018-11-18 12:50:41.970+0000 WARN Unknown config option: causal_clustering.transaction_listen_address
2018-11-18 12:50:42.045+0000 INFO ======== Neo4j 3.3.9 ========
2018-11-18 12:50:42.275+0000 INFO Starting...
2018-11-18 12:50:48.632+0000 INFO Bolt enabled on 0.0.0.0:7687.
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 262160 bytes for Chunk::new
# An error report file with more information is saved as:
# /var/lib/neo4j/hs_err_pid6.log
#
# Compiler replay data is saved as:
# /var/lib/neo4j/replay_pid6.log
答案 0 :(得分:1)
正在寻找其他日志文件/var/lib/neo4j/hs_err_pid6.log
,显示了以下信息:
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 262160 bytes for Chunk::new
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:390), pid=6, tid=0x00007fee96f9bae8
#
# JRE version: OpenJDK Runtime Environment (8.0_181-b13) (build 1.8.0_181-b13)
# Java VM: OpenJDK 64-Bit Server VM (25.181-b13 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.9.0
# Distribution: Custom build (Tue Oct 23 11:27:22 UTC 2018)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
事实证明,我的Docker机器仅设置为1GB RAM,而Neo4j的最低要求(根据their website)为2GB。通过根据this guide替换默认的Docker计算机并提供了一个新的4GB内存,我得以解决此问题。
基本上,我做了以下事情:
$ docker-machine rm default
$ docker-machine create -d virtualbox --virtualbox-cpu-count=2 --virtualbox-memory=4096 --virtualbox-disk-size=50000 default
您可能还需要重新启动Docker:
docker-machine stop
exit
到目前为止,我尚未在网上找到有关此问题的任何信息,因此有一天有可能对某人有帮助=)。