Neo4j GDS(Graph Data Science)库安装(Mac版)

Neo4j GDS(Graph Data Science)库安装(Mac版)

Neo4j GDS库安装(Mac版)

前言

最近在研究llm-graph-builder这个项目。因为我之前对数据库这里不太懂,所以里面的Neo4j的东西让我理解起来很头疼。这篇是我一步一步安装下来,然后一步步截图来的。照着我的做,准没有问题。如果你是windows版本,那这篇博客也能给你起到参考作用。

GDS(Graph Data Science)库官方介绍

The Neo4j Graph Data Science (GDS) library provides efficiently implemented, parallel versions of common graph algorithms, exposed as Cypher procedures. Additionally, GDS includes machine learning pipelines to train predictive supervised models to solve graph problems, such as predicting missing relationships.

翻译如下:

Neo4j Graph Data Science (GDS) 库提供常见图形算法的高效实现、并行版本,以 Cypher 程序的形式公开。此外,GDS 还包括机器学习管道,用于训练预测监督模型来解决图形问题,例如预测缺失关系。

GDS(Graph Data Science)库安装

1、确认咱们到底装了GDS没有

首先在 http://localhost:7474中(也就是在Neo4j)输入

bash 复制代码
RETURN gds.version()

如果结果是(如图),

sql 复制代码
Neo.ClientError.Statement.SyntaxError
Unknown function 'gds.version' (line 1, column 8 (offset: 7))
"RETURN gds.version()"
        ^

这就说明咱们确实没装GDS,开始第二步。

2、找到并下载我们装的Neo4j对应的GDS版本

首先在终端 输入

bash 复制代码
open /usr/local/Cellar/neo4j

找到自己的neo4j的版本(如图),那我neo4j版本就是2025.01.0

然后进入Neo4j Graph Data Science官方文档也就是这个网址
https://neo4j.com/docs/graph-data-science/current/installation/supported-neo4j-versions/

里找对应的关系,如图。

从这张图,我们可以看出我们要装的GDS的版本是2.14。

接着进入https://github.com/neo4j/graph-data-science/releases这个网站里,找到我们要装的版本的jar包下载下来。(如图)

3、把jar包复制到neo4j的plugins的文件夹内和修改,验证是否装成功

把下载完成的neo4j-graph-data-science的jar包复制到neo4j的plugins的文件夹里面

也就是/usr/local/Cellar/neo4j/你的版本/libexec/plugins 这个路径里面。

接着打开neo4j的conf/neo4j.conf。(如图)

打开之后,我们根据自己的neo4j的版本,新版本(Neo4j 4.3+),加入

bash 复制代码
dbms.security.procedures.unrestricted=gds.*
dbms.security.procedures.allowlist=gds.*

而旧版本(Neo4j 3.x-4.2),则加入

bash 复制代码
dbms.security.procedures.unrestricted=gds.*
dbms.security.procedures.whitelist=gds.*

加入作用如下就是 无限制和白名单。

bash 复制代码
dbms.security.procedures.unrestricted=gds.*
作用:允许所有以 gds. 开头的存储过程无需额外权限即可被任何用户调用。
场景:GDS 库中的算法(如 PageRank、社区检测等)通常需要高性能计算权限。将此参数设置为 gds.* 意味着任何用户(包括未登录用户)都可以直接执行这些过程,无需授予 EXECUTE PROCEDURE 权限。
风险:开放权限可能带来安全隐患,需确保仅在可信环境中使用。

dbms.security.procedures.whitelist=gds.*
dbms.security.procedures.allowlist=gds.*
作用:这两个参数定义了一个允许执行的存储过程白名单。只有列出的存储过程(如 gds.*)可以被调用,其他未列出的过程会被阻止。
历史变化:whitelist 是旧版本参数名称(Neo4j 3.x-4.2)。allowlist 是新版本参数名称(Neo4j 4.3+),出于术语规范性考虑,弃用了 whitelist。

要加到 dbms.security 那一堆,这样之后找也比较好找,加入后保存。如果你和我一样前面装了apoc,那么就把gds加在apoc后面就可以了,不能两个都加,会报错哦。

接着输入

bash 复制代码
RETURN gds.version()

结果如图,就成功了

错误示范:

输入neo4j restart的报错如下:

bash 复制代码
Stopping Neo4j............ stopped.
Validating Neo4j configuration: /usr/local/Cellar/neo4j/2025.01.0/libexec/conf/neo4j.conf
1 issue found.
Error: dbms.security.procedures.allowlist declared multiple times.

Skipping Log4j validation due to previous issues.

Configuration file validation failed.
2025-03-21 09:17:07.573+0000 ERROR /usr/local/Cellar/neo4j/2025.01.0/libexec/conf/neo4j.conf - Error: dbms.security.procedures.allowlist declared multiple times.
Configuration contains errors. This validation can be performed again using 'neo4j-admin server validate-config'.
Run with '--verbose' for a more detailed error message.
(base) phoenix@liwenchangdeMBP ~ % neo4j restart
Neo4j is not running.
Validating Neo4j configuration: /usr/local/Cellar/neo4j/2025.01.0/libexec/conf/neo4j.conf
1 issue found.
Error: dbms.security.procedures.allowlist declared multiple times.

Skipping Log4j validation due to previous issues.

Configuration file validation failed.
2025-03-21 09:17:25.059+0000 ERROR /usr/local/Cellar/neo4j/2025.01.0/libexec/conf/neo4j.conf - Error: dbms.security.procedures.allowlist declared multiple times.
Configuration contains errors. This validation can be performed again using 'neo4j-admin server validate-config'.
Run with '--verbose' for a more detailed error message.

参考博客

Neo4j使用记录--APOC和GDS的安装【实践】

结束语

恭喜恭喜,相信一步步跟我做下来的你肯定也成功了。有什么问题后可以给我留言和私信,我看到后就会回复。

相关推荐
HIT_Weston15 分钟前
45、【Agent】【OpenCode】本地代理分析(请求&接收回调)
人工智能·agent·opencode
逻辑君31 分钟前
认知神经科学研究报告【20260010】
人工智能·深度学习·神经网络·机器学习
星河耀银海43 分钟前
远控体验分享:安全与实用性参考
人工智能·安全·微服务
企业架构师老王1 小时前
2026企业架构演进:科普Agent(龙虾)如何从“极客玩具”走向实在Agent规模化落地?
人工智能·ai·架构
GreenTea1 小时前
一文搞懂Harness Engineering与Meta-Harness
前端·人工智能·后端
鬼先生_sir1 小时前
Spring AI Alibaba 1.1.2.2 完整知识点库
人工智能·ai·agent·源码解析·springai
深念Y1 小时前
豆包AI能力集成方案:基于会话管理的API网关设计
人工智能
龙文浩_2 小时前
Attention Mechanism: From Theory to Code
人工智能·深度学习·神经网络·学习·自然语言处理
ulimate_2 小时前
八卡算力、三个Baseline算法(WALLOSS、pi0、DreamZero)
人工智能
深小乐2 小时前
AI 周刊【2026.04.06-04.12】:Anthropic 藏起最强模型、AI 社会矛盾激化、"欢乐马"登顶
人工智能