Neo4j APOC 用户手册 4.4-0002-安装及用法
0、背景
本系列翻译一下 Neo4j 阿波克用户手册 4.4 版本~
(1)本系列文章
格瑞图:Neo4j APOC 用户手册 4.4-0001-概览及简介
1、 安装 - Installation
APOC Core
is packaged with Neo4j and can be found in the
$NEO4J_HOME/labs
directory.
APOC Full
can be downloaded using one of the methods described in the sections below.
阿波克核心版随 Neo4j一起打包发行,可以在 $N_H/labs 目录找到。阿波克完整版可以使用下面描述的方法下载。
APOC Full contains all the procedures and functions included in APOC Core. You must not install both libraries.
阿波克完整版包含核心版所有的过程和函数。千万不要同时安装两个库。
(1)阿波克核心版 - APOC Core
APOC Core can be installed by moving the APOC jar file from the$NEO4J_HOME/labs
directory to the$NEO4J_HOME/plugins
directory and restarting Neo4j.
阿波克核心版可以通过将其从 $N_H/labs 目录移动到插件 plugins 目录,并重启 Neo4j 实现。
(2)Neo4j 桌面版 - Neo4j Desktop
APOC Full can be installed with Neo4j Desktop , after creating your database, by going to theManage
screen, and then thePlugins
tab. ClickInstall
in the APOC box and wait until you see a green check mark near "APOC".
阿波克完整版可以和 Neo4j 桌面版一起安装,在创建完数据库后,到管理 M 界面的插件 P 页签。点击阿波克分组中的安装 I 按钮来安装。
(3)Neo4j 服务器版 - Neo4j Server
Since APOC relies on Neo4j’s internal APIs you need to use the matching APOC version for your Neo4j installaton. Make sure that the first two version numbers match between Neo4j and APOC .
因为阿波克依赖 Neo4j 内部接口,所以需要匹配阿波克和 Neo4j 的版本。请确保 Neo4j 和阿波克版本号前两位匹配。
Go to
the latest release
for
Neo4j version 4.4
and download the binary jar to place into your
$NEO4J_HOME/plugins
folder.
去 Neo4j 版本 4.4 最新发版页面下载二进制库包并放置到 $N_H/plugins 插件目录。
You can find all releases here .
可以在这里找到 所有发布版本 。
After you move the jar file to the plugins folder you have to restart neo4j withneo4j restart
Since APOC relies on Neo4j’s internal APIs, you need to use the right APOC version for your Neo4j installation.
在将包移动到插件目录后需要使用 neo4j restart 重启 Neo4j。因为阿波克依赖 Neo4j 内部接口,需要保证阿波克和已安装 Neo4j 版本匹配。
APOC uses a consistent versioning scheme:<neo4j-version>.<apoc>
version. The trailing<apoc>
part of the version number will be incremented with every apoc release.
阿波克使用一致的版本管理方案:n-v.a 版本命名。末尾的阿波克部分版本号会随着每次阿波克发版自增。
The version compatibility matrix explains the mapping between Neo4j and APOC versions:
这个版本兼容性矩阵解释了 Neo4j 和阿波克版本之间的映射关系:
apoc version | neo4j version |
---|---|
4.4.0.1 | 4.4.0 (4.3.x) |
4.3.0.4 | 4.3.7 (4.3.x) |
4.2.0.9 | 4.2.11 (4.2.x) |
4.1.0.10 | 4.1.11 (4.1.x) |
4.0.0.18 | 4.0.12 (4.0.x) |
3.5.0.15 | 3.5.30 (3.5.x) |
3.4.0.8 | 3.4.18 (3.4.x) |
3.3.0.4 | 3.3.9 (3.3.x) |
3.2.3.6 | 3.2.14 (3.2.x) |
3.1.3.9 | 3.1.9 (3.1.x) |
3.0.8.6 | 3.0.12 (3.0.x) |
3.5.0.0 | 3.5.0-beta01 |
3.4.0.2 | 3.4.5 |
3.3.0.3 | 3.3.5 |
3.2.3.5 | 3.2.3 |
3.1.3.8 | 3.1.5 |
If by mistake a jar not compatible with the neo4j version is inserted, alog.warn
like this will appear inneo4j.log
:
The apoc version (<APOC_VERSION>) and the Neo4j DBMS versions [NEO4J_VERSION] are incompatible.
See the compatibility matrix in https://neo4j.com/labs/apoc/4.4/installation/ to see the correct version
(4)容器部署 - Docker
APOC Full can be used with the
Neo4j Docker image
via the
NEO4JLABS_PLUGINS
environment variable. If we use this environment variable, the APOC plugin will be downloaded and configured at runtime.
阿波克完整版可以通过环境变量 N_P 在 Neo4j 容器镜像中使用。如果配置了此环境变量,阿波克插件将会在运行时下载和配置。
This feature is intended to facilitate using APOC in development environments, but it is not recommended for use in production environments.
该特性用来在研发环境使用阿波克,但是不建议在生产环境使用。
The following runs Neo4j 4.0 in a Docker container with the latest version of the APOC Library
下面的命令运行一个 Neo4j 容器并使用最新版本的阿波克库。
docker run \
-p 7474:7474 -p 7687:7687 \
-v $PWD/data:/data -v $PWD/plugins:/plugins \
--name neo4j-apoc \
-e NEO4J_apoc_export_file_enabled=true \
-e NEO4J_apoc_import_file_enabled=true \
-e NEO4J_apoc_import_file_use__neo4j__config=true \
-e NEO4JLABS_PLUGINS=\[\"apoc\"\] \
neo4j:4.0
We should see the following two lines in the output after running this command:
运行完上面的命令后会看到下面两行输出
Fetching versions.json for Plugin 'apoc' from https://neo4j-contrib.github.io/neo4j-apoc-procedures/versions.json
Installing Plugin 'apoc' from https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.4.0.6/4.4.0.6-all.jar to /plugins/apoc.jar
In a production environment we should download the APOC release matching our Neo4j version and, copy it to a local folder, and supply it as a data volume mounted at
/plugins
.
在生产环境中我们应该首先下载与 Neo4j 版本匹配的阿波克版本,拷贝到一个本地目录,然后通过数据卷挂载到插件 /p 来提供阿波克。
The following downloads the APOC Library into the
plugins
directory and then mounts that folder to the Neo4j Docker container
下面的命令创建一个 p 目录,然后将阿波克下载到该目录并将其挂载到 Neo4j 容器:
mkdir plugins
pushd plugins
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.4.0.6/apoc-4.4.0.6-all.jar
docker run --rm -e NEO4J_AUTH=none -p 7474:7474 -v $PWD/plugins:/plugins -p 7687:7687 neo4j:4.4
If you want to pass custom apoc config to your Docker instance, you can use environment variables, like here:
如果想给容器实例传递自定义阿波克配置,可以使用环境变量,像这样:
docker run \
-p 7474:7474 -p 7687:7687 \
-v $PWD/data:/data -v $PWD/plugins:/plugins \
--name neo4j-apoc \
-e NEO4J_apoc_export_file_enabled=true \
-e NEO4J_apoc_import_file_enabled=true \
-e NEO4J_apoc_import_file_use__neo4j__config=true \