Titan图形数据库学习笔记(一)

Titan数据库简介

Titan 是一个可扩展的图形数据库,结合HBase、Cassandra、BerkeleyDB提供存储功能,ES、Lucene、Solar提供索引功能,可利用Hadoop计算框架对图数据进行分析、统计。经过优化,可用于存储和索引分布于多节点集群的百亿级顶点和边的图,同时,Titan又是一个事务数据库,可以支持数千个并发用户实时执行复杂图形遍历。

  1. 框架
    Titan是一个图形数据库引擎,其本身专注于紧凑图表序列化,丰富的图形数据库建模和高效的查询执行。其框架主要如下:
    • Titan与底层磁盘之间有多个存储和索引适配器:
      • 存储:
        • Cassandra
        • HBase
        • BerkeleyDB
      • 索引:
        • Elasticsearch
        • Solr
        • Lucene
    • Titan提供了三种交互式接口:
      • TitanGraph API
      • TinkPop API
      • Management API

Titan数据库环境配置

  1. 下载titan-1.0.0-hadoop2.zip解压。
  2. 配置文件

    • 进入conf/es文件夹,配置elasticsearch.yml,截取如下:

      1
      2
      3
      4
      5
      6
      7
      8
      path.data: db/es/data
      path.work: db/es/work
      path.logs: log
      path.plugins: bin/esplugins
      network.host: 22.144.110.125
      transport.tcp.port: 9300
      http.port: 9200
      discovery.zen.ping.unicast.hosts: ["hadoop1","hadoop2","hadoop3","hadoop4","hadoop5","hadoop6"]
    • 进入conf文件夹,配置titan-hbase-es.properties,截取如下:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      storage.backend=hbase
      storage.hostname=hadoop1, hadoop2, hadoop3, hadoop4, hadoop5, hadoop6
      cache.db-cache = true
      cache.db-cache-clean-wait = 20
      cache.db-cache-time = 180000
      cache.db-cache-size = 0.5
      index.search.backend=elasticsearch
      index.search.hostname=hadoop5
      index.search.elasticsearch.client-only=true
  3. 启动

    • 进入bin目录,运行elasticsearch
    • 重开终端,运行gremlin.sh
    • 输入以下脚本:

      1
      2
      3
      graph = TitanFactory.open('../conf/titan-hbase-es.properties')
      g = graph.traversal()
      saturn = g.V().has('name', 'saturn').next()


参考资料