Key-Value Store Indexer
这个组件非常关键,是Hbase到Solr生成索引的中间工具。
Lily HBase Indexer是一款灵活的、可扩展的、高容错的、事务性的,并且近实时的处理HBase列索引数据的分布式服务软件。它是NGDATA公司开发的Lily系统的一部分,已开放源代码。Lily HBase Indexer使用SolrCloud来存储HBase的索引数据,当HBase执行写入、更新或删除操作时,Indexer通过HBase的replication功能来把这些操作抽象成一系列的Event事件,并用来保证写入Solr中的HBase索引数据的一致性。并且Indexer支持用户自定义的抽取,转换规则来索引HBase列数据。Solr搜索结果会包含用户自定义的columnfamily:qualifier字段结果,这样应用程序就可以直接访问HBase的列数据。而且Indexer索引和搜索不会影响HBase运行的稳定性和HBase数据写入的吞吐量,因为索引和搜索过程是完全分开并且异步的。Lily HBase Indexer在CDH5中运行必须依赖HBase、SolrCloud和Zookeeper服务。
1.开启Hbase的复制功能
2、 Hbase表需要开启REPLICATION复制功能
create 'record', {NAME => 'data', REPLICATION_SCOPE => 1}
3、 生成实体配置文件
solrctl instancedir --generate /var/lib/solr/solr_config_search_new
4、编辑/var/lib/solr/solr_config_search_new 下生成好的scheme.xml文件
field 中name是solr中的列名,type是列的类型,indexed是是否建索引,stored是是否存储数据
5、创建collection实例并配置文件上传到zookeeper,命令
solrctl instancedir --create waslog /var/lib/solr/solr_config_search_new
6、上传到zookeeper之后,其他节点就可以从zookeeper下载配置文件。接下来创建collection,命令:
solrctl collection --create waslog -s 15 -r 2 -m 50
7.创建morphline-hbase-mapper.xml配置文件,谁便放在上面路径下。
table 是hbase里面的表名,morphlineId的value,要作为下面Morphlines 文件的ID
wasMap
8、修改Morphlines 文件, 具体操作:进入Key-Value Store Indexer面板->配置->查看和编辑->属性-Morphline文件
morphlines : [
{
id : wasMap
importCommands : ["org.kitesdk.**", "com.ngdata.**"]
commands : [
{
extractHBaseCells {
mappings : [
{
inputColumn : "data:c1"
outputField : "c1"
type : string
source : value
}, {
inputColumn : "data:c2"
outputField : "c2"
type : string
source : value
}
]
}
}
{ logDebug { format : "output record: {}", args : ["@{}"] } }
]
}
]
inputColumn是hbase里面的列族和列
outputField是solr中的列,也就是上面scheme.xml文件配置的field
9、创建hbase-indexer(lily跟solr collection进行关联起来)
hbase-indexer add-indexer \10、往hbase写数据
put 'record', 'row1', 'data:c1', 'value1'