[教程]docker 安装 neo4j以及APOC

拉取镜像:


docker pull neo4j:4.4.28
为neo4j映射5个文件夹 这里目录我现在/host_mnt/g/neo4j/(这里是DockerDesktopforWindows/WSL2环境)
在该目录下创建5个空文件夹:


conf

data

import

logs

plugins
做好映射即可

输入命令: 密码和容器名字可自行修改

直接run


docker run -d --name neo4j \
  -p 7474:7474 -p 7687:7687 \  # Expose ports 7474 (HTTP) and 7687 (Bolt) from the container to the host
  -v /host_mnt/g/neo4j/data:/data \  # Mount host directory /host_mnt/g/neo4j/data to container path /data (for database storage)
  -v /host_mnt/g/neo4j/logs:/logs \  # Mount host directory /host_mnt/g/neo4j/logs to container path /logs (for logs)
  -v /host_mnt/g/neo4j/conf:/var/lib/neo4j/conf \  # Mount host directory /host_mnt/g/neo4j/conf to container path /var/lib/neo4j/conf (for configuration files)
  -v /host_mnt/g/neo4j/import:/var/lib/neo4j/import \  # Mount host directory /host_mnt/g/neo4j/import to container path /var/lib/neo4j/import (for data import)
  -v /host_mnt/g/neo4j/plugins:/plugins \  # Mount host directory /host_mnt/g/neo4j/plugins to container path /plugins (for plugins)
  --env NEO4J_AUTH=neo4j/password \  # Set environment variable NEO4J_AUTH to set initial username/password (neo4j/password)
  neo4j:4.4.28  # Docker image name and tag (Neo4j version 4.4.28)


一行命令:

docker run -d --name neo4j -p 7474:7474 -p 7687:7687 -v /host_mnt/g/neo4j/data:/data -v /host_mnt/g/neo4j/logs:/logs -v /host_mnt/g/neo4j/conf:/var/lib/neo4j/conf -v /host_mnt/g/neo4j/import:/var/lib/neo4j/import -v /host_mnt/g/neo4j/plugins:/plugins --env NEO4J_AUTH=neo4j/password neo4j:4.4.28
此时通过 IP地址:7474 即可访问web页面 但是要开启远程访问还需要进行配置


配置开启远程访问
由于前面我们映射了配置文件 我们直接修改/host_mnt/g/neo4j/conf下的配置文件
添加下面3行代码即可:

dbms.connector.bolt.listen_address=0.0.0.0:7687
dbms.connector.http.listen_address=0.0.0.0:7474
dbms.connector.https.listen_address=0.0.0.0:7473

记得开放对应端口!
安装APOC


通过web页面查看neo4j版本

找到对应版本的APOC jar包下载
https://github.com/neo4j-contrib/neo4j-apoc-procedures
下载好后放入映射的plugins文件夹里
配置文件添加语句:

dbms.security.procedures.unrestricted=apoc.*


哈重新启动容器
查看是否安装成功:

return apoc.version()


发表评论

路人甲 表情
看不清楚?点图切换 Ctrl+Enter快速提交

网友评论(0)

sitemap