JanusGraph Server的配置和使用

时间:2024-03-25 18:57:48

JanusGraph是一款图数据库,关于它的简单安装,大家可以看菌子的linux学习系列中的centos7下安装janusGraph单机版。 

       JanusGraph Server有两种连接方式,一种是socket,另一种是http。两种方式的配置方式差别不大,也可以配置同时支持socket和http的模式。本文将直接配置同时支持socket和http的模式。

首先我们进入JanusGraph目录的conf目录中。我们需要的文件是janusgraph-hbase-es.properties和 gremlin-server/gremlin-server.yaml ,复制这两个文件并重命名为http-janusgraph-hbase-es.properties, gremlin-server/http-gremlin-server.yaml

JanusGraph Server的配置和使用

[[email protected] conf]# cp gremlin-server/gremlin-server.yaml gremlin-server/http-gremlin-server.yaml 

[[email protected] conf]# cp janusgraph-hbase-es.properties http-janusgraph-hbase-es.properties

1. 配置http-janusgraph-hbase-es.properties 文件

[[email protected] conf]# vi http-janusgraph-hbase-es.properties

        首先确保storage.backend, storage.hostname and storage.hbase.table这些属性是存在的。并且确保gremlin.graph=org.janusgraph.core.JanusGraphFactory这句话存在。没有就加上。storage.backend指定存储后端,在本例中是hbase。storage.hostname指定存储端ip,本例中是单机环境,所以设置为localhost。storage.hbase.table设置在hbase中的存储位置,在server启动时,janusgraph会在hbase上自动建立该表,在本例中设置为test

JanusGraph Server的配置和使用

2. 配置 gremlin-server/http-gremlin-server.yaml 文件,配置channelizer为org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer,则server会同时支持http和web socket。同时指定graph配置文件为刚才的http-janusgraph-hbase-es.properties文件路径。

[[email protected] conf]# vi gremlin-server/http-gremlin-server.yaml

JanusGraph Server的配置和使用

3. 配置结束,启动gremlin server,运行gremlin-server.sh 并指定yaml配置文件为刚才配好的文件。janusgraph会自动在hbase和es上创建表和索引。

[[email protected] janusgraph]# ./bin/gremlin-server.sh conf/gremlin-server/http-gremlin-server.yaml

JanusGraph Server的配置和使用

4. 验证

[[email protected] ~]# curl -XPOST -Hcontent-type:application/json -d '{"gremlin":"g.V().count()"}' http://localhost:8182

JanusGraph Server的配置和使用

5. 完成收工