您的位置:首页 > 其它

Titan Graph DataBase 研究 (一)----环境搭建

2017-11-02 13:59 253 查看
from:http://blog.csdn.net/q2365921/article/details/54616249

[-]
弹性和线性可伸缩性的增长数据和用户群
数据分布和复制和容错性能
多数据中心的高可用性和热备份
支持 ACID事务和 最终一致性
支持各种 存储后端
支持全球 图表数据分析 报告和ETL通过集成与大数据平台
支持地理数值范围并通过全文搜索
Titan本身集成 TinkerPop 图堆栈
开源与自由 Apache 2 许可证
解压titanzip并且校验gremlin
下面的示例将打开一个Titan图实例并且载入众神关系数据集

问题1
问题2
问题3
问题4

最近有个与腾讯朋友里二度人脉相关的需求,发觉Titan貌似可以解决这种人际关系相关的数据存储。 

反正将近年末,手头也没有什么工作不如研究研究,以下为Titan的一些特性


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


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


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


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


支持各种 存储后端 :

Apache Cassandra
Apache HBase
Oracle BerkeleyDB


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

Apache Spark
Apache Giraph
Apache Hadoop


支持地理,数值范围,并通过:全文搜索

ElasticSearch
Solr
Lucene


Titan本身集成 TinkerPop 图堆栈:

Gremlin图查询语言
Gremlin图服务器
Gremlin应用程序


开源与自由 Apache 2 许可证。

话不多说,开始进行环境搭建。 

本文编写时Titan的最新版本更新到1.0.0。 

如果有对Titan还不是很明白的请查看Titan官网

http://titan.thinkaurelius.com/

我认为不管如何学习一门新技术都应该先去了解它的安装,下载链接如下

https://github.com/thinkaurelius/titan/wiki/Downloads

我下载的是titan-1.0.0-hadoop2.zip,这个zip包。查看官网Titan最低要求为jdk1.8,如不是1.8的jdk则去下载一个。 

在安装开始说明一下环境配置 

OS:Centos6.4 

jdk:1.8.0_111 

storage:hbase 

index.search:solr5.3.1

下面是安装及配置过程

1. 解压titan.zip并且校验gremlin

unzip titan-1.0.0-hadoop2.zip
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[/code]1 2
3

如果使用hadoop2的安装包需要引入titan-hadoop-1.0.0.jar否则报如下异常
Invalid import definition: 'com.thinkaurelius.titan.hadoop.MapReduceIndexManagement'; reason: startup failed:
script14719348643282042298222.groovy: 1: unable to resolve class com.thinkaurelius.titan.hadoop.MapReduceIndexManagement
@ line 1, column 1.
import com.thinkaurelius.titan.hadoop.MapReduceIndexManagement
^

1 error
1
2
3
4
5
6
7

启动gremlin
cd titan-1.0.0-hadoop2/bin
./gremlin.sh
#启动gremlin shell 本文作者也不了解gremlin如有兴趣的可自行百度,把他当做一个模拟shell就好了,可以执行一些Titan命令,创建一些图实例。
gremlin> 100-10
==>90
gremlin> "Titan:" + " The Rise of Big Graph Data"
==>Titan: The Rise of Big Graph Data
gremlin> [name:'aurelius', vocation:['philosopher', 'emperor']]
==>name=aurelius
==>vocation=[philosopher, emperor]
1
2
3
4
5
6
7
8
9
10

2. 下面的示例将打开一个Titan图实例并且载入众神关系数据集


Titanfactory提供了一组静态开放的方法,其中每个需要配置的参数并返回一个图实例,由于官网上提供的实例是以BerkeleyDB 为数据后端,以 Elasticsearch为索引后端,但笔者并没有这两种环境,恰好Titan支持Hbase数据后端与Solr索引后端的配置方式,那么就以这两种组件做为后端进行配置,修改$TITAN_HOME/conf/titan-hbase-solr.properties文件如下,由于配置文件中注释过多,只把主要配置贴了出来
storage.backend=hbase

storage.hostname=hadoop1,hadoop2,hadoop3,hadoop4,hadoop5

index.search.backend=solr

index.search.solr.mode=cloud

index.search.solr.configset=titan

index.search.solr.zookeeper-url=solr1:2181,solr2:2181,solr3:2181,solr4:2181,solr5:2181
1
2
3
4
5
6
7
8
9
10
11
12

Titan所有支持的配置请参考下文

http://s3.thinkaurelius.com/docs/titan/1.0.0/titan-config-ref.html

Storage BackEnds的安装及配置请参考下文
http://s3.thinkaurelius. f0ff
com/docs/titan/1.0.0/storage-backends.html

配置好数据端后则开始导入众神关系数据集
gremlin> graph = TitanFactory.open('../conf/titan-hbase-solr.properties')
==>standardtitangraph[hbase:[hadoop1, hadoop2, hadoop3, hadoop4, hadoop5]]
#在执行下面语句之前需要以$TITAN_HOME/conf/solr文件,建立solrCollection,并且在titan-hbase-solr.properties中添加index.search.solr.configset=titanconfigset配置
gremlin> GraphOfTheGodsFactory.load(graph)
==>null
gremlin> g = graph.traversal()
==>graphtraversalsource[standardtitangraph[berkeleyje:../db/berkeley], standard]
1
2
3
4
5
6
7


问题1

在执行过程中报出如下错误
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.<init>(ConnectionManager.java:623)
... 59 more
Caused by: java.lang.UnsupportedOperationException: Not implemented by the DistributedFileSystem FileSystem implementation
at org.apache.hadoop.fs.FileSystem.getScheme(FileSystem.java:214)
at org.apache.hadoop.fs.FileSystem.loadFileSystems(FileSystem.java:2559)
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2569)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2586)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:89)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2625)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2607)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:368)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:167)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:352)
at org.apache.hadoop.fs.Path.getFileSystem(Path.java:296)
at org.apache.hadoop.hbase.util.DynamicClassLoader.<init>(DynamicClassLoader.java:104)
at org.apache.hadoop.hbase.protobuf.ProtobufUtil.<clinit>(ProtobufUtil.java:232)
... 64 more
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

该错误解决方法是将Titan中的hadoop-core.jar替换为对应Hadoop backends的core.jar,我替换的是hadoop-mapreduce-client-core-2.6.0-cdh5.8.0.jar


问题2

如solrCloud中不包含jts-*.jar,则将$TITAN_HOME/lib/jst-1.13.jar复制到solr的lib目录中,并且重启solr集群


问题3

如Solr版本不是solr5.2.1,则按实际情况修改源码,笔者的solr版本为5.3.1,当将solr-solrj-5.2.1.jar替换为solr-solrj-5.3.1.jar后抛出异常,由于5.3.1中 

zkStateReader.updateClusterState不存在有参函数故报错,我又替换为solrj-solr5.2.1.jar 经测试通过

titan/titan-solr/src/main/java/com/thinkaurelius/titan/diskstorage/solr/SolrIndex.java

/**
* Checks if the collection has already been created in Solr.
*/
private static boolean checkIfCollectionExists(CloudSolrClient server, String collection) throws KeeperException, InterruptedException {
ZkStateReader zkStateReader = server.getZkStateReader();
zkStateReader.updateClusterState(true);
ClusterState clusterState = zkStateReader.getClusterState();
return clusterState.getCollectionOrNull(collection) != null;
}
1
2
3
4
5
6
7
8
9


问题4

如报如下异常
com.thinkaurelius.titan.core.SchemaViolationException: Adding this property for key [~T$SchemaName] and value [rtname] violates a uniqueness constraint [SystemIndex#~T$SchemaName]
1

将hbase中的titan表的数据清理,该异常为多次构建backend造成的 

Stack Overflow 的说明如下

http://stackoverflow.com/questions/32938486/error-while-trying-to-use-indexes-in-titan-graph-db
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: