1. 使用LILY HBASE NRT 索引服务
1.1. 确保整个集群范围的HBase复制启用
1.2. 用shell设置column-family的复制功能
a) 对于已存在的表,每个需要建立索引的列簇都需要设置REPLICATION_SCOPE,命令如下:
b) 新建表,用如下命令:
1.3. 创建slor对应的collection
c) 生成实体配置文件
d) 编辑/home/bigdata/xuhailiu/solr/web-collection/conf/schema.xml文件。
为方便调试,取出了文件中自带的一些字段。
注:其中id字段和_version_两个字段必须保留,id作为habse的rowkey,_version_用于版本的区分。
e) 创建 collection 实例并配置文件上传到 zookeeper
$ solrctl instancedir --create web-collection /home/bigdata/xuhailiu/solr/web-collection |
验证操作是否成功:
登录到zookeeper安装的主机,执行客户端脚本登录:
$ /opt/cloudera/parcels/CDH/bin/zookeeper-client |
登录成功后执行命令:
ls /solr/configs/web-collection |
显示结果:
f) 创建collection:
solrctl collection --create web-collection -s 1 -r 2 |
此时可在solr界面上看到创建的collection
1.4. 创建 Lily HBase Indexer 配置
morphline-hbase-mapper.xml
<?xml version="1.0"?> |
Ø Table对应需要映射的hbase表名
Ø Mapper固定值com.ngdata.hbaseindexer.morphline.MorphlineResultToSolrMapper
Ø morphlineFile对应的value为morphlines.conf存放位置
Ø morphlineId 为morphlines.conf文件中morphlines属性 id 值
1.5. 创建morphlines.conf文件
morphlines : [ } { }
|
Ø inputColumn对应hbase中的列簇和列
Ø outputField对应schema.xml文件中Field值
1.6. 上传morphlines.conf文件到Key-ValueStore Indexer的每台主机上
(ps:此处通过Key-Value Store Indexer界面的操作方式,有待研究。)
1.7. 注册 Lily HBase Indexer configuration 和 Lily Hbase Indexer Service
验证操作是否成功:
登录到zookeeper安装的主机,执行命令:
hbase-indexer list-indexers -dump |
显示:
1.8. 向Hbase表中插入数据
$ hbase shell |
solr界面查询结果: