wget https://oss-cdn.nebula-graph.com.cn/package/3.2.0/nebula-graph-3.2.0.el7.x86_64.rpm
/usr/local/nebula/rpm -ivh nebula-graph-3.2.0.el7.x86_64.rpm
--meta_server_addrs=ip1:9559,ip2:9559,ip3:9559
# Local IP used to identify the nebula-graphd process.
# Change it to an address other than loopback if the service is distributed or
# will be accessed remotely.
--local_ip=ip1
/usr/local/nebula/scripts/nebula.service start all
/usr/local/nebula/scripts/nebula.service status all

./nebula-console -addr ip1 -port 9669 -u root -p nebula
ADD HOSTS ip1:9779, ip2:9779, ip3:9779
SHOW HOSTS;
安装依赖
pip install nebula3-python==3.2.0
python连接示例参见:https://github.com/vesoft-inc/nebula-python/tree/release-3.1/example
nSQL的语法有点类似sql和cphyer的混合体,如果两方面都有基础的话,上手挺快的。
备份的使用限制蛮多的,只有全量备份,无法增量备份等,不过有比没有好。
git clone https://github.com/vesoft-inc/nebula-br.git
go env -w GOPROXY=https://goproxy.cn
cd /opt/145_graph/nebula-br
make
bin/br version

nebula graph的索引不用于查询加速,仅用于点和边的定位。
使用lookup和match查询语法之前必须创建索引。
通过listener插件可以将storage中存储的节点和边,同步到es引擎中。
但是基于es创建的全文索引,使用限制非常多,几乎没有实际应用价值。
但数据同步还是不错的,对于有es基础的用户而言,可以直接使用es本身的查询功能,更强大,而不必受限于nebula graph
SIGN IN TEXT SERVICE (ip:9200, HTTP);

cd /usr/local/nebula
./bin/nebula-storaged --flagfile /usr/local/nebula/etc/nebula-storaged-listener.conf

ADD LISTENER ELASTICSEARCH listener_ip:
下载nebula import工具:https://github.com/vesoft-inc/nebula-importer/releases/tag/v3.2.0
编写yaml文件,执行命令:./nebula-importer --config nodes_config.yaml
version: v3
description: zh
removeTempFiles: false
clientSettings:
retry: 3
concurrency: 10
channelBufferSize: 128
space: zh
connection:
user: root
password: nebula
address: IP1:9669,IP2:9669,IP3:9669
logPath: ./test.log
files:
1. path: ./test-node.csv
failDataPath: ./nodes-err.csv
batchSize: 128
inOrder: false
type: csv
csv:
withHeader: true
withLabel: false
delimiter: ","
schema:
type: vertex
个人比较喜欢使用带header的CSV文件,csv文件样式如下。这里简单比较一下nebula import和neo4j import的区别:
nebula csv文件

neo4j csv文件,id不用写在csv文件中,neo4j导入一个节点会赋一个自增的id

nebula中似乎没有删除节点这一概念,只能删除某一id的节点的tag和相应的属性,但id本身不会被删除。
如果希望删除某一tag的所有节点,需要写一个脚本,match (v:tag) return id(v) ,然后根据获取的v逐个删除。
DELETE TAG * FROM '1';

为了测试nebula的性能,采用其官方的压测工具进行。参考文档:https://github.com/vesoft-inc/nebula-bench/blob/release-1.2/README_cn.md
wget https://dl.google.com/go/go1.18.3.linux-amd64.tar.gz
tar -C /usr/local/ -zxvf go1.18.3.linux-amd64.tar.gz
sed -i '$aexport GOROOT=/usr/local/go\nexport PATH=$PATH:$GOROOT/bin' /etc/profile
source /etc/profile
go version
# go get 的包下载不下来,需要设置 golang 代理
export GOPROXY=https://goproxy.cn
sudo yum install -y git \
make \
file \
libev \
libev-devel \
gcc \
wget \
python3 \
python3-devel \
java-1.8.0-openjdk \
maven
# nebula bench工具
git clone https://github.com/vesoft-inc/nebula-bench.git
# 安装nebula-bench的依赖包
pip3 install --user -r requirements.txt
# 下载k6插件,nebula-import,go的环境
# 如果上述环境已经有了,就不会重复下载了
# 在Linux上运行时,记得将scripts下的sh文件转为LF格式,否则可能出错等
/bin/bash scripts/setup.sh
# k6插件
# 如果git下载不下来,可以去网页手动下载
git clone https://github.com/vesoft-inc/k6-plugin
python3 run.py data
python3 run.py nebula importer -a 127.0.0.1:9669

6. 测试
# 一跳
python3 run.py stress run -scenario go.Go1Step --args='-u 10 -d 1s'
# 二跳
python3 run.py stress run -scenario go.Go2Step --args='-u 10 -d 1s'