【docker】docker启动neo4j,并配置内存

注意下:--volume=宿主机目录:/data--publish=宿主机port:7474 --publish=宿主机port:7687

bash 复制代码
docker run -d \
--publish=9801:7474 --publish=9802:7687 \
--env NEO4J_AUTH=neo4j/passwd \
--volume=/opt/docker/data/vol-data/neo4j4.2:/data \
--restart always \
--memory 2G
--name neo4j4.2 neo4j:4.2.9-community

查看容器占用内存

bash 复制代码
docker stats neo4j4.2
# CONTAINER ID   NAME       CPU %     MEM USAGE / LIMIT   MEM %     NET I/O         BLOCK I/O         PIDS
# a3dbc78b8ac2   neo4j4.2   0.34%     395.8MiB / 2GiB     19.33%    738kB / 605kB   80.6MB / 5.77MB   47
bash 复制代码
docker exec -it neo4j4.2 /bin/bash
cd /var/lib/neo4j/conf

cat neo4j.conf

可以看到neo4j的配置文件 neo4j.conf,默认#dbms.memory.heap.initial_size=512m #dbms.memory.heap.max_size=512m 都没有配置。而dbms.memory.pagecache.size=512M已配置

bash 复制代码
# 启动java-heap内存,建议启动和最大设置成一样的。
# Java Heap Size: by default the Java heap size is dynamically calculated based
# on available system resources. Uncomment these lines to set specific initial
# and maximum heap size.
#dbms.memory.heap.initial_size=512m
#dbms.memory.heap.max_size=512m

# neo4j索引从文件系统映射内存。设置内存大小。
# The amount of memory to use for mapping the store files.
# The default page cache memory assumes the machine is dedicated to running
# Neo4j, and is heuristically set to 50% of RAM minus the Java heap size.
#dbms.memory.pagecache.size=10g

# 全局事务内存。所有事务的总内存
# Limit the amount of memory that all of the running transaction can consume.
# By default there is no limit.
#dbms.memory.transaction.global_max_size=256m

# 单个事务的内存。
# Limit the amount of memory that a single transaction can consume.
# By default there is no limit.
#dbms.memory.transaction.max_size=16m

docker 配置文档
neo4j配置官网

修改配置:

bash 复制代码
# 复制到宿主机
 docker cp neo4j4.2:/var/lib/neo4j/conf/neo4j.conf .

# 内容 vim neo4j.conf :
dbms.memory.heap.initial_size=512m
dbms.memory.heap.max_size=512m
dbms.memory.transaction.global_max_size=512m
dbms.memory.pagecache.size=1024M

# 复制回去
docker cp ./neo4j.conf neo4j4.2:/var/lib/neo4j/conf
# check一下
docker exec neo4j4.2 cat /var/lib/neo4j/conf/neo4j.conf | grep memory
# 重启容器
docker restart neo4j4.2

参考文章

如何为 docker 容器设置内存限制?

相关推荐
hai-chu1 天前
将 Neo4j 安装为 macOS 服务
macos·策略模式·neo4j
❀͜͡傀儡师1 天前
docker部署orion-ops一站式运维管理平台
运维·docker·github
笨蛋不要掉眼泪1 天前
Docker概念入门与初步安装
docker·微服务·容器
青靴1 天前
轻量级 CI/CD 实战(三):Kafka消费者Docker容器化部署
分布式·docker·kafka
青靴1 天前
轻量级 CI/CD 实战(四):本地开发钉钉告警 → 自动部署云服务器 Kafka 消费者容器
ci/cd·docker·钉钉
秋邱1 天前
自我进化!AI 驱动平台自动迭代,用户行为 + 数据反馈打造教育超级助手 2.0
网络·数据库·人工智能·redis·python·缓存·docker
deyong10242 天前
使用 Docker Compose 构建 Misskey项目
运维·docker·容器
拾心212 天前
【云运维】k8s管理(一)
运维·容器·kubernetes
究極の法則に通じた野犬2 天前
K8S 本地机器 windows 推送官方镜像到本地镜像仓库 (Docker) -- 以curl镜像为例
docker·容器·kubernetes
j***12152 天前
springboot整合libreoffice(两种方式,使用本地和远程的libreoffice);docker中同时部署应用和libreoffice
spring boot·后端·docker