JanusGraph集群搭建,多图配置及索引

[b]下载和启动实例[/b]
1、下载和启动Cassandra,生产环境会使用HBase作为Storage backend,但在开发环境部署HBase比较复杂

http://cassandra.apache.org/download/ 下载3.11.2

解压后 sh bin/cassandra -f, 默认绑定IP:127.0.0.1 PORT:9042

启动thrift,sh ./bin/nodetool enablethrift 默认绑定IP:127.0.0.1 PORT:9160

2、下载和启动ES

JanusGraph的发布包自带ES,sh /elasticsearch/bin/elasticsearch,默认绑定IP:127.0.0.1 PORT:9200

也可以使用独立的ES,但建议5.0以上版本。

[color=orange]PS:centos6下启动es5.0以上版本遇到的问题及解决方法[/color]

[1]: max file descriptors [10240] for elasticsearch process is too low, increase to at least [65536]

ulimit -n 65536
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

修改/etc/sysctl.conf配置文件,

cat /etc/sysctl.conf | grep vm.max_map_count
vm.max_map_count=262144

如果不存在则添加

echo "vm.max_map_count=262144" >>/etc/sysctl.conf

sysctl -p

[3]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false



3、下载和安装JanusGraph

https://github.com/JanusGraph/janusgraph/releases/ 下载janusgraph-0.2.0-hadoop2.zip

编辑janusgraph-cassandra-es.properties,将es和cassandra的ip指定为步骤1,2中的IP

sh bin/gremlin.sh

graph = JanusGraphFactory.open("conf/janusgraph-cassandra-es.properties"),如提示standardjanusgraph[cassandrathrift:[127.0.0.1]],则配置成功

4、启动gremlin server

修改conf/gremlin-server/gremlin-server.yaml,确定properties文中的cassandra和es的ip正确

sh bin/gremlin-server.sh

使用gremlin.sh测试是否可以连上服务,:remote connect tinkerpop.server conf/remote.yaml





[b]组建集群及多图[/b]
1、GremlinServer多图配置

[color=orange]服务器gremlin-server.yaml中可以设置多个graph的properties文件[/color]

graphs: {
graph: conf/gremlin-server/janusgraph-cassandra-es-server.properties,
pressureGraph: conf/gremlin-server/janusgraph-pressure.properties
}

[color=brown]janusgraph-pressure.properties中需要声明keyspace和index-name,否则会按照默认名字janusgraph建立存储和索引。多个properties指向同一个图。[/color]

storage.hostname=10.*.*.*
storage.cassandra.keyspace=pressure

index.pressure.hostname=10.*.*.*:9200

index.pressure.index-name=pressure

PS:可使用cqlsh describe keyspaces , curl -XGET 10.*.*.*:9200/_cat/indices查看存储及索引情况

[color=orange]scripts/empty-sample.groovy,增加traversalSource,对应不同的graph[/color]

globals << [g : graph.traversal(), p : pressureGraph.traversal()]



2、集群配置配置

[color=orange]客户端remote-objects.yaml,指定多实例IP,并实现负载均衡[/color]

hosts: [10.*.*.*,10.*.*.*]

[color=orange]jgex-remote.properties指定服务器上的traversalSource[/color]

gremlin.remote.driver.sourceName=p





[b]索引优化及检查[/b]
[color=orange]1、composite索引,基于storage backend实现,仅支持相等(完全匹配),速度快[/color]

mgmt.buildIndex('copIndustryCode', Vertex.class).addKey(industryCode).buildCompositeIndex()

[color=orange]2、mixed索引,基于index backend实现,支持如ES的特性,速度慢于composite索引。最后一个参数为index-name。[/color]

mgmt.buildIndex('mixCompanyCode', Vertex.class).addKey(companyCode).buildMixedIndex("pressure")
[color=orange]3、可以使用gramlin.sh进行检索,如提示Query requires iterating over all vertices [(companyCode = 10)]. For better performance, use indexes,则表示未使用索引。[/color]

相反则代表使用了索引

gremlin> g.V().has("companyCode", textContains("1000")).valueMap()
==>[companyCode:[1000],companyName:[机构1000]]
gremlin> g.V().has("companyCode", "10").valueMap()
19:34:32 WARN org.janusgraph.graphdb.transaction.StandardJanusGraphTx - Query requires iterating over all vertices [(companyCode = 10)]. For better performance, use indexes



[b]4.1 全剧配置[/b]

schema.default=none // 关闭自动创建vertex label,edge label, property

# Required to enable Metrics in JanusGraph
metrics.enabled = true
force-index

4.2 storage backend

4.3 index backend





参考资料:

http://docs.janusgraph.org/latest/getting-started.html 官网

https://groups.google.com/forum/#!topic/gremlin-users/yWqS6gzmoYY 配置多graph, traversalSource
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值