CDH 6 安装 Hbase 二级索引 Solr + Key-Value Store Indexer

目录

一、集群安装Solr +  Key-Value Store Indexer

二、创建Hbase二级索引

1.更改表结构,允许复制

2.创建相应的SolrCloud集合

3.创建 collection实例并将配置文件上传到 zookeeper

 4.创建 Lily HBase Indexer 配置

5.配置Morphline文件

6.注册 Lily HBase Indexer Configuration 和 Lily HBase Indexer Service

7.重启 Key-Value Store Indexer 服务

三、命令汇总

1.列出所有 Hbase indexer

2.删除 Hbase indexer

3.列出 Solr 所有 collection

4.清空 Solr collection 中所有数据

5.删除 Solr collection 

6.列出 Solr 所有 instancedir

7.删除 Solr instancedir

8.初始化生成 instancedir 配置文件

9.创建 instancedir

10. 创建 Solr collection

11. 创建 Hbase Indexer

12.更新 Solr instancedir 配置

13.更新 Solr collection配置

14.更新 Hbase Indexer


一、集群安装Solr +  Key-Value Store Indexer

      先安装Solr ,再安装Key-Value Store Indexer ,安装节点和hbase,hdfs在相同节点。

二、创建Hbase二级索引

1.更改表结构,允许复制

已存在的表
disable 'tableName'
alter 'tableName',{NAME =>'fn', REPLICATION_SCOPE =>1}
enable 'tableName'
不存在的表
create ‘table‘,{NAME =>‘cf‘, REPLICATION_SCOPE =>1}
#其中1表示开启replication功能,0表示不开启,默认为0

2.创建相应的SolrCloud集合


这里得路径和用户名都可以自己定义

# 生成实体配置文件:solrctl instancedir --generate /opt/hbase-indexer/index1

进入 ~/hbase-indexer/user_index 目录下的conf目录,将managed-schema 文件复制为 schema.xml

cp managed-schema schema.xml

在schema.xml文件中加入

<field name="HBase_Indexer_Test_cf1_name" type="string" indexed="true" stored="true"/>
属性解析:
name:这里的name是自定义,但是后面要使用到,要和后面的Morphline.conf文件中的outputField属性对应。
type:字段类型
indexed:是否建立索引
stored:是否存储

注意:这里name字段它对应了我们后续需要修改Morphline.conf文件中的outputField属性。因此可以看成是hbase中需要创建索引的值。因此我们建议将其与表名和列族结合,格式建议如下:

HBase_Indexer_ZDTable_fn_name
Hbase_indexer_表名_列簇_列名

再修改solrconfig.xml,找到下面的配置将false改为true,这个是硬提交,会影响性能

    <autoCommit><maxTime>${solr.autoCommit.maxTime:60000}</maxTime><openSearcher>true</openSearcher></autoCommit>

创建

solrctl instancedir --create index1 /home/jast/opt/hbase-indexer/index1

3.创建 collection实例并将配置文件上传到 zookeeper

solrctl collection --create index1如果希望将数据分散到各个节点进行存储和检索,则需要创建多个shard,需要使用如下命令solrctl collection --create index1 -s 7 -r 3 -m 21其中-s表示设置Shard数为7,-r表示设置的replica数为3,-m表示最大shards数目(7*3)

 4.创建 Lily HBase Indexer 配置

创建文件 morphline-hbase-mapper.xml 

[root@test119 index1]# cat morphline-hbase-mapper.xml 
<?xml version="1.0"?>
<!-- table:需要索引的HBase表名称-->
<!-- mapper:用来实现和读取指定的Morphline配置文件类,固定为MorphlineResultToSolrMapper-->
<indexer table="hbase_tableName" mapper="com.ngdata.hbaseindexer.morphline.MorphlineResultToSolrMapper" read-row="never" >
<!--param中的name参数用来指定当前配置为morphlineFile文件 -->
<!--value用来指定morphlines.conf文件的路径,绝对或者相对路径用来指定本地路径,如果是使用Cloudera Manager来管理morphlines.conf就直接写入值morphlines.conf"--><param name="morphlineFile" value="morphlines.conf"/>
<!--value="ZDTableMap",这里test3Map是自定义,接下来要使用。其他的mapper,param name等属性默认即可--><param name="morphlineId" value="JastTableMap"/>
</indexer>

5.配置Morphline文件

进入CM管理界面中 Key-Value Store Indexer,修改 Morphline文件

SOLR_LOCATOR : {# Name of solr collectioncollection : hbaseindexer# ZooKeeper ensemblezkHost : "$ZK_HOST" 
}morphlines : [
{
id : JastTableMap
importCommands : ["org.kitesdk.**", "com.ngdata.**"]commands : [                    {extractHBaseCells {mappings : [{inputColumn : "fn:name"outputField : "hbase_indexer_vt_fn_name" type : string source : value},{inputColumn : "fn:comments_count"outputField : "hbase_indexer_vt_fn_comments_count" type : stringsource : value},{inputColumn : "fn:text"outputField : "hbase_indexer_vt_fn_text" type : stringsource : value}]}}{ logDebug { format : "output record: {}", args : ["@{}"] } }
]
}
]

上面设置类型都是string(根据数据会自动转换),如果需要设置int类型可以参考: 

 https://datamining.blog.csdn.net/article/details/103566964 

注:

id:表示当前morphlines的名称,与上一步的value="JastTableMap"要一致importCommands:需要引入的命令包地址extractHBaseCells:该命令用来读取HBase列数据并写入到SolrInputDocument对象中,该命令必须包含零个或者多个mappings命令对象。mappings:用来指定HBase列限定符的字段映射。inputColumn:需要写入到solr中的HBase列字段。值包含列族和列限定符,并用‘ : ’分开。其中列限定符也可以使用通配符*来表示,譬如可以使用c1:*表示读取只要列族为data的所有hbase列数据,也可以通过c1:na*来表示读取列族为c1列限定符已na开头的字段值.outputField:用来表示morphline读取的记录需要输出的数据字段名称,该名称必须和solr中的schema.xml文件的field节点自定义的name名称保持一致,否则写入不正确type:用来定义读取HBase数据的数据类型,HBase中的数据都是以byte[]的形式保存,但是所有的内容在Solr中索引为text形式,所以需要一个方法来把byte[]类型转换为实际的数据类型。type参数的值就是用来做这件事情的。现在支持的数据类型有:byte,int,long,string,boolean,float,double,short和bigdecimal。当然你也可以指定自定的数据类型,只需要实现com.ngdata.hbaseindexer.parse.ByteArrayValueMapper接口即可实现接口可参考: https://datamining.blog.csdn.net/article/details/103566964 source:用来指定HBase的KeyValue那一部分作为索引输入数据,可选的有‘value’和'qualifier',当为value的时候表示使用HBase的列值作为索引输入,当为qualifier的时候表示使用HBase的列限定符作为索引输入

 

6.注册 Lily HBase Indexer Configuration 和 Lily HBase Indexer Service

hbase-indexer add-indexer \
--name ZDindexer \
--indexer-conf /opt/hbase-indexer/index1/morphline-hbase-mapper.xml --connection-param solr.zk=test110:2181,test115:2181,test119:2181/solr \
--connection-param solr.collection=index1 \
--zookeeper test110:2181,test115:2181,test119:2181

注:这里的name可以随便起,solr.collection 要与上面的相同

7.重启 Key-Value Store Indexer 服务

此时往hbase中插入数据,可以自动同步至 Solr 中,Solr Collection 为上面创建的 index1

solr查看页面:http://ip:8983

 

三、命令汇总

1.列出所有 Hbase indexer

hbase-indexer list-indexers --zookeeper hostname:2181

2.删除 Hbase indexer

hbase-indexer delete-indexer --name TESTindexer --zookeeper hostname1:2181,hostname2:2181,hostname3:2181

3.列出 Solr 所有 collection

solrctl collection --list

4.清空 Solr collection 中所有数据

solrctl collection --deletedocs vt_index

5.删除 Solr collection 

solrctl collection --delete vt_index

6.列出 Solr 所有 instancedir

solrctl instancedir --list 

7.删除 Solr instancedir

solrctl instancedir --delete vt_index

8.初始化生成 instancedir 配置文件

solrctl instancedir --generate /home/jast/opt/hbase-indexer/index1

9.创建 instancedir

solrctl instancedir --create index1 /home/jast/opt/hbase-indexer/index1

10. 创建 Solr collection

solrctl collection --create index1 -s 3 -r 1 -m 3

11. 创建 Hbase Indexer

hbase-indexer add-indexer \
--name TESTindexer \
--indexer-conf ~/opt/hbase-indexer/morphline-hbase-mapper.xml --connection-param solr.zk=hostname1:2181,hostname2:2181,hostname3:2181/solr \
--connection-param solr.collection=index1\
--zookeeper hostname1:2181,hostname2:2181,hostname3:2181

12.更新 Solr instancedir 配置

solrctl instancedir --update index1/home/jast/opt/hbase-indexer/index1

13.更新 Solr collection配置

solrctl collection --reload index1

14.更新 Hbase Indexer

hbase-indexer update-indexer -n index1

 

常见问题

问题1:服务异常退出,查看日志发现没报错

从服务器查看日志没有异常,通过CDH查看日志发现内存不足,在搭建集群时候,Key-Value Store Indexer 与 Solr 都要给够相关内存,具体大小根据实际情况来测试

Key-Value Store Indexer  的配置参数:

    Lily HBase Indexer 的 Java 堆栈大小(字节)

Solr 的配置参数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/509835.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

glClipPlane剪裁平面

glClipPlane裁剪平面 (2012-02-21 12:49:18) 转载▼标签&#xff1a; 半平面 裁剪 线框 球体 表示 杂谈 分类&#xff1a; OPENGL void glClipPlane(GLenum plane, const GLdouble *equation); 定义一个裁剪平面。equation参数指向平面方程Ax By Cz D …

html思维导图

网页版&#xff1a;https://www.processon.com/view/link/5a658afae4b010a6e728e492

Hbase Solr 二级索引,更新数据部分字段丢失问题

问题&#xff1a; 第一次往hbase put数据&#xff0c;索引同步三个字段&#xff0c;第二次更新hbase数据&#xff0c;只更新一个字段&#xff0c;其他两个字段会消失。 原因&#xff1a; 在创建Hbase Indexer 时我们配置文件指定了 read-row"never" $ cat morphl…

c#事件和委托

一、委托(Delegate) 1、定义 delegate是C#中的一种类型&#xff0c;它实际上是一个能够持有对某个方法的引用的类。与其它的类不同&#xff0c;delegate类能够 拥有一个签名&#xff08;signature&#xff09;&#xff0c;并且它"只能持有与它的签名相匹配的方法的引用&qu…

Hbase二级索引 Solr 异常 The most likely cause is another Solr server (or another solr core in this server)

solr查询数据时候报错&#xff0c;去服务器查看该节点日志 {"responseHeader":{"status":503,"QTime":3,"params":{"q":"*:*","_":"1576753724528"}},"error":{"metadata&q…

MonoBehaviour常用方法

1.Start()在Update方法被调用之前开始调用Start方法&#xff0c;而且Start方法在整个MonoBehaviour生命周期内只被调用一次。Awake和Start不同的地方在于Start方法仅仅在脚本初始化后被调用&#xff0c;这样允许你延迟加载任何代码&#xff0c;直到代码真正被使用时。Awake方法…

Hbase RegionServer 启动失败 Time difference of xxx ms max allowed of 30000ms

Hbase RegionServer 启动报错 异常如下&#xff1a; STOPPED: Unhandled: org.apache.hadoop.hbase.ClockOutOfSyncException: Server hostname13,16020,1576647671625 has been rejected; Reported time is too far out of sync with master. Time difference of 32345ms …

unity3d UGUI视频教程

http://forum.china.unity3d.com/home.php?modspace&uid3418&dothread&viewme&typethread&orderdateline&fromspace&page1

CDH6.x Solr7.x 集成 Ik 分词

下载ik相关jar包&#xff1a; 链接&#xff1a;https://pan.baidu.com/s/19fydKWw15g8rPg4LW1cOtw 提取码&#xff1a;f2l8 在CDH安装目录下 查找CDH6 solr 的启动目录 [roothostname1 ~]# find /opt -name WEB-INF |grep solr /opt/cloudera/parcels/CDH-6.0.0-1.cdh6.0.0.p…

java Switch里面的类型问题

switch中可以为以下几种类型&#xff1a; byte、short、int注意没有longchar、string(jdk 1.7版本之后的 )枚举类型 Java 7之前&#xff0c;switch后面的括号里面只能放int类型的值&#xff0c;注意是只能放int类型&#xff0c;但是放byte&#xff0c;short&#xff0c;char类…

Unity3d常用插件

1,UI插件 - NGUI 3.9.2http://pan.baidu.com/s/1o6kst662,地图编辑器 - Tiled Map Editorhttp://www.mapeditor.org/download.html3,A*寻路插件 - A* Pathfinding Project Pro 3.7 最新版http://pan.baidu.com/s/1nty759n4,可视化脚本工具 - Playmaker 1.7.8 最新版http://pan.…

Solr 基础性能调优讲解

本篇文章我们来了解一下solr的性能方面的调优&#xff0c;分为Schema优化、索引更新与提交调优、索引合并性能调优、Solr缓存、Solr查询性能优化 Schema优化 1、indextrue比indexfalse在索引时占用更多的内存、索引合并和优化时间更长&#xff0c;索引体积也响应变的更大&…

C语言有参函数调用时参数值传递问题

http://blog.csdn.net/hehuimin6/article/details/38800459

Solr router 路由介绍

目录 1、compositeId路由 1.1、compositeId路由原理 1.2、compositeId路由查询 2、implicit路由 2.1、implicit路由原理 2.2、implicit路由查询 3、扩展 3.1、compositeId路由方式扩展 3.2、implicit路由方式扩张 solrcloud的官方文档有对路由的简短介绍&#xff0c;但…

行为树的原理及实现

查阅了一些行为树资料&#xff0c;目前最主要是参考了这篇文章&#xff0c;看完后感觉行为树实乃强大&#xff0c;绝对是替代状态机的不二之选。但从理论看起来很简单的行为树&#xff0c;真正着手起来却发现很多细节无从下手。 总结起来&#xff0c;就是&#xff1a; 1、行为树…

Unity 3D中的射线与碰撞检测

在我们的游戏开发过程中&#xff0c;有一个很重要的工作就是进行碰撞检测。例如在射击游戏中子弹是否击中敌人&#xff0c;在RPG游戏中是否捡到装备等等。在进行碰撞检测时&#xff0c;我们最常用的工具就是射线&#xff0c;Unity 3D的物理引擎也为我们提供了射线类以及相关的函…

图数据库 HugeGraph : IndexLabel

IndexLabel 用来定义索引类型&#xff0c;描述索引的约束信息&#xff0c;主要是为了方便查询。 IndexLabel 允许定义的约束信息包括&#xff1a;name、baseType、baseValue、indexFeilds、indexType&#xff0c;下面逐一介绍。 name: 属性的名字&#xff0c;用来区分不同的 …

boost常用库

1.boost::any boost::any是一种通用的数据类型&#xff0c;可以将各种类型包装后统一放入容器内&#xff0c;最重要的它是类型安全的。有点象COM里面的variant。 使用方法&#xff1a; any::type() 返回包装的类型 any_cast可用于any到其他类型的转化 #include <boost/any.h…

HugeGraphServer 部署安装

官方文档链接&#xff1a;https://hugegraph.github.io/hugegraph-doc HugeGraphServer Quick Start 1 概述 HugeGraph-Server 是 HugeGraph 项目的核心部分&#xff0c;包含Core、Backend、API等子模块。 Core模块是Tinkerpop接口的实现&#xff0c;Backend模块用于管理数…