欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

HugeGraphServer 部署安装

程序员文章站 2023-12-27 08:11:15
...

官方文档链接:https://hugegraph.github.io/hugegraph-doc

HugeGraphServer Quick Start

1 概述

HugeGraph-Server 是 HugeGraph 项目的核心部分,包含Core、Backend、API等子模块。

Core模块是Tinkerpop接口的实现,Backend模块用于管理数据存储,目前支持的后端包括:Memory、Cassandra、ScyllaDB以及RocksDB,API模块提供HTTP Server,将Client的HTTP请求转化为对Core的调用。

文档中会大量出现HugeGraph-ServerHugeGraphServer这两种写法,其他组件也类似。这两种写法含义上并无大的差异,可以这么区分:HugeGraph-Server表示服务端相关组件代码,HugeGraphServer表示服务进程。

2 依赖

2.1 安装JDK-1.8

HugeGraph-Server 基于jdk-1.8开发,代码用到了较多jdk-1.8中的类和方法,请用户自行安装配置。

在往下阅读之前务必执行java -version命令查看jdk版本

java -version

2.2 安装GCC-4.3.0(GLIBCXX_3.4.10)或更新版本(可选)

如果使用的是RocksDB后端,请务必执行gcc --version命令查看gcc版本;若使用其他后端,则不需要。

gcc --version

版本对应关系 

HugeGraphServer 部署安装 

3 部署

有三种方式可以部署HugeGraph-Server组件:

  • 方式1:一键部署
  • 方式2:下载tar包
  • 方式3:源码编译

3.1 一键部署

HugeGraph-Tools提供了一键部署的命令行工具,用户可以使用该工具快速地一键下载、解压、配置并启动HugeGraphServer和HugeGraphStudio。 当然,还是得先下载HugeGraph-Tools的tar包。

wget https://github.com/hugegraph/hugegraph-tools/releases/download/v${version}/hugegraph-tools-${version}.tar.gz
tar -zxvf hugegraph-tools-${version}.tar.gz
cd hugegraph-tools-${version}

注:${version}为版本号,最新版本号可参考Download页面,或直接从Download页面点击链接下载

HugeGraph-Tools 的总入口脚本是bin/hugegraph,用户可以使用help子命令查看其用法,这里只介绍一键部署的命令。

bin/hugegraph deploy -v {hugegraph-version} -p {install-path} [-u {download-path-prefix}]

{hugegraph-version}表示要部署的HugeGraphServer及HugeGraphStudio的版本,用户可查看conf/version-mapping.yaml文件获取版本信息,{install-path}指定HugeGraphServer及HugeGraphStudio的安装目录,{download-path-prefix}可选,指定HugeGraphServer及HugeGraphStudio tar包的下载地址,不提供时使用默认下载地址,比如要启动 0.6 版本的HugeGraph-Server及HugeGraphStudio将上述命令写为bin/hugegraph deploy -v 0.6 -p services即可。

3.2 下载tar包

所有版本目录,我们这里使用 0.10.4 版本

https://github.com/hugegraph/hugegraph/releases
wget 
https://github.com/hugegraph/hugegraph/releases/download/v0.10.4/hugegraph-0.10.4.tar.gz
tar -zxvf hugegraph-0.10.4.tar.gz

3.3 源码编译

下载HugeGraph源代码

git clone https://github.com/hugegraph/hugegraph.git

编译打包生成tar包

cd hugegraph
mvn package -DskipTests

执行日志如下:

......
[INFO] Reactor Summary:
[INFO] 
[INFO] hugegraph .......................................... SUCCESS [  0.003 s]
[INFO] hugegraph-core ..................................... SUCCESS [ 15.335 s]
[INFO] hugegraph-api ...................................... SUCCESS [  0.829 s]
[INFO] hugegraph-cassandra ................................ SUCCESS [  1.095 s]
[INFO] hugegraph-scylladb ................................. SUCCESS [  0.313 s]
[INFO] hugegraph-rocksdb .................................. SUCCESS [  0.506 s]
[INFO] hugegraph-mysql .................................... SUCCESS [  0.412 s]
[INFO] hugegraph-palo ..................................... SUCCESS [  0.359 s]
[INFO] hugegraph-dist ..................................... SUCCESS [  7.470 s]
[INFO] hugegraph-example .................................. SUCCESS [  0.403 s]
[INFO] hugegraph-test ..................................... SUCCESS [  1.509 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
......

执行成功后,在hugegraph目录下生成 hugegraph-*.tar.gz 文件,就是编译生成的tar包。

4 配置

如果需要快速启动HugeGraph仅用于测试,那么只需要进行少数几个配置项的修改即可(见下一节)。 详细的配置介绍请参考配置文档配置项介绍

5 启动

启动分为"首次启动"和"非首次启动",这么区分是因为在第一次启动前需要初始化后端数据库,然后启动服务。 而在人为停掉服务后,或者其他原因需要再次启动服务时,因为后端数据库是持久化存在的,直接启动服务即可。

HugeGraphServer启动时会连接后端存储并尝试检查后端存储版本号,如果未初始化后端或者后端已初始化但版本不匹配时(旧版本数据),HugeGraphServer会启动失败,并给出错误信息。

如果需要外部访问HugeGraphServer,请修改rest-server.propertiesrestserver.url配置项 (默认为http://127.0.0.1:8080),修改成机器名或IP地址。

由于各种后端所需的配置(hugegraph.properties)及启动步骤略有不同,下面逐一对各后端的配置及启动做介绍。

HugeGraphServer的默认配置只能是本机访问,可以修改配置,使其能在其他机器访问。

 vim conf/rest-server.properties

 restserver.url=http://0.0.0.0:8080

 

5.1 Memory (建议测试学习时使用)

修改 hugegraph.properties

backend=memory
serializer=text

Memory后端的数据是保存在内存中无法持久化的,不需要初始化后端,这也是唯一一个不需要初始化的后端。

启动 server

bin/start-hugegraph.sh
Starting HugeGraphServer...
Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)....OK

提示的 url 与 rest-server.properties 中配置的 restserver.url 一致

5.2 HBase

用户需自行安装 HBase,要求版本 2.0 以上,下载地址

修改 hugegraph.properties

backend=hbase
serializer=hbase

# hbase backend config
hbase.hosts=localhost
hbase.port=2181

初始化数据库(仅第一次启动时需要)

cd hugegraph-${version}
bin/init-store.sh

查看日志,发现会在hbase创建一些表

2020-01-08 14:23:37 8612  [main] [INFO ] com.baidu.hugegraph.cmd.InitStore [] - Init graph with config file: conf/hugegraph.properties
2020-01-08 14:23:37 8697  [main] [INFO ] com.baidu.hugegraph.HugeGraph [] - Opening backend store 'hbase' for graph 'hugegraph'
2020-01-08 14:23:37 8944  [main] [WARN ] org.apache.hadoop.util.NativeCodeLoader [] - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2020-01-08 14:23:37 9285  [main] [INFO ] org.apache.hadoop.hbase.zookeeper.ReadOnlyZKClient [] - Connect 0x38aa816f to 192.168.2.116:2181 with session timeout=90000ms, retries 3, retry interval 1000ms, keepAlive=60000ms
2020-01-08 14:23:38 10101 [main] [INFO ] org.apache.hadoop.hbase.zookeeper.ReadOnlyZKClient [] - Connect 0x2c7b5824 to 192.168.2.116:2181 with session timeout=90000ms, retries 3, retry interval 1000ms, keepAlive=60000ms
2020-01-08 14:23:39 11019 [main] [INFO ] org.apache.hadoop.hbase.zookeeper.ReadOnlyZKClient [] - Connect 0x6bb2d00b to 192.168.2.116:2181 with session timeout=90000ms, retries 3, retry interval 1000ms, keepAlive=60000ms
2020-01-08 14:23:41 12754 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_di completed
2020-01-08 14:23:41 13472 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_ie completed
2020-01-08 14:23:43 14700 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_vi completed
2020-01-08 14:23:43 15414 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_hi completed
2020-01-08 14:23:44 16127 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_li completed
2020-01-08 14:23:45 16852 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_ui completed
2020-01-08 14:23:46 17566 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_v completed
2020-01-08 14:23:46 18278 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_si completed
2020-01-08 14:23:47 18990 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_ii completed
2020-01-08 14:23:48 20205 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_oe completed
2020-01-08 14:23:49 20917 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_fi completed
2020-01-08 14:23:50 21631 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_ei completed
2020-01-08 14:23:51 22842 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:s_ai completed
2020-01-08 14:23:52 23783 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_di completed
2020-01-08 14:23:53 25071 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_ie completed
2020-01-08 14:23:54 25784 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_vi completed
2020-01-08 14:23:54 26497 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_hi completed
2020-01-08 14:23:55 27211 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_li completed
2020-01-08 14:23:56 27923 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_ui completed
2020-01-08 14:23:57 28638 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_v completed
2020-01-08 14:23:58 29850 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_si completed
2020-01-08 14:23:59 30584 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_ii completed
2020-01-08 14:23:59 31299 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_oe completed
2020-01-08 14:24:01 32567 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_fi completed
2020-01-08 14:24:09 41383 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_ei completed
2020-01-08 14:24:10 42187 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:g_ai completed
2020-01-08 14:24:11 43427 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:vl completed
2020-01-08 14:24:12 44156 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:el completed
2020-01-08 14:24:13 44923 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:m_si completed
2020-01-08 14:24:14 46156 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:il completed
2020-01-08 14:24:15 47533 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:pk completed
2020-01-08 14:24:16 48291 [main] [INFO ] org.apache.hadoop.hbase.client.HBaseAdmin [] - Operation: CREATE, Table Name: hugegraph:c completed
2020-01-08 14:24:18 50524 [main] [INFO ] com.baidu.hugegraph.HugeGraph [] - Graph 'hugegraph' has been initialized
2020-01-08 14:24:18 50524 [main] [INFO ] com.baidu.hugegraph.HugeGraph [] - Close graph hugegraph[hugegraph]
2020-01-08 14:24:18 50529 [main] [INFO ] org.apache.hadoop.hbase.client.ConnectionImplementation [] - Closing master protocol: MasterService
2020-01-08 14:24:18 50529 [main] [INFO ] org.apache.hadoop.hbase.zookeeper.ReadOnlyZKClient [] - Close zookeeper connection 0x6bb2d00b to 192.168.2.116:2181
2020-01-08 14:24:18 50540 [main] [INFO ] org.apache.hadoop.hbase.client.ConnectionImplementation [] - Closing master protocol: MasterService
2020-01-08 14:24:18 50540 [main] [INFO ] org.apache.hadoop.hbase.zookeeper.ReadOnlyZKClient [] - Close zookeeper connection 0x2c7b5824 to 192.168.2.116:2181
2020-01-08 14:24:18 50540 [main] [INFO ] org.apache.hadoop.hbase.client.ConnectionImplementation [] - Closing master protocol: MasterService
2020-01-08 14:24:18 50544 [main] [INFO ] org.apache.hadoop.hbase.zookeeper.ReadOnlyZKClient [] - Close zookeeper connection 0x38aa816f to 192.168.2.116:2181
2020-01-08 14:24:19 50606 [Thread-1] [INFO ] com.baidu.hugegraph.HugeGraph [] - HugeGraph is shutting down

 

启动server

bin/start-hugegraph.sh
Starting HugeGraphServer...
Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)....OK

6 访问Server

6.1 服务启动状态校验

jps查看服务进程

jps
6475 HugeGraphServer

curl请求RestfulAPI

echo `curl -o /dev/null -s -w %{http_code} "http://localhost:8080/graphs/hugegraph/graph/vertices"`

返回结果200,代表server启动正常

7 停止Server

$cd hugegraph-${version}
$bin/stop-hugegraph.sh

 

异常

1.启动之前未进行初始化操作,第一次启动需要先

bin/init-store.sh

 再执行

bin/start-hugegraph.sh

 异常内容

2020-01-08 14:20:50 13629 [main] [ERROR] com.baidu.hugegraph.dist.HugeGraphServer [] - HugeRestServer start error: 
com.baidu.hugegraph.backend.BackendException: The backend store of 'hugegraph' has not been initialized
	at com.baidu.hugegraph.core.GraphManager.checkBackendVersionOrExit(GraphManager.java:206) ~[hugegraph-api-0.10.4.jar:0.48.0.0]
	at com.baidu.hugegraph.core.GraphManager.<init>(GraphManager.java:76) ~[hugegraph-api-0.10.4.jar:0.48.0.0]
	at com.baidu.hugegraph.server.ApplicationConfig$GraphManagerFactory$1.onEvent(ApplicationConfig.java:108) ~[hugegraph-api-0.10.4.jar:0.48.0.0]
	at org.glassfish.jersey.server.internal.monitoring.CompositeApplicationEventListener.onEvent(CompositeApplicationEventListener.java:74) ~[jersey-server-2.25.1.jar:?]
	at org.glassfish.jersey.server.internal.monitoring.MonitoringContainerListener.onStartup(MonitoringContainerListener.java:81) ~[jersey-server-2.25.1.jar:?]
	at org.glassfish.jersey.server.ApplicationHandler.onStartup(ApplicationHandler.java:1180) ~[jersey-server-2.25.1.jar:?]
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.start(GrizzlyHttpContainer.java:357) ~[jersey-container-grizzly2-http-2.25.1.jar:?]
	at org.glassfish.grizzly.http.server.HttpHandlerChain.start(HttpHandlerChain.java:422) ~[grizzly-http-server-2.3.28.jar:2.3.28]
	at org.glassfish.grizzly.http.server.HttpServer.setupHttpHandler(HttpServer.java:314) ~[grizzly-http-server-2.3.28.jar:2.3.28]
	at org.glassfish.grizzly.http.server.HttpServer.start(HttpServer.java:290) ~[grizzly-http-server-2.3.28.jar:2.3.28]
	at com.baidu.hugegraph.server.RestServer.start(RestServer.java:62) ~[hugegraph-api-0.10.4.jar:0.48.0.0]
	at com.baidu.hugegraph.server.RestServer.start(RestServer.java:113) ~[hugegraph-api-0.10.4.jar:0.48.0.0]
	at com.baidu.hugegraph.dist.HugeRestServer.start(HugeRestServer.java:58) ~[hugegraph-dist-0.10.4.jar:?]
	at com.baidu.hugegraph.dist.HugeGraphServer.<init>(HugeGraphServer.java:55) [hugegraph-dist-0.10.4.jar:?]
	at com.baidu.hugegraph.dist.HugeGraphServer.main(HugeGraphServer.java:100) [hugegraph-dist-0.10.4.jar:?]
2020-01-08 14:20:50 13645 [main] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Shutting down OpProcessor[]
2020-01-08 14:20:50 13645 [main] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Shutting down OpProcessor[session]
2020-01-08 14:20:50 13646 [main] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Shutting down OpProcessor[traversal]
2020-01-08 14:20:50 13646 [main] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Shutting down thread pools.
2020-01-08 14:20:50 13652 [gremlin-server-stop] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Executing shutdown LifeCycleHook
2020-01-08 14:20:50 13652 [gremlin-server-stop] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Executed once at shutdown of Gremlin Server.
2020-01-08 14:20:52 15854 [gremlin-server-stop] [INFO ] com.baidu.hugegraph.HugeGraph [] - Close graph hugegraph[hugegraph]
2020-01-08 14:20:52 15862 [gremlin-server-stop] [WARN ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Exception while closing Graph instance [hugegraph]
java.lang.IllegalStateException: Ensure tx closed in all threads when closing graph 'hugegraph'
	at com.google.common.base.Preconditions.checkState(Preconditions.java:199) ~[guava-19.0.jar:?]
	at com.baidu.hugegraph.util.E.checkState(E.java:68) ~[hugegraph-common-1.6.16.jar:1.6.16.0]
	at com.baidu.hugegraph.HugeGraph.close(HugeGraph.java:503) ~[hugegraph-core-0.10.4.jar:0.10.4.0]
	at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$null$7(GremlinServer.java:298) ~[gremlin-server-3.4.3.jar:3.4.3]
	at java.util.concurrent.ConcurrentHashMap$KeySetView.forEach(ConcurrentHashMap.java:4649) ~[?:1.8.0_121]
	at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$stop$8(GremlinServer.java:295) ~[gremlin-server-3.4.3.jar:3.4.3]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
2020-01-08 14:20:52 15863 [gremlin-server-stop] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Closed Graph instance [hugegraph]
2020-01-08 14:20:52 15864 [gremlin-server-stop] [INFO ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Gremlin Server - shutdown complete
Exception in thread "main" com.baidu.hugegraph.backend.BackendException: The backend store of 'hugegraph' has not been initialized
	at com.baidu.hugegraph.core.GraphManager.checkBackendVersionOrExit(GraphManager.java:206)
	at com.baidu.hugegraph.core.GraphManager.<init>(GraphManager.java:76)
	at com.baidu.hugegraph.server.ApplicationConfig$GraphManagerFactory$1.onEvent(ApplicationConfig.java:108)
	at org.glassfish.jersey.server.internal.monitoring.CompositeApplicationEventListener.onEvent(CompositeApplicationEventListener.java:74)
	at org.glassfish.jersey.server.internal.monitoring.MonitoringContainerListener.onStartup(MonitoringContainerListener.java:81)
	at org.glassfish.jersey.server.ApplicationHandler.onStartup(ApplicationHandler.java:1180)
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.start(GrizzlyHttpContainer.java:357)
	at org.glassfish.grizzly.http.server.HttpHandlerChain.start(HttpHandlerChain.java:422)
	at org.glassfish.grizzly.http.server.HttpServer.setupHttpHandler(HttpServer.java:314)
	at org.glassfish.grizzly.http.server.HttpServer.start(HttpServer.java:290)
	at com.baidu.hugegraph.server.RestServer.start(RestServer.java:62)
	at com.baidu.hugegraph.server.RestServer.start(RestServer.java:113)
	at com.baidu.hugegraph.dist.HugeRestServer.start(HugeRestServer.java:58)
	at com.baidu.hugegraph.dist.HugeGraphServer.<init>(HugeGraphServer.java:55)
	at com.baidu.hugegraph.dist.HugeGraphServer.main(HugeGraphServer.java:100)

 

相关标签: Graph

上一篇:

下一篇: