版本不对应时如下结果:
neo4j官方网址:
https://neo4j.com/
neo4j-3版本对应JDK8;(官方已不支持,没找到下载地址)
neo4j-4版本对应JDK11;
neo4j-5版本对应JDK17;
JDK官网下载地址
:https://www.oracle.com/cn/java/technologies/downloads/#java11
# 在/usr/local下创建java文件夹,将下载的jdk上传至java文件夹下
mkdir /usr/local/java
# 解压上传的jdk文件夹到当前目录下
tar -zxvf jdk-11.0.18_linux-x64_bin.tar.gz
# 在/usr/local/下创建neo4j文件夹,
mkdir /usr/local/neo4j
# 上传neo4j压缩包至该文件夹,并解压
tar -zxvf neo4j-community-4.4.18-unix.tar.gz
# 修改环境变量
vim /etc/profile
#Java环境变量配置
export JAVA_HOME="/usr/local/java/jdk-11.0.18"
export PATH="$JAVA_HOME/bin:$PATH"
export CLASSPATH=".:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"
#neo4j环境变量配置
PATH="/usr/local/neo4j/neo4j-community-4.4.18/bin:$PATH"
# 更新环境变量文件,使修改立即生效
source /etc/profile
# 查看jdk配置是否正确
java -version
# 修改neo4j配置文件,让它可以从`远程访问控制台`
vim /usr/local/neo4j/neo4j-community-4.4.18/conf/neo4j.conf
# 查看防火墙状态
systemctl status firewalld
# 关闭防火墙
systemctl stop firewalld
neo4j.conf修改内容如下:
取消注释的 dbms.default_listen_address=0.0.0.0
# 启动neo4j;
neo4j start
# 登录用户:neo4j 登录密码:neo4j
neo4j官方语法文档:
https://neo4j.com/docs/cypher-manual/current/clauses/
简单操作与了解:https://zhuanlan.zhihu.com/p/88745411
LDBC_SNB导入数据库大概流程:
1、ldbc_snb_datagen生成测试数据
2、ldbc_snb_interactive_impls进行将测试的数据转换成neo4j数据库能导入的格式
3、将csv文件导入neo4j数据库
https://blog.csdn.net/spquan/article/details/121455546?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-121455546-blog-127413632.pc_relevant_multi_platform_whitelistv4&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-121455546-blog-127413632.pc_relevant_multi_platform_whitelistv4&utm_relevant_index=1
原因分析:
1、这里通过压缩包方式确实安装成功了Python2,但在/usr/bin/
下却只存在Python3,说明Python3是操作系统自带的安装
,python命令执行时,例:python --version
却是python 2版本的
# 创建软连接方式
sudo ln -s /usr/local/bin/python2.7 /usr/bin/python2
记录过程中出现的问题:
1、安装包不要在Windows上解压
后再上传至虚拟机,会出现问题。
2、Python2版本安装完成后
官方网址
:https://github.com/ldbc/ldbc_snb_interactive_impls
ldbc_snb_interactive_impls是ldbc_snb的交互式实现,用途:
1、转换测试的数据为neo4j数据库能导入的数据类型
2、导入csv数据入库
相关执行命令路径
/usr/local/ldbc_snb/ldbc_snb_interactive_impls-1.0.0/cypher/scripts
这里我研究了下.sh命令:例如第一次要执行的 :
vim ./load-in-one-step.sh
可以看出这些命令是为
Docker容器的neo4j
适配的。不过修改一下,我们依然可以用。
# 打开配置文件
vim /etc/profile
#添加Neo4j中测试数据文件夹路径变量
export NEO4J_CONVERTED_CSV_DIR="/usr/local/neo4j/converted_csv_dir"
export NEO4J_VANILLA_CSV_DIR="/usr/local/neo4j/vanilla_csv_dir"
#配置立即生效
source /etc/profile
[root@bogon scripts]# ls
backup-database.sh convert-csvs.sh import-to-neo4j-noDocker.sh load-in-one-step.sh start-neo4j.sh
backup-neo4j.sh create-indices.sh import-to-neo4j.sh restart-neo4j.sh stop-neo4j.sh
build.sh delete-neo4j-database.sh indices.cypher restore-database.sh vars.sh
cat headers.txt install-dependencies.sh restore-neo4j.sh
[root@bogon scripts]# ./load-in-one-step.sh
===============================================================================
Loading the Neo4j database
-------------------------------------------------------------------------------
NEO4J_CONTAINER_ROOT: /usr/local/neo4j/neo4j-community-4.4.18
NEO4J_CONTAINER_NAME: neo4j-community-4.4.18
NEO4J_DATA_DIR: /usr/local/neo4j/neo4j-community-4.4.18/data
NEO4J_ENV_VARS: /usr/local/neo4j/neo4j-community-4.4.18/bin
NEO4J_VERSION: 4.4.18
NEO4J_VANILLA_CSV_DIR (on the host machine):
/usr/local/neo4j/vanilla_csv_dir
NEO4J_CONVERTED_CSV_DIR (on the host machine):
/usr/local/neo4j/converted_csv_dir
NEO4J_DATA_DIR (on the host machine):
/usr/local/neo4j/neo4j-community-4.4.18/data
NEO4J_CSV_POSTFIX: _0_0.csv
===============================================================================
Starting preprocessing CSV files
static/organisation: id:ID(Organisation)|:LABEL|name:STRING|url:STRING
static/place: id:ID(Place)|name:STRING|url:STRING|:LABEL
static/tagclass: id:ID(TagClass)|name:STRING|url:STRING
static/tag: id:ID(Tag)|name:STRING|url:STRING
static/tagclass_isSubclassOf_tagclass: :START_ID(TagClass)|:END_ID(TagClass)
static/tag_hasType_tagclass: :START_ID(Tag)|:END_ID(TagClass)
static/organisation_isLocatedIn_place: :START_ID(Organisation)|:END_ID(Place)
static/place_isPartOf_place: :START_ID(Place)|:END_ID(Place)
dynamic/comment: id:ID(Comment)|creationDate:LONG|locationIP:STRING|browserUsed:STRING|content:STRING|length:INT
dynamic/forum: id:ID(Forum)|title:STRING|creationDate:LONG
dynamic/person: id:ID(Person)|firstName:STRING|lastName:STRING|gender:STRING|birthday:LONG|creationDate:LONG|locationIP:STRING|browserUsed:STRING|speaks:STRING[]|email:STRING[]
dynamic/post: id:ID(Post)|imageFile:STRING|creationDate:LONG|locationIP:STRING|browserUsed:STRING|language:STRING|content:STRING|length:INT
dynamic/comment_hasCreator_person: :START_ID(Comment)|:END_ID(Person)
dynamic/comment_isLocatedIn_place: :START_ID(Comment)|:END_ID(Place)
dynamic/comment_replyOf_comment: :START_ID(Comment)|:END_ID(Comment)
dynamic/comment_replyOf_post: :START_ID(Comment)|:END_ID(Post)
dynamic/forum_containerOf_post: :START_ID(Forum)|:END_ID(Post)
dynamic/forum_hasMember_person: :START_ID(Forum)|:END_ID(Person)|joinDate:LONG
dynamic/forum_hasModerator_person: :START_ID(Forum)|:END_ID(Person)
dynamic/forum_hasTag_tag: :START_ID(Forum)|:END_ID(Tag)
dynamic/person_hasInterest_tag: :START_ID(Person)|:END_ID(Tag)
dynamic/person_isLocatedIn_place: :START_ID(Person)|:END_ID(Place)
dynamic/person_knows_person: :START_ID(Person)|:END_ID(Person)|creationDate:LONG
dynamic/person_likes_comment: :START_ID(Person)|:END_ID(Comment)|creationDate:LONG
dynamic/person_likes_post: :START_ID(Person)|:END_ID(Post)|creationDate:LONG
dynamic/person_studyAt_organisation: :START_ID(Person)|:END_ID(Organisation)|classYear:INT
dynamic/person_workAt_organisation: :START_ID(Person)|:END_ID(Organisation)|workFrom:INT
dynamic/post_hasCreator_person: :START_ID(Post)|:END_ID(Person)
dynamic/comment_hasTag_tag: :START_ID(Comment)|:END_ID(Tag)
dynamic/post_hasTag_tag: :START_ID(Post)|:END_ID(Tag)
dynamic/post_isLocatedIn_place: :START_ID(Post)|:END_ID(Place)
Finished preprocessing CSV files
==========================================================================2=
scripts/stop-neo4j.sh: line 11: docker: command not found
No container neo4j-community-4.4.18 found
==========================================================================3=
==========================================================================4=
scripts/import-to-neo4j.sh: line 18: docker: command not found
[root@bogon scripts]# vim import-to-neo4j.sh
neo4j:${NEO4J_VERSION} \
neo4j-admin import \
--id-type=INTEGER \
--nodes=Place="/import/static/place${NEO4J_CSV_POSTFIX}" \
--nodes=Organisation="/import/static/organisation${NEO4J_CSV_POSTFIX}" \
--nodes=TagClass="/import/static/tagclass${NEO4J_CSV_POSTFIX}" \
--nodes=Tag="/import/static/tag${NEO4J_CSV_POSTFIX}" \
--nodes=Comment:Message="/import/dynamic/comment${NEO4J_CSV_POSTFIX}" \
--nodes=Forum="/import/dynamic/forum${NEO4J_CSV_POSTFIX}" \
--nodes=Person="/import/dynamic/person${NEO4J_CSV_POSTFIX}" \
--nodes=Post:Message="/import/dynamic/post${NEO4J_CSV_POSTFIX}" \
--relationships=IS_PART_OF="/import/static/place_isPartOf_place${NEO4J_CSV_POSTFIX}" \
--relationships=IS_SUBCLASS_OF="/import/static/tagclass_isSubclassOf_tagclass${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="/import/static/organisation_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TYPE="/import/static/tag_hasType_tagclass${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_CREATOR="/import/dynamic/comment_hasCreator_person${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="/import/dynamic/comment_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=REPLY_OF="/import/dynamic/comment_replyOf_comment${NEO4J_CSV_POSTFIX}" \
--relationships=REPLY_OF="/import/dynamic/comment_replyOf_post${NEO4J_CSV_POSTFIX}" \
--relationships=CONTAINER_OF="/import/dynamic/forum_containerOf_post${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_MEMBER="/import/dynamic/forum_hasMember_person${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_MODERATOR="/import/dynamic/forum_hasModerator_person${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TAG="/import/dynamic/forum_hasTag_tag${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_INTEREST="/import/dynamic/person_hasInterest_tag${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="/import/dynamic/person_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=KNOWS="/import/dynamic/person_knows_person${NEO4J_CSV_POSTFIX}" \
--relationships=LIKES="/import/dynamic/person_likes_comment${NEO4J_CSV_POSTFIX}" \
--relationships=LIKES="/import/dynamic/person_likes_post${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_CREATOR="/import/dynamic/post_hasCreator_person${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TAG="/import/dynamic/comment_hasTag_tag${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TAG="/import/dynamic/post_hasTag_tag${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="/import/dynamic/post_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=STUDY_AT="/import/dynamic/person_studyAt_organisation${NEO4J_CSV_POSTFIX}" \
--relationships=WORK_AT="/import/dynamic/person_workAt_organisation${NEO4J_CSV_POSTFIX}" \
--delimiter '|'
还是Docker的neo4j导入数据操作,我
看不懂转换生成的文件哪些是节点,哪些是关系
,但是这个脚本sh里面找到了,可惜他是Docker写的,这里为了能够使用,自己创建了import-to-neo4j-noDocker.sh
,里面直接用指定好路径,neo4j-admin import命令
导入数据。
[root@bogon scripts]# vim import-to-neo4j-noDocker.sh
${NEO4J_CONTAINER_ROOT}/bin/neo4j-admin import \
--id-type=INTEGER \
--nodes=Place="${NEO4J_CONTAINER_ROOT}/import/static/place${NEO4J_CSV_POSTFIX}" \
--nodes=Organisation="${NEO4J_CONTAINER_ROOT}/import/static/organisation${NEO4J_CSV_POSTFIX}" \
--nodes=TagClass="${NEO4J_CONTAINER_ROOT}/import/static/tagclass${NEO4J_CSV_POSTFIX}" \
--nodes=Tag="${NEO4J_CONTAINER_ROOT}/import/static/tag${NEO4J_CSV_POSTFIX}" \
--nodes=Comment:Message="${NEO4J_CONTAINER_ROOT}/import/dynamic/comment${NEO4J_CSV_POSTFIX}" \
--nodes=Forum="${NEO4J_CONTAINER_ROOT}/import/dynamic/forum${NEO4J_CSV_POSTFIX}" \
--nodes=Person="${NEO4J_CONTAINER_ROOT}/import/dynamic/person${NEO4J_CSV_POSTFIX}" \
--nodes=Post:Message="${NEO4J_CONTAINER_ROOT}/import/dynamic/post${NEO4J_CSV_POSTFIX}" \
--relationships=IS_PART_OF="${NEO4J_CONTAINER_ROOT}/import/static/place_isPartOf_place${NEO4J_CSV_POSTFIX}" \
--relationships=IS_SUBCLASS_OF="${NEO4J_CONTAINER_ROOT}/import/static/tagclass_isSubclassOf_tagclass${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="${NEO4J_CONTAINER_ROOT}/import/static/organisation_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TYPE="${NEO4J_CONTAINER_ROOT}/import/static/tag_hasType_tagclass${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_CREATOR="${NEO4J_CONTAINER_ROOT}/import/dynamic/comment_hasCreator_person${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="${NEO4J_CONTAINER_ROOT}/import/dynamic/comment_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=REPLY_OF="${NEO4J_CONTAINER_ROOT}/import/dynamic/comment_replyOf_comment${NEO4J_CSV_POSTFIX}" \
--relationships=REPLY_OF="${NEO4J_CONTAINER_ROOT}/import/dynamic/comment_replyOf_post${NEO4J_CSV_POSTFIX}" \
--relationships=CONTAINER_OF="${NEO4J_CONTAINER_ROOT}/import/dynamic/forum_containerOf_post${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_MEMBER="${NEO4J_CONTAINER_ROOT}/import/dynamic/forum_hasMember_person${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_MODERATOR="${NEO4J_CONTAINER_ROOT}/import/dynamic/forum_hasModerator_person${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TAG="${NEO4J_CONTAINER_ROOT}/import/dynamic/forum_hasTag_tag${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_INTEREST="${NEO4J_CONTAINER_ROOT}/import/dynamic/person_hasInterest_tag${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="${NEO4J_CONTAINER_ROOT}/import/dynamic/person_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=KNOWS="${NEO4J_CONTAINER_ROOT}/import/dynamic/person_knows_person${NEO4J_CSV_POSTFIX}" \
--relationships=LIKES="${NEO4J_CONTAINER_ROOT}/import/dynamic/person_likes_comment${NEO4J_CSV_POSTFIX}" \
--relationships=LIKES="${NEO4J_CONTAINER_ROOT}/import/dynamic/person_likes_post${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_CREATOR="${NEO4J_CONTAINER_ROOT}/import/dynamic/post_hasCreator_person${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TAG="${NEO4J_CONTAINER_ROOT}/import/dynamic/comment_hasTag_tag${NEO4J_CSV_POSTFIX}" \
--relationships=HAS_TAG="${NEO4J_CONTAINER_ROOT}/import/dynamic/post_hasTag_tag${NEO4J_CSV_POSTFIX}" \
--relationships=IS_LOCATED_IN="${NEO4J_CONTAINER_ROOT}/import/dynamic/post_isLocatedIn_place${NEO4J_CSV_POSTFIX}" \
--relationships=STUDY_AT="${NEO4J_CONTAINER_ROOT}/import/dynamic/person_studyAt_organisation${NEO4J_CSV_POSTFIX}" \
--relationships=WORK_AT="${NEO4J_CONTAINER_ROOT}/import/dynamic/person_workAt_organisation${NEO4J_CSV_POSTFIX}" \
--delimiter '|'
Type :quit<Enter> to exit Vim
1、将
待转换的csv文件放置在import文件夹
下
2、使用neo4j自带的shell命令neo4j-admin import
批量导入文件