Ubuntu下Titan 环境搭建

Titan官网:http://titan.thinkaurelius.com/
首先我们要了解Titan的一些特性,知道什么情况用到Titan

1.弹性和线性可伸缩性的增长数据和用户群。

2.数据分布和复制和容错性能。

3.多数据中心的高可用性和热备份。

4.支持 ACID事务和 最终一致性 。

5.支持各种 存储后端 :
    Apache Cassandra
    Apache HBase
    Oracle BerkeleyDB

6.支持全球 图表数据分析 、报告和ETL通过集成与大数据平台:
    Apache Spark
    Apache Giraph
    Apache Hadoop

7.支持地理,数值范围,并通过:全文搜索
    ElasticSearch
    Solr
    Lucene

8.Titan本身集成 TinkerPop 图堆栈:
    Gremlin图查询语言
    Gremlin图服务器
    Gremlin应用程序

运行环境:
JDK             :1.8.0_151
elasticsearch   :elasticsearch-1.4.2
cassandra       :cassandra-2.1.18


JKD,elasticsearch安装:
    http://blog.csdn.net/weixin_40596016/article/details/78591678
cassandra安装:
    http://blog.csdn.net/weixin_40596016/article/details/78594603



Titan下载地址:https://github.com/thinkaurelius/titan/wiki/Downloads

安装:
    wget http://s3.thinkaurelius.com/downloads/titan/titan-1.0.0-hadoop2.zip
    我下载的是Titan 1.0.0 with Hadoop 2 (signature)。
注意:titan-1.0.0-hadoop2.zip这个包,Titan最低要求为jdk1.8!!!

解压:
    unzip titan-1.0.0-hadoop2.zip
进入lib目录:
    cd titan-1.0.0-hadoop2/lib
    wget http://search.maven.org/remotecontent?filepath=com/thinkaurelius/titan/titan-hadoop/1.0.0/titan-hadoop-1.0.0.jar
注意:如果使用Hadoop2的安装包,是需要手动引入titan-hadoop-1.0.0.jar的,不然会报异常!!!

启动gremlin:
    进入bin目录:
        cd titan-1.0.0-hadoop2/bin
    启动titan数据库
        bin/titan.sh start
    启动gremlin
        bin/gremlin.sh
    成功:
                 \,,,/
                 (o o)
        -----oOOo-(3)-oOOo-----
    创建实例
        graph = TitanFactory.open('conf/titan-cassandra-es.properties')
    导入图谱
        GraphOfTheGodsFactory.load(graph)
    遍历
        g = graph.traversal()


Gremlin Shell测试,示例来自官方,在hbase,elasticsearch上都会生成一个titan库。
    $bin/gremlin.sh  
    gremlin>graph=TitanFactory.open('conf/titan-hbase-es.properties')  
    ==>standardtitangraph[hbase:[host-115]]  
    gremlin>GraphOfTheGodsFactory.load(graph)  
    ==>null  
    gremlin>g=graph.traversal()  
    graphtraversalsource[standardtitangraph[hbase:[host-115]], standard]  
    gremlin>saturn=g.V().has('name','saturn').next()  
    ==>v[256]gremlin>g.V(saturn).valueMap()  
    ==>[name:[saturn],age:[10000]]  
    gremlin>g.V(saturn).in('father').in('father').values('name')  
    ==>hercules  
    gremlin>g.E().has('place',geoWithin(Geoshape.circle(37.97,23.72,50)))  
    ==>e[a9x-co8-9hx-39s][16424-battled->4240]  
    ==>e[9vp-co8-9hx-9ns][16424-battled->12520]  
    gremlin>g.E().has('place',geoWithin(Geoshape.circle(37.97,23.72,50))).as('source').inV().as('god2').select('source').outV().as('god1').select('god1','god2').by('name')  
    ==>[god1:hercules,god2:hydra]  
    ==>[god1:hercules,god2:nemean]  
    gremlin>hercules=g.V(saturn).repeat(__.in('father')).times(2).next()  
    ==>v[1536]  
    gremlin>g.V(hercules).out('father','mother')  
    ==>v[1024]  
    ==>v[1792]  
    gremlin>g.V(hercules).out('father','mother').values('name')  
    ==>jupiter  
    ==>alcmene  
    gremlin>g.V(hercules).out('father','mother').label()  
    ==>god  
    ==>human  
    gremlin>hercules.label()  
    ==>demigod  
    gremlin>g.V(hercules).out('father','mother')  
    ==>v[1024]  
    ==>v[1792]  
    gremlin>g.V(hercules).out('father','mother').values('name')  
    ==>jupiter  
    ==>alcmenegremlin>g.V(hercules).out('father','mother').label()  
    ==>god  
    ==>human  
    gremlin>hercules.label()  
    ==>demigod  
    gremlin>g.V(hercules).outE('battled').has('time',gt(1)).inV().values('name').toString()==>[GraphStep([v[24744]],vertex),VertexStep(OUT,[battled],edge),HasStep([time.gt(1)]),EdgeVertexStep(IN),PropertiesStep  
    gremlin>pluto=g.V().has('name','pluto').next()  
    ==>v[2048]  
    gremlin>g.V(pluto).out('lives').in('lives').values('name')  
    ==>pluto  
    ==>cerberus  
    gremlin>// pluto can't be his own cohabitant  
    gremlin>g.V(pluto).out('lives').in('lives').where(is(neq(pluto))).values('name')  
    ==>cerberusgremlin>g.V(pluto).as('x').out('lives').in('lives').where(neq('x')).values('name')  
    ==>cerberus  
    gremlin>// where do pluto's brothers live?  
    gremlin>g.V(pluto).out('brother').out('lives').values('name')  
    ==>sky  
    ==>sea  
    gremlin>// which brother lives in which place?  
    gremlin>g.V(pluto).out('brother').as('god').out('lives').as('place').select()  
    ==>[god:v[1024],place:v[512]]  
    ==>[god:v[1280],place:v[768]]  
    gremlin>// what is the name of the brother and the name of the place?  
    gremlin>g.V(pluto).out('brother').as('god').out('lives').as('place').select().by('name')  
    ==>[god:jupiter,place:sky]  
    ==>[god:neptune,place:sea]  
    gremlin>g.V(pluto).outE('lives').values('reason')  
    ==>nofearofdeathgremlin>g.E().has('reason',textContains('loves'))  
    ==>e[6xs-sg-m51-e8][1024-lives->512]  
    ==>e[70g-zk-m51-lc][1280-lives->768]  
    gremlin>g.E().has('reason',textContains('loves')).as('source').values('reason').as('reason').select('source').outV().values('name').as('god').select('source').inV().values('name').as('thing').select('god','reason','thing')  
    ==>[god:neptune,reason:loveswaves,thing:sea]  
    ==>[god:jupiter,reason:lovesfreshbreezes,thing:sky]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值