hugegraph-server配置详解

hugegraph-server

配置文件的目录为 hugegraph-release/conf,所有关于服务和图本身的配置都在此目录下

主要的配置文件包括:gremlin-server.yamlrest-server.properties hugegraph.properties

HugeGraphServer 内部集成了 GremlinServer(配置文件:gremlin-server.yaml) 和 RestServer(配置文件:rest-server.properties)

    GremlinServer:GremlinServer接受用户的gremlin语句,解析后转而调用Core的代码

    RestServer:提供Restful API,根据不同的HTTP请求,调用对应的Core API,如果用户请求体是gremlin语句,则会转发给GremlinServer,实现对图数据的操作

 

gremlin-server.yaml

# If you want to start gremlin-server for gremlin-console(web-socket),
# please change `HttpChannelizer` to `WebSocketChannelizer` or comment this line.
channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
graphs: {
  hugegraph: conf/hugegraph.properties
}

配置项很多,但目前只需要关注如下几个配置项:channelizer 和 graphs

  • channelizer:GremlinServer 与客户端有两种通信方式:
    •  WebSocket :用户可以通过 Gremlin-Console 快速体验 HugeGraph 的特性,但是不支持大规模数据导入
    •  HTTP(默认):推荐使用 HTTP 的通信方式,我们的一些外围组件都是基于 HTTP 实现的;
  • graphs:GremlinServer 启动时需要打开的图,该项是一个 map 结构,key 是图的名字,value 是该图的配置文件路径;

默认GremlinServer是服务在 localhost:8182,如果需要修改,配置 host、port 即可,目前 HugeGraphServer 不支持分布式部署,且GremlinServer不直接暴露给用户;

同时需要在 rest-server.properties 中增加对应的配置项 gremlinserver.url=http://host:port

注意:init-store 命令是根据 gremlin-server.yaml 的 graphs 下的图进行初始化的。

 

rest-server.properties

restserver.url=http://127.0.0.1:8080
gremlinserver.url=http://127.0.0.1:8182
graphs=[hugegraph:conf/hugegraph.properties]

#max_vertices_per_batch=500
#max_edges_per_batch=500

restserver.url:RestServer 提供服务的 url,根据实际环境修改;

gremlinserver.url:GremlinServer 为RestServer提供服务的 url,该配置项默认为 http://localhost:8182,如需修改,需要和 gremlin-server.yaml 中的 host 和 port 相匹配;

graphs:RestServer 启动时也需要打开图,该项为 map 结构,key 是图的名字,value 是该图的配置文件路径;

 

hugegraph.properties

gremlin.graph=com.baidu.hugegraph.HugeFactory
backend=cassandra
serializer=cassandra
store=hugegraph
rocksdb.data_path=.
rocksdb.wal_path=.
cassandra.host=localhost
cassandra.port=9042
cassandra.username=
cassandra.password=
admin.token=162f7848-0b6d-4faf-b557-3a0797869c55

重点关注未注释的几项:

  • gremlin.graph:GremlinServer 的启动入口,用户不要修改此项;
  • backend:使用的后端存储,可选值有 memory、cassandra、scylladb 和 rocksdb;
  • serializer:主要为内部使用,用于将 schema、vertex 和 edge 序列化到后端,对应的可选值为 text、cassandra、scylladb 和 binary;
  • store:图存储到后端使用的数据库名,在 cassandra 和 scylladb 中就是 keyspace 名,此项的值与 GremlinServer 和 RestServer 中的图名并无关系,但是出于直观考虑,建议仍然使用相同的名字;
  • cassandra.host:backend 为 cassandra 或 scylladb 时此项才有意义,cassandra/scylladb 集群的 seeds;
  • cassandra.port:backend 为 cassandra 或 scylladb 时此项才有意义,cassandra/scylladb 集群的 native port;
  • rocksdb.data_path:backend 为 rocksdb 时此项才有意义,rocksdb 的数据目录
  • rocksdb.wal_path:backend 为 rocksdb 时此项才有意义,rocksdb 的日志目录
  • admin.token: 通过一个token来获取服务器的配置信息,例如:http://localhost:8080/graphs/hugegraph/conf?token=162f7848-0b6d-4faf-b557-3a0797869c55

 

多图配置

我们的系统是可以存在多个图的,并且各个图的后端可以不一样,比如图 hugegraph 和 hugegraph1,其中 hugegraph 以 cassandra 作为后端,hugegraph1 以 rocksdb作为后端

修改 gremlin-server.yaml

在 gremlin-server.yaml 的 graphs 域中添加一个键值对,键为图的名字,值为图的配置文件路径,比如:

graphs: {
  hugegraph: conf/hugegraph.properties,
  hugegraph1: conf/hugegraph1.properties
}

修改 rest-server.properties

在 rest-server.properties 的 graphs 域中添加一个键值对,键为图的名字,值为图的配置文件路径,比如:

graphs=[hugegraph:conf/hugegraph.properties, hugegraph1:conf/hugegraph1.properties]

添加 hugegraph1.properties

拷贝 hugegraph.properties,命名为 hugegraph1.properties,修改图对应的数据库名以及关于后端部分的参数,比如:

store=hugegraph1

...

backend=rocksdb
serializer=binary

停止 Server,初始化执行 init-store.sh(为新的图创建数据库),重新启动 Server

$ bin/stop-hugegraph.sh
$ bin/init-store.sh
$ bin/start-hugegraph.sh

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值