Nebula 实践报告

实践报告

安装及部署

使用源码安装 Nebula Graph
## 安装依赖的包
[eric.fang@eric ~]$ sudo yum install -y make m4 git wget unzip sz readline-devel ncurses-devel zlib-devel gcc gcc-c++ cmake gett4ext curl redhat-lsb-core bzip2

## gcc 和 cmake 版本不符合要求
[eric.fang@eric ~]$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright © 2015 Free Software Foundation, Inc.
[eric.fang@eric ~]$ cmake --version
cmake version 2.8.12.2

## 通过 nebula-common 安装符合要求的 gcc 和 cmake 版本
[eric.fang@eric ~]$ git clone --branch v2.0.1 https://github.com/vesoft-inc/nebula-common.git
[eric.fang@eric ~]$ cd nebula-common && ./third-party/install-cmake.sh cmake-install
[eric.fang@eric ~]$ source cmake-install/bin/enable-cmake.sh
[eric.fang@eric nebula-common]$ cmake --version
cmake version 3.15.5
[eric.fang@eric nebula-common]$ sudo mkdir /opt/vesoft && sudo chmod -R a+w /opt/vesoft
[eric.fang@eric nebula-common]$ sudo ./third-party/install-gcc.sh --prefix=/opt
[eric.fang@eric nebula-common]$ source /opt/vesoft/toolset/gcc/7.5.0/enable
[eric.fang@eric nebula-common]$ gcc --version
gcc (Nebula Graph Build) 7.5.0
[eric.fang@eric nebula-common]$ ./third-party/install-third-party.sh

## 编译源码
[eric.fang@eric ~]$ git clone --branch v2.0.1 https://github.com/vesoft-inc/nebula-graph.git
[eric.fang@eric build]$ cd nebula-graph && mkdir build && cd build && pwd
/home/eric.fang/nebula-graph/build
[eric.fang@eric build]$ cmake -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DNEBULA_COMMON_REPO_TAG=v2.0.1 -DNEBULA_STORAGE_REPO_TAG=v2.0.1 ..
...
>>>> Configuring Nebula Storage done <<<<
-- Configuring done
-- Generating done
-- Build files have been written to: /home/eric.fang/nebula-graph/build
[eric.fang@eric build]$ make -j2
...
Scanning dependencies of target nebula-graphd
[100%] Building CXX object src/daemons/CMakeFiles/nebula-graphd.dir/GraphDaemon.cpp.o
[100%] Linking CXX executable ../../bin/nebula-graphd
[100%] Built target nebula-graphd
[eric.fang@eric build]$ sudo make install-all
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/nebula/bin/nebula-graphd
-- Installing: /usr/local/nebula/etc/nebula-graphd.conf.default
-- Installing: /usr/local/nebula/etc/nebula-graphd.conf.production
-- Installing: /usr/local/nebula/share/resources/gflags.json
-- Installing: /usr/local/nebula/share/resources/date_time_zonespec.csv
-- Installing: /usr/local/nebula/scripts/nebula-graphd.service
-- Installing: /usr/local/nebula/scripts/nebula.service
-- Installing: /usr/local/nebula/scripts/utils.sh
Built target install-all

## 启动服务
## 先配置 nebula-graphd.conf,nebula-metad.conf,nebula-storaged.conf
[eric.fang@eric nebula-graph]$ sudo /usr/local/nebula/scripts/nebula.service start all
[INFO] Starting nebula-metad...
[INFO] Done
[INFO] Starting nebula-graphd...
[INFO] Done
[INFO] Starting nebula-storaged...
[INFO] Done
[eric.fang@eric nebula-graph]$ sudo /usr/local/nebula/scripts/nebula.service status all
[INFO] nebula-metad: Running as 11225, Listening on 9559
[INFO] nebula-graphd: Running as 11296, Listening on 9669
[INFO] nebula-storaged: Running as 11331, Listening on 9779
使用 Docker Compose 部署
## 安装 docker 并启动服务
[eric.fang@eric ~]$ docker --version
Docker version 20.10.8, build 3967b7d
[eric.fang@eric ~]$ docker-compose --version
docker-compose version 1.29.2, build 5becea4c

## clone并启动服务
[eric.fang@eric ~]$ git clone -b master https://github.com/vesoft-inc/nebula-docker-compose.git
[eric.fang@eric ~]$ cd nebula-docker-compose/
[eric.fang@eric nebula-docker-compose]$ docker-compose up -d
Creating network "nebula-docker-compose_nebula-net" with the default driver
Pulling metad0 (vesoft/nebula-metad:v2-nightly)...
ERROR: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit

## 解决 docker hub pull rate limit
## docker hub 官网注册一个账号
## docker login --username ericfang --password password
[eric.fang@eric nebula-docker-compose]$ docker-compose up -d
...
Creating nebula-docker-compose_metad1_1 ... done
Creating nebula-docker-compose_metad0_1 ... done
Creating nebula-docker-compose_metad2_1 ... done
Creating nebula-docker-compose_storaged1_1 ... done
Creating nebula-docker-compose_storaged0_1 ... done
Creating nebula-docker-compose_storaged2_1 ... done
Creating nebula-docker-compose_graphd2_1   ... done
Creating nebula-docker-compose_graphd_1    ... done
Creating nebula-docker-compose_graphd1_1   ... done
[eric.fang@eric nebula-docker-compose]$ docker-compose ps
              Name                             Command                  State                                                                                      Ports
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
nebula-docker-compose_graphd1_1     /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49177->19669/tcp,:::49177->19669/tcp, 0.0.0.0:49176->19670/tcp,:::49176->19670/tcp, 0.0.0.0:49178->9669/tcp,:::49178->9669/tcp
nebula-docker-compose_graphd2_1     /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49174->19669/tcp,:::49174->19669/tcp, 0.0.0.0:49173->19670/tcp,:::49173->19670/tcp, 0.0.0.0:49175->9669/tcp,:::49175->9669/tcp
nebula-docker-compose_graphd_1      /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49172->19669/tcp,:::49172->19669/tcp, 0.0.0.0:49171->19670/tcp,:::49171->19670/tcp, 0.0.0.0:9669->9669/tcp,:::9669->9669/tcp
nebula-docker-compose_metad0_1      /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49160->19559/tcp,:::49160->19559/tcp, 0.0.0.0:49159->19560/tcp,:::49159->19560/tcp, 0.0.0.0:49161->9559/tcp,:::49161->9559/tcp, 9560/tcp
nebula-docker-compose_metad1_1      /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49154->19559/tcp,:::49154->19559/tcp, 0.0.0.0:49153->19560/tcp,:::49153->19560/tcp, 0.0.0.0:49155->9559/tcp,:::49155->9559/tcp, 9560/tcp
nebula-docker-compose_metad2_1      /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49157->19559/tcp,:::49157->19559/tcp, 0.0.0.0:49156->19560/tcp,:::49156->19560/tcp, 0.0.0.0:49158->9559/tcp,:::49158->9559/tcp, 9560/tcp
nebula-docker-compose_storaged0_1   /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49166->19779/tcp,:::49166->19779/tcp, 0.0.0.0:49165->19780/tcp,:::49165->19780/tcp, 9777/tcp, 9778/tcp, 0.0.0.0:49167->9779/tcp,:::49167->9779/tcp, 9780/tcp
nebula-docker-compose_storaged1_1   /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49163->19779/tcp,:::49163->19779/tcp, 0.0.0.0:49162->19780/tcp,:::49162->19780/tcp, 9777/tcp, 9778/tcp, 0.0.0.0:49164->9779/tcp,:::49164->9779/tcp, 9780/tcp
nebula-docker-compose_storaged2_1   /usr/local/nebula/bin/nebu ...   Up (healthy)   0.0.0.0:49169->19779/tcp,:::49169->19779/tcp, 0.0.0.0:49168->19780/tcp,:::49168->19780/tcp, 9777/tcp, 9778/tcp, 0.0.0.0:49170->9779/tcp,:::49170->9779/tcp, 9780/tcp
部署可视化工具
## 部署 studio
[eric.fang@eric ~]$ cd nebula-graph-studio-v2
[eric.fang@eric nebula-graph-studio-v2]$ ls
docker-compose.yml  example  nginx  uploads
[eric.fang@eric nebula-graph-studio-v2]$ docker-compose pull
Pulling client   ... done
Pulling web      ... done
Pulling importer ... done
Pulling nginx    ... done
[eric.fang@eric nebula-graph-studio-v2]$ docker-compose up -d
Creating network "nebula-graph-studio-v2_nebula-web" with the default driver
Creating nebula-graph-studio-v2_importer_1 ... done
Creating nebula-graph-studio-v2_client_1   ... done
Creating nebula-graph-studio-v2_web_1      ... done
Creating nebula-graph-studio-v2_nginx_1    ... done
[eric.fang@eric nebula-graph-studio-v2]$ docker-compose ps
              Name                             Command               State                        Ports
-----------------------------------------------------------------------------------------------------------------------------
nebula-graph-studio-v2_client_1     ./nebula-http-gateway            Up      0.0.0.0:49205->8080/tcp,:::49205->8080/tcp
nebula-graph-studio-v2_importer_1   nebula-importer --port=569 ...   Up      0.0.0.0:49206->5699/tcp,:::49206->5699/tcp
nebula-graph-studio-v2_nginx_1      /docker-entrypoint.sh ngin ...   Up      0.0.0.0:7001->7001/tcp,:::7001->7001/tcp, 80/tcp
nebula-graph-studio-v2_web_1        docker-entrypoint.sh npm r ...   Up      0.0.0.0:49207->7001/tcp,:::49207->7001/tcp

连接并使用

## 连接 docker compose 部署的集群
[eric.fang@eric ~]$ docker run --rm -ti --network nebula-docker-compose_nebula-net --entrypoint=/bin/sh vesoft/nebula-console:v2-nightly
v2-nightly: Pulling from vesoft/nebula-console
5843afab3874: Pull complete
20f815313dee: Pull complete
17901d916fce: Pull complete
Digest: sha256:2e17edd11022e64e01a789a6f9d38737d5b81b91108b87581ee5d8a3047fd445
Status: Downloaded newer image for vesoft/nebula-console:v2-nightly

/ # nebula-console -u root -p nebula --address=graphd --port=9669
2021/08/09 08:52:01 [INFO] connection pool is initialized successfully

Welcome to Nebula Graph!

(root@nebula) [(none)]> show hosts
+-------------+------+----------+--------------+----------------------+------------------------+
| Host        | Port | Status   | Leader count | Leader distribution  | Partition distribution |
+-------------+------+----------+--------------+----------------------+------------------------+
| "storaged0" | 9779 | "ONLINE" | 0            | "No valid partition" | "No valid partition"   |
+-------------+------+----------+--------------+----------------------+------------------------+
| "storaged1" | 9779 | "ONLINE" | 0            | "No valid partition" | "No valid partition"   |
+-------------+------+----------+--------------+----------------------+------------------------+
| "storaged2" | 9779 | "ONLINE" | 0            | "No valid partition" | "No valid partition"   |
+-------------+------+----------+--------------+----------------------+------------------------+
| "Total"     |      |          | 0            |                      |                        |
+-------------+------+----------+--------------+----------------------+------------------------+
Got 4 rows (time spent 2480/3253 us)

Mon, 09 Aug 2021 08:52:32 UTC

## 创建 space
(root@nebula) [(none)]> create space my_space(partition_num=15, replica_factor=1, vid_type=int64)
(root@nebula) [(none)]> show spaces
+------------+
| Name       |
+------------+
| "my_space" |
+------------+
(root@nebula) [(none)]> use my_space

## 创建 tag 和 edge
(root@nebula) [my_space]> create tag t_user(uid string)
Execution succeeded (time spent 5646/6068 us)
(root@nebula) [my_space]> create tag t_mobile(dt string, mobile fixed_string(11))
(root@nebula) [my_space]> create tag t_app(did string)
(root@nebula) [my_space]> create edge e_register()
Execution succeeded (time spent 5420/5809 us)
(root@nebula) [my_space]> create edge e_use()

## 插入点和边
(root@nebula) [my_space]> insert vertex t_user(uid) values 1001:("1001")
Execution succeeded (time spent 3634/4146 us)
(root@nebula) [my_space]> insert vertex t_mobile(dt, mobile) values 13120930000:("2021-08-08", "13120930000")
(root@nebula) [my_space]> insert vertex t_app(did) values 2001:("d2001")
(root@nebula) [my_space]> insert edge e_register() values 1001->13120930000:()
(root@nebula) [my_space]> insert edge e_use() values 13120930000->2001:()
(root@nebula) [my_space]> show stats
+---------+--------------+-------+
| Type    | Name         | Count |
+---------+--------------+-------+
| "Tag"   | "t_app"      | 1     |
+---------+--------------+-------+
| "Tag"   | "t_mobile"   | 1     |
+---------+--------------+-------+
| "Tag"   | "t_user"     | 1     |
+---------+--------------+-------+
| "Edge"  | "e_register" | 1     |
+---------+--------------+-------+
| "Edge"  | "e_use"      | 1     |
+---------+--------------+-------+
| "Space" | "vertices"   | 3     |
+---------+--------------+-------+
| "Space" | "edges"      | 2     |
+---------+--------------+-------+
Got 7 rows (time spent 1152/1613 us)

## 创建索引
(root@nebula) [my_space]> create tag index t_user_index on t_user(uid(4))
Execution succeeded (time spent 10619/11005 us)
(root@nebula) [my_space]> create edge index e_register_index on e_register()
(root@nebula) [my_space]> rebuild tag index t_user_index
+------------+
| New Job Id |
+------------+
| 12         |
+------------+
Got 1 rows (time spent 3657/4070 us)

Mon, 09 Aug 2021 09:10:15 UTC

(root@nebula) [my_space]> rebuild edge index e_register_index
+------------+
| New Job Id |
+------------+
| 13         |
+------------+
Got 1 rows (time spent 4196/4620 us)

Mon, 09 Aug 2021 09:10:25 UTC

## 通用查询
(root@nebula) [my_space]> fetch prop on t_user 1001
+-----------------------------+
| vertices_                   |
+-----------------------------+
| (1001 :t_user{uid: "1001"}) |
+-----------------------------+
(root@nebula) [my_space]> lookup on t_user where t_user.uid == "1001"
+----------+
| VertexID |
+----------+
| 1001     |
+----------+
Got 1 rows (time spent 2539/3015 us)
(root@nebula) [my_space]> match (u:t_user{uid:'1001'}) -[e1:e_register]->(v1)-->(v2)<--(v3)   RETURN v3;
+------------------------------------------------------------------+
| v3                                                               |
+------------------------------------------------------------------+
| (13120930000 :t_mobile{dt: "2021-08-08", mobile: "13120930000"}) |
+------------------------------------------------------------------+
| (13120930000 :t_mobile{dt: "2021-08-08", mobile: "13120930000"}) |
+------------------------------------------------------------------+
Got 2 rows (time spent 7462/8342 us)

导入数据

导入 basketballplayer 数据
## 导入 basketballplayer 数据
## 下载 nebula console 和数据文件
vesoft@localhost:~> ls
basketballplayer-2.X.ngql  bin  nebula-console  nebula-graph

## 导入数据
vesoft@localhost:~> ./nebula-console -u root --password nebula --port 9669 -f basketballplayer-2.X.ngql
...
(root@nebula) [basketballplayer]> insert edge serve(start_year,end_year) values "player150"->"team213":(2018, 2019);
Execution succeeded (time spent 302/421 us)

Tue, 10 Aug 2021 10:51:52 CST

## 查询导入的数据量
(root@nebula) [basketballplayer]> show stats
+---------+------------+-------+
| Type    | Name       | Count |
+---------+------------+-------+
| "Tag"   | "player"   | 51    |
+---------+------------+-------+
| "Tag"   | "team"     | 30    |
+---------+------------+-------+
| "Edge"  | "follow"   | 81    |
+---------+------------+-------+
| "Edge"  | "serve"    | 152   |
+---------+------------+-------+
| "Space" | "vertices" | 81    |
+---------+------------+-------+
| "Space" | "edges"    | 233   |
+---------+------------+-------+
Got 6 rows (time spent 681/1080 us)

Tue, 10 Aug 2021 10:55:00 CST
导入 LDBC 数据
## 安装 nebula-bench
vesoft@localhost:~> git clone https://github.com/vesoft-inc/nebula-bench
vesoft@localhost:~> ls
basketballplayer-2.X.ngql  bin  nebula-bench  nebula-console  nebula-graph
vesoft@localhost:~> cd nebula-bench/
vesoft@localhost:~/nebula-bench> bash scripts/setup.sh
...
2021/08/10 11:02:40 [INFO] exec (timeout=0s): /usr/bin/go get -d -v go.k6.io/k6
go: downloading go.k6.io/k6 v0.33.0
...
2021/08/10 11:07:04 [INFO] exec (timeout=0s): /usr/bin/go build -o /home/vesoft/nebula-bench/temp/xk6-nebula/k6 -ldflags -w -s -trimpath
2021/08/10 11:07:08 [INFO] Build complete: ./k6
2021/08/10 11:07:08 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-08-10-1102.100844574
Finish

## 生成 LDBC 数据
vesoft@localhost:~/nebula-bench> python3 run.py data  -s 1
...
merge data: organisation_0_0.csv
merge data: organisation_isLocatedIn_place_0_0.csv
merge data: place_0_0.csv
merge data: place_isPartOf_place_0_0.csv
merge data: tag_0_0.csv
merge data: tagclass_0_0.csv
merge data: tagclass_isSubclassOf_tagclass_0_0.csv
merge data: tag_hasType_tagclass_0_0.csv
Finish

## 导入 LDBC 数据
vesoft@localhost:~/nebula-bench> python3 run.py nebula importer -a 127.0.0.1:9669
...
### 无法创建 space
2021/08/10 11:25:57 Client(0) fails to execute commands (CREATE SPACE IF NOT EXISTS stress_test_0810(PARTITION_NUM = 24, REPLICA_FACTOR = 3, vid_type = int64);
...

## 查看错误日志
vesoft@localhost:/usr/local/nebula/logs> pwd
/usr/local/nebula/logs
vesoft@localhost:/usr/local/nebula/logs> tail -2 nebula-metad.ERROR
E0810 11:25:56.657224 19961 CreateSpaceProcessor.cpp:228] Not enough hosts existed for replica 3, hosts num 1
E0810 11:25:56.698678 19961 CreateSpaceProcessor.cpp:228] Not enough hosts existed for replica 3, hosts num 1
### 原因是 replica 参数配置不正确

## 手动创建 space stress_test_0810
(root@nebula) [(none)]> CREATE SPACE IF NOT EXISTS stress_test_0810(PARTITION_NUM = 5, REPLICA_FACTOR = 1, vid_type = int64)
Execution succeeded (time spent 1520/2013 us)

Tue, 10 Aug 2021 11:33:40 CST

(root@nebula) [(none)]> show spaces
+--------------------+
| Name               |
+--------------------+
| "basketballplayer" |
+--------------------+
| "stress_test_0810" |
+--------------------+
Got 2 rows (time spent 717/1217 us)

## 重新导入数据
vesoft@localhost:~/nebula-bench> python3 run.py nebula importer -a 127.0.0.1:9669
...
begin space compact
2021-08-10 11:36:47.000866 - INFO controller.py [line:60] succeeded job <SUBMIT JOB COMPACT>, job id is <35>
[2021-08-10 11:36:47,866]:succeeded job <SUBMIT JOB COMPACT>, job id is <35>
end space compact
...

## 统计导入的数据
(root@nebula) [stress_test_0810]> show stats
+---------+------------------+----------+
| Type    | Name             | Count    |
+---------+------------------+----------+
| "Tag"   | "Comment"        | 2052169  |
+---------+------------------+----------+
| "Tag"   | "Forum"          | 90492    |
+---------+------------------+----------+
| "Tag"   | "Organisation"   | 7955     |
+---------+------------------+----------+
| "Tag"   | "Person"         | 9892     |
+---------+------------------+----------+
...

查询 LDBC 数据(Interactive short)

## Interactive / short / 1
(root@nebula) [stress_test_0810]> match (p:Person)-[:IS_LOCATED_IN]->(c:Place) where id(p) == 2199023261211 return p.firstName as firstName, p.lastName as lastName, p.birthday as birthday, p.locationIP as locationIP, p.browserUsed as browserUsed, id(c) as placeId, p.gender as gender, p.creationDate as creationDate
+-----------+----------+--------------+---------------+---------------------+---------+--------+--------------------------------+
| firstName | lastName | birthday     | locationIP    | browserUsed         | placeId | gender | creationDate                   |
+-----------+----------+--------------+---------------+---------------------+---------+--------+--------------------------------+
| "Jack"    | "Smith"  | "1981-04-19" | "24.212.6.75" | "Internet Explorer" | 1027    | "male" | "2010-04-25T05:45:11.772+0000" |
+-----------+----------+--------------+---------------+---------------------+---------+--------+--------------------------------+
Got 1 rows (time spent 2169/2536 us)

## Interactive / short / 2 
(root@nebula) [sf100]> match (p1:Person)<-[:HAS_CREATOR]-(c:`Comment`)-[:REPLY_OF*..5]->(t:Post)-[:HAS_CREATOR]->(p2) where id(p1) == 21990232560886 return id(c) as commentId, left(c.content, 20) as commentContent, c.creationDate as commentCreationDate, id(t) as postId, id(p2) as originalPosterId, p2.firstName as originalPosterFirstName, p2.lastName as originalPosterLastName order by commentCreationDate desc, commentId desc limit 10
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| commentId      | commentContent         | commentCreationDate            | postId         | originalPosterId | originalPosterFirstName | originalPosterLastName |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 70369064648362 | "maybe"                | "2012-09-10T20:31:33.977+0000" | 70369064648356 | 24189256066941   | "K."                    | "Singh"                |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 70369129009310 | "roflol"               | "2012-09-09T22:59:24.695+0000" | 70369129009307 | 19791209538106   | "Zhi"                   | "Zhang"                |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65970858157842 | "duh"                  | "2012-09-05T01:28:06.842+0000" | 65970858157831 | 19791209360454   | "Lin"                   | "Yang"                 |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65970992843311 | "About 50 Cent, , Jad" | "2012-09-04T09:36:49.852+0000" | 65970992843302 | 10995116511261   | "Lei"                   | "Zhu"                  |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65971013172256 | "no"                   | "2012-09-02T07:46:29.260+0000" | 65971013172254 | 19791209557626   | "Jun"                   | "Zhou"                 |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65971050436500 | "About Jorge Luis Bor" | "2012-08-30T20:20:39.281+0000" | 65971050436494 | 17592186437103   | "Lin"                   | "Zhang"                |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65971042146666 | "thanks"               | "2012-08-18T15:05:50.401+0000" | 65971042146659 | 17592186453672   | "Jun"                   | "Li"                   |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65970815644358 | "thanks"               | "2012-08-18T11:47:31.383+0000" | 65970815644349 | 19791209356012   | "Wei"                   | "Zhang"                |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65971033797639 | "About Elizabeth I of" | "2012-08-18T09:04:14.979+0000" | 65971033797635 | 19791209495181   | "Lin"                   | "Chen"                 |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
| 65970815644355 | "thx"                  | "2012-08-17T21:47:35.677+0000" | 65970815644349 | 19791209356012   | "Wei"                   | "Zhang"                |
+----------------+------------------------+--------------------------------+----------------+------------------+-------------------------+------------------------+
Got 10 rows (time spent 110471/111613 us)

## Interactive / short / 3
(root@nebula) [sf100]> match (p1:Person)-[k:KNOWS]-(p2:Person) where id(p1) == 4398046751146 return id(p2) as friendId, p2.firstName as friendFirstName, p2.lastName as friendLastName, k.creationDate as creationDate order by creationDate desc, friendId asc
+----------------+-----------------+----------------+--------------------------------+
| friendId       | friendFirstName | friendLastName | creationDate                   |
+----------------+-----------------+----------------+--------------------------------+
| 30786326053219 | "Andrei"        | "Popescu"      | "2012-06-02T21:01:43.925+0000" |
+----------------+-----------------+----------------+--------------------------------+
| 28587302532005 | "Nikki"         | "Cruz"         | "2012-06-01T19:07:17.709+0000" |
+----------------+-----------------+----------------+--------------------------------+
| 26388279524054 | "Mihai"         | "Popescu"      | "2012-03-12T14:29:13.225+0000" |
+----------------+-----------------+----------------+--------------------------------+ 
...
Got 25 rows (time spent 11467/12590 us)

## Interactive / short / 4
(root@nebula) [stress_test_0810]> fetch prop on `Comment` 2061584302088 yield `Comment`.creationDate as commentCreationDate, `Comment`.content as commentContent
+---------------+--------------------------------+----------------+
| VertexID      | commentCreationDate            | commentContent |
+---------------+--------------------------------+----------------+
| 2061584302088 | "2012-07-20T17:35:11.096+0000" | "right"        |
+---------------+--------------------------------+----------------+
Got 1 rows (time spent 1045/1473 us)

## Interactive / short / 5
(root@nebula) [sf100]> go from 52776558133277 over HAS_CREATOR yield HAS_CREATOR._dst as personId, $$.Person.firstName, $$.Person.lastName
+----------------+---------------------+--------------------+
| personId       | $$.Person.firstName | $$.Person.lastName |
+----------------+---------------------+--------------------+
| 10995116704903 | "Batong"            | "Ha"               |
+----------------+---------------------+--------------------+
Got 1 rows (time spent 19270/26045 us)

## Interactive / short / 6
(root@nebula) [stress_test_0810]> match (c:`Comment`)-[:REPLY_OF]->(:Post)<-[:CONTAINER_OF]-(f:Forum)-[:HAS_MODERATOR]->(p:Person) where id(c) == 1649267441693 return id(f) as forumId, f.title as forumTitle, id(p) as moderatorId, p.firstName as moderatorFirstName, p.lastName as moderatorLastName
+---------+--------------------------+-------------+--------------------+-------------------+
| forumId | forumTitle               | moderatorId | moderatorFirstName | moderatorLastName |
+---------+--------------------------+-------------+--------------------+-------------------+
| 0       | "Wall of Mahinda Perera" | 933         | "Mahinda"          | "Perera"          |
+---------+--------------------------+-------------+--------------------+-------------------+
Got 1 rows (time spent 4385/4928 us)

## 给两个人的id,判断两个人是否认识,如果认识是通过哪些人认识的。比如A →  B → C → D,那A和D就是认识的
(root@nebula) [stress_test_0810]> find shortest path from 6597069770517 to 32985348837706 over KNOWS
+-----------------------------------------------------------------------------------+
| path                                                                              |
+-----------------------------------------------------------------------------------+
| <(6597069770517)-[:KNOWS@0 {}]->(10995116284808)-[:KNOWS@0 {}]->(32985348837706)> |
+-----------------------------------------------------------------------------------+
Got 1 rows (time spent 1296/1689 us)

K6 压测

压测环境

施压机:192.168.1.2

Nebula集群:192.168.1.3、192.168.1.4、192.168.1.5,各部署一个 meta、graph、storage服务

部署监控

在 192.168.1.2 上部署 Promethues 和 node-exporter

## Promethues 的配置
scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["192.168.1.2:9090"]

  - job_name: "node"
    scrape_interval: 8s
    static_configs:
      - targets:
        - 192.168.1.3:9100
        - 192.168.1.3:9256
        - 192.168.1.4:9100
        - 192.168.1.4:9256
        - 192.168.1.5:9100
        - 192.168.1.5:9256

## docker compose启动prometheus
[vesoft@vesoft-192-168-1-2 promethues]$ docker-compose ps
         Name                        Command               State                                         Ports
-----------------------------------------------------------------------------------------------------------------------------------------------------
influxdb                  /entrypoint.sh influxd           Up      0.0.0.0:8083->8083/tcp,:::8083->8083/tcp, 0.0.0.0:8086->8086/tcp,:::8086->8086/tcp
promethues_grafana_1      /run.sh                          Up      0.0.0.0:3000->3000/tcp,:::3000->3000/tcp
promethues_prometheus_1   /bin/prometheus --config.f ...   Up      0.0.0.0:9090->9090/tcp,:::9090->9090/tcp
[vesoft@vesoft-192-168-1-2 promethues]$ pwd
/home/vesoft/promethues

在Nebula集群各节点启动 node-exporter

## 启动docker服务
[vesoft@vesoft-192-168-1-3 exporter]$ sudo systemctl start docker
[vesoft@vesoft-192-168-1-3 exporter]$ ps -ef | grep docker
root     123987      1 10 16:09 ?        00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
vesoft   124130 123894  0 16:09 pts/0    00:00:00 grep --color=auto docker
## 启动 exporter
[vesoft@vesoft-192-168-1-3 exporter]$ docker-compose up -d
Pulling node-exporter (prom/node-exporter:)...
latest: Pulling from prom/node-exporter
aa2a8d90b84c: Pull complete
b45d31ee2d7f: Pull complete
6c8262c5af55: Pull complete
Digest: sha256:a990408ed288669bbad5b5b374fe1584e54825cde4a911c1a3d6301a907a030c
Status: Downloaded newer image for prom/node-exporter:latest
Pulling process-exporter (ncabatoff/process-exporter:)...
latest: Pulling from ncabatoff/process-exporter
42f023458199: Pull complete
Digest: sha256:322c1c1284b2bc3011c660ca53f35aacb4544ea1ed5cd2a2d12d143c889b7106
Status: Downloaded newer image for ncabatoff/process-exporter:latest
Creating exporter_process-exporter_1 ... done
Creating exporter_node-exporter_1    ... done
[vesoft@vesoft-192-168-1-3 exporter]$ docker-compose ps
           Name                          Command               State   Ports
----------------------------------------------------------------------------
exporter_node-exporter_1      /bin/node_exporter --path. ...   Up
exporter_process-exporter_1   /bin/process-exporter --pr ...   Up
执行压测

具体使用 nebula-bench 文档参见 https://github.com/vesoft-inc/nebula-bench/blob/master/README_cn.md

5 个赞