GBCA (Galaxybase) 认证学习资料内参

GBCA (Galaxybase) 认证学习资料内参

严少安 Lv.6

创邻科技 Galaxybase 图数据库

Galaxybase是中国自主知识产权的通用商业化分布式图数据库,目前世界最快、延展性最好,性能超美国同类竞品百倍。Galaxybase改变了传统数据存储的方式,以一种更为灵活的基于“对象”和其间“关系”的图数据结构,将分散的不同种类的原始数据连接在一起形成一个关系网络,打通数据孤岛,通过自然语言处理、机器学习、图挖掘等人工智能算法,提供用户从关系角度分析问题的能力,帮助其完成实时决策。

Galaxybase 图数据库认证专员(GBCA)

Galaxybase 图数据库认证专员(GBCA)是创邻科技 Galaxybase 培训体系初级认证课程。未来将持续推出 Galaxybase 图数据库认证专家(GBCP)和认证大师(GBCM)的中高级进阶课程,该认证体系凝聚了图数据库王牌厂商创邻科技近十年实践经验,致力于帮助企业和个人更轻松、更快速、更深入地学习系统的图数据库理论知识和实操方法,全面掌握面向关联复杂、变化迅速、查询频繁场景的图技术处理方案,实现企业从“数据管理”到“数据驱动”的关键数字化转型。

1.png 图 -- 新鲜出炉的 GBCA 证书

数据库基础概念

  • 数据模型 Data Model

数据模型是用于描述数据库中数据结构的描述。

A data model is collection of concepts for describing the data in a database,A description of how the data is structured.
—— Professor Andy Pavlo, Carnegie Mellon, University

按模型可分为关系模型,图模型,键值模型,文档模型,宽列模型。

  • 图的定义

图是由若干给定的顶点及连接两顶点的边所构成的图形
图通常用来描述某些事物之间的某种特定关系
顶点用于代表事物,连接两顶点的边则用于表示两个事物间具有某种关系。

  • 图数据库的定义

以点、边为基础存储单元,以高效存储、查询图数据为第一设计原理的数据管理系统。

2.png 图1 - 墨天轮图数据库排行榜 Top 10
  • 属性图

属性图模型由顶点、边及其属性构成。顶点和边都可以带有属性,节点可以通过“标签(Label)”进行分组。表示关系的边总是从一个开始点指向一个结束点,而且边是一定是有方向的,这使得图成为了有向图。关系上的属性可以为节点的关系提供额外的元数据和语义。是业界最通用的图模型。

图数据库的特性

图数据库按存储架构可分为非原生图数据库,原生图数据库。

  • 非原生图数据库
  1. 关系型数据库缺少关系数据,只有在建模阶段作为连接表的手段
  2. 关系型数据库无法对关系进行语义区分,以及定义权重
  3. 关联查询代价昂贵
  • 原生图数据库
  1. 图数据库把关系作为数据的一部分进行存储
  2. 图数据库可以对关系进行语义区分,定义权重
  3. 高效查询复杂关系

图数据库的应用场景

图数据库的应用场景广泛,数据库规模大,关联跳数深,实时要求高的场景都适合使用图数据库。
比如:社交网络,金融,零售,电力,电信,政企,制造,网络安全等。

Galaxybase 单机版部署环境

  1. centos 7+
  2. docker 17+

galaxybase可以在centos7进行安装,并需要安装docker17以上的版本。

常用端口

  1. 图集群管理端口: 51314
  2. 图可视化端口: 8888
  3. 图查询API端口: 7687

安装步骤

  • 下载安装包

从官网[1]下载最新单机版(galaxybase-standalone-20220721170804.tar.gz)。

  • 解压安装包

将安装包上传至服务器并解压:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ tar -xf galaxybase-standalone-20220721170804.tar.gz

$ ls
galaxybase-20220721170804 galaxybase-standalone-20220721170804.tar.gz

$ du -sh galaxybase-20220721170804/
601M galaxybase-20220721170804/

$ tree .
.
├── bin
│ ├── galaxybase-deploy
│ ├── galaxybase-export
│ └── galaxybase-load
├── docker
│ └── docker-linux.tgz
└── images
└── images.wim

3 directories, 5 files
  • 环境变量

添加环境变量:

1
2
3
4
5
vi ~/.bashrc
export GALAXYBASE_HOME=/data/gbca/galaxybase-20220721170804
export PATH=$PATH:$GALAXYBASE_HOME/bin

source ~/.bashrc

验证全局变量是否生效:

1
2
3
4
5
$ galaxybase-deploy version
Server: Galaxybase Engine - standalone
Version: 3.4.1
Build: 20220721170804
OS/Arch: linux/amd64
  • 安装镜像

安装docker镜像

1
galaxybase-deploy image install

安装成功:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ galaxybase-deploy image install
2023/06/12 14:35:48 [INFO] check docker service state
2023/06/12 14:35:48 [INFO] images load env check pass
2023/06/12 14:35:48 [INFO] check original graph image
2023/06/12 14:35:48 [INFO] start load graph image
2023/06/12 14:36:13 [INFO] [local] [local] id : 05d30de7f8d8(7/7) [==================================================] 100.00%
2023/06/12 14:36:13 [INFO] images is successfully loaded

$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mariadb 10.11 9a79847e85fb 10 days ago 403MB
mariadb latest 9a79847e85fb 10 days ago 403MB
mysql 8.0.32 412b8cc72e4a 2 months ago 531MB
my-postgresql 15.2 42a9c74acef3 2 months ago 600MB
amd64/busybox latest 7cfbbec8963d 2 months ago 4.86MB
busybox latest 7cfbbec8963d 2 months ago 4.86MB
mariadb 10.4 81825cbadf42 2 months ago 385MB
mariadb 10.6 21277cbf6e2f 2 months ago 394MB
galaxybase s-20220721170804 f4ae486baad9 10 months ago 746MB

使用sudo权限安装docker

1
galaxybase-deploy build graph --home /data/gbca/home-galaxybase

安装成功:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ galaxybase-deploy build graph --home /data/gbca/home-galaxybase
2023/06/12 14:37:02 [INFO] resolving a service instance
2023/06/12 14:37:02 [INFO] check docker service state
2023/06/12 14:37:02 [INFO] the service container is checked pass
2023/06/12 14:37:02 [INFO] build resources
2023/06/12 14:37:02 [INFO] start get cpu info
2023/06/12 14:37:02 [INFO] build container running environment
2023/06/12 14:37:02 [INFO] [graph] container created successfully
2023/06/12 14:37:02 [INFO] starts [graph]-8d6140bedc59c14696c30c10c20b881c9e9f2e86e70bcf160f04f4b028018844 container
2023/06/12 14:37:03 [INFO] [graph]-8d6140bedc59c14696c30c10c20b881c9e9f2e86e70bcf160f04f4b028018844 container started successfully
2023/06/12 14:37:03 [INFO] waiting for server [server.manager.http] port [51314] listen
2023/06/12 14:37:17 [INFO] the service container is successfully build


$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8d6140bedc59 galaxybase:s-20220721170804 "/usr/bin/runner-sta…" 47 seconds ago Up 46 seconds galaxybase-dde2371d1f96

查看服务启动日志:

1
docker logs galaxybase-dde2371d1f96
3.png 4.png
  • 启动服务

启动 Galaxybase
通过浏览器访问服务器的51314端口,进入图节点管理平台启动Galaxybase。
账号/密码:admin/admin

5.png 6.png
  • 启动图节点

启动图节点,会提示需要授权,可以联机,也可以手动申请。

7.png

通过授权后,可以启动节点。

8.png

Cypher 语法

数据筛选

1
2
3
MATCH (n:电影)
WHERE n.上映年份 > 1990
RETURN n

模式匹配

  • 用圆括号()表示点、用 --> 表示边,可以用变量名指代点边数据
1
MATCH p=()-->() RETURN p LIMIT 10
  • 边可以指明方向,也可以不指明方向
1
MATCH (a)-[r]-(c) RERURN a,r,c LIMIT 10
  • 在括号内可以添加具体信息
1
MATCH (a)-[r:出演]->(b:电影 {电影名: "宝贝计划"}) RETURN a,r,b
  • 可以设置路径长度
1
MATCH p=(a:电影 {电影名: "宝贝计划"})-[*3]-(c) RETURN p LIMIT 10

数据查询

  • 结果排序
1
2
3
MATCH (b:电影)
WHERE b.上映时间 > 2000
RETURN b ORDER BY b.上映时间 SKIP 10 LIMIT 1
  • 路径查询
1
2
MATCH p=(m:人物{姓名:"吴孟达"})--()--(n:人物{姓名:"周星驰"})
RETURN p LIMIT 2
  • k跳扩展查询
1
2
MATCH p=(:人物{姓名:"刘德华"})-[*1..2]-()
RETURN p

数据修改

  • 修改属性
1
2
3
MATCH (a:电影{电影名:"无间道"})
SET a.语言="粤语"
RETURN a
  • 增加边、点
1
2
CREATE (a:人物{姓名:"AA"}) -[r:出演{角色:"RR"}]->(b:电影{电影名:"BB"})
RETURN a,r,b

数据删除

1
2
MATCH (a:人物{姓名:"特朗普"})
DELETE a

感谢 Carry 的帮助支持

在本文撰写过程中,启动单机版时遇到了授权失败的问题,感谢 @Carry 的帮助支持。

9.png
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
[13:53:27][OUT]进行自动授权,userLicense:xxx
[13:53:49][OUT]send url: https://auth.galaxybase.cloud/galaxybase/galaxybase/authcode/verify 失败, AuthCode 验证失败,检查auth server是否正常!,Exception:
[13:53:49][OUT]org.apache.http.conn.HttpHostConnectException: Connect to auth.galaxybase.cloud:443 [auth.galaxybase.cloud/42.194.233.160] failed: Connection refused (Connection refused)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at com.galaxybase.admin.http.client.HttpClientUtil.postForObjectWithJson(HttpClientUtil.java:174)
at com.galaxybase.admin.service.AuthorizeService.sendAuthCode(AuthorizeService.java:250)
at com.galaxybase.admin.service.AuthorizeService.autoAuthorize(AuthorizeService.java:79)
at com.galaxybase.admin.http.servlet.AdminServlet.doPost(AdminServlet.java:122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
at com.galaxybase.admin.http.filter.LoginFilter.doFilter(LoginFilter.java:203)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:308)
at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:262)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:61)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:348)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 48 more

[13:53:49][OUT]java.lang.RuntimeException: AuthCode 验证失败,检查auth service是否正常!
at com.galaxybase.admin.service.AuthorizeService.sendAuthCode(AuthorizeService.java:257)
at com.galaxybase.admin.service.AuthorizeService.autoAuthorize(AuthorizeService.java:79)
at com.galaxybase.admin.http.servlet.AdminServlet.doPost(AdminServlet.java:122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
at com.galaxybase.admin.http.filter.LoginFilter.doFilter(LoginFilter.java:203)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:308)
at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:262)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:61)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.base/java.lang.Thread.run(Thread.java:829)

总结

本文介绍了 GBCA 考试相关内容,并记录了如何在本地安装 galaxybase 单机版,以及基础的语法示例。


https://www.modb.pro/db/645884


  1. https://www.galaxybase.com/download ↩︎

  • Title: GBCA (Galaxybase) 认证学习资料内参
  • Author: 严少安
  • Created at: 2023-06-12 09:06:35
  • Updated at: 2023-06-12 09:06:35
  • Link: https://shawnyan.cn/2023/other/galaxybase-gbca/
  • License: This work is licensed under CC BY-NC-SA 4.0.
if (hexo-config('comment.enable') == true && hexo-config('comment.system') != "") { if (hexo-config('comment.system') == "waline") { @require "./waline.styl" } else if (hexo-config('comment.system') == "gitalk") { @require "./gitalk.styl" } else if (hexo-config('comment.system') == "twikoo") { @require "./twikoo.styl" } } .comments-container display inline-block margin-top $spacing-unit width 100% #comment-anchor width 100% height 10px .comment-area-title width 100% margin 10px 0 font-size 1.38rem color var(--default-text-color) font-family 'Consolas', '宋体', sans-serif font-weight bold i color var(--default-text-color) +redefine-tablet() margin 5px 0 font-size 1.2rem