Titan/JanusGraph图数据库支持Hadoop-Gremlin批量数据导入,其执行需要注意如下问题
1)Titan/Janusgraph支持的数据格式为邻接链表
其实就是邻接矩阵,每条边(i, j)在邻接列表中出现两次,一次为入边,一次为出边,分别位于矩阵的上三角和下下三角。如果进一步深入,那就需要学习线性代数啦。
2)如果导入数据为从其他Titan图数据库导出的数据, 在导入数据前,需要
针对每种类型(VertexLabel)节点,创建索引,属性名称为bulkLoader.vertex.id。
在实际导入前,系统会以VertexLablel和bulkLoader.vertex.id联合查询导入的顶点在数据库中是否存在,如果不建立索引,会导致查询时间过长。索引建立例子如下
blid = m.makePropertyKey("bulkLoader.vertex.id").dataType(Long.class).make()
vetexLabel = m.makeEdgeLabel("vertexLabel").make()
m.buildIndex("byBulkLoaderVertexId", Vertex.class).addKey(blid).indexOnly(vetexLabel).buildCompositeIndex()
3)如果导入到Titan/JanusGraph图数据库,需要在titan-hbase-es.properties等配置文件中配置gremlin.graph的类型,否则Hadoop-Gremlin会抛出图数据库类型不确定Exception。
gremlin.graph=com.thinkaurelius.titan.core.TitanFactory
4) 如果是大规模图的导入,则需要调整HBase,Akka等参数,以应对RPC Timeout、MapOutPutTracker等数据库海量数据操作异常。
设置RPC Timeout参数,我一般把Timeout调到20min,应对大规模并发情况下的RPC延迟延长。
设置spark.akka.timeout,spark.akka.heartbeat.pauses, ...,spark.akka.frameSize等spark.akka参数,应对Akka操作导致的Timeout问题。以下为我针对10亿级顶点的数据导入采用的spark.akka配置参数。
spark.akka.timeout=1000
spark.akka.heartbeat.pauses=60000
spark.akka.failure-detector.threshold=3000.0
spark.akka.heartbeat.interval=10000
spark.akka.askTimeout=600
spark.akka.frameSize=100
spark.akka.lookupTimeout=600