日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2024/8/23 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CDH 6 安装 Hbase 二级索引 Solr + Key-Value Store Indexer 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

目錄

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

二、創(chuàng)建Hbase二級(jí)索引

1.更改表結(jié)構(gòu),允許復(fù)制

2.創(chuàng)建相應(yīng)的SolrCloud集合

3.創(chuàng)建 collection實(shí)例并將配置文件上傳到 zookeeper

?4.創(chuàng)建 Lily HBase Indexer 配置

5.配置Morphline文件

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

7.重啟?Key-Value Store Indexer 服務(wù)

三、命令匯總

1.列出所有 Hbase indexer

2.刪除 Hbase indexer

3.列出 Solr 所有 collection

4.清空 Solr collection 中所有數(shù)據(jù)

5.刪除 Solr collection?

6.列出 Solr 所有 instancedir

7.刪除 Solr?instancedir

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

9.創(chuàng)建?instancedir

10. 創(chuàng)建 Solr collection

11. 創(chuàng)建 Hbase Indexer

12.更新 Solr?instancedir 配置

13.更新 Solr collection配置

14.更新 Hbase Indexer


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

? ? ? 先安裝Solr ,再安裝Key-Value Store Indexer ,安裝節(jié)點(diǎn)和hbase,hdfs在相同節(jié)點(diǎn)。

二、創(chuàng)建Hbase二級(jí)索引

1.更改表結(jié)構(gòu),允許復(fù)制

已存在的表 disable 'tableName' alter 'tableName',{NAME =>'fn', REPLICATION_SCOPE =>1} enable 'tableName' 不存在的表 create ‘table‘,{NAME =>‘cf‘, REPLICATION_SCOPE =>1} #其中1表示開啟replication功能,0表示不開啟,默認(rèn)為0

2.創(chuàng)建相應(yīng)的SolrCloud集合


這里得路徑和用戶名都可以自己定義

# 生成實(shí)體配置文件:solrctl instancedir --generate /opt/hbase-indexer/index1

進(jìn)入?~/hbase-indexer/user_index 目錄下的conf目錄,將managed-schema 文件復(fù)制為?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屬性對應(yīng)。 type:字段類型 indexed:是否建立索引 stored:是否存儲(chǔ)

注意:這里name字段它對應(yīng)了我們后續(xù)需要修改Morphline.conf文件中的outputField屬性。因此可以看成是hbase中需要?jiǎng)?chuàng)建索引的值。因此我們建議將其與表名和列族結(jié)合,格式建議如下:

HBase_Indexer_ZDTable_fn_name Hbase_indexer_表名_列簇_列名

再修改solrconfig.xml,找到下面的配置將false改為true,這個(gè)是硬提交,會(huì)影響性能

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

創(chuàng)建

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

3.創(chuàng)建 collection實(shí)例并將配置文件上傳到 zookeeper

solrctl collection --create index1如果希望將數(shù)據(jù)分散到各個(gè)節(jié)點(diǎn)進(jìn)行存儲(chǔ)和檢索,則需要?jiǎng)?chuàng)建多個(gè)shard,需要使用如下命令solrctl collection --create index1 -s 7 -r 3 -m 21其中-s表示設(shè)置Shard數(shù)為7,-r表示設(shè)置的replica數(shù)為3,-m表示最大shards數(shù)目(7*3)

?4.創(chuàng)建 Lily HBase Indexer 配置

創(chuàng)建文件?morphline-hbase-mapper.xml?

[root@test119 index1]# cat morphline-hbase-mapper.xml <?xml version="1.0"?> <!-- table:需要索引的HBase表名稱--> <!-- mapper:用來實(shí)現(xiàn)和讀取指定的Morphline配置文件類,固定為MorphlineResultToSolrMapper--> <indexer table="hbase_tableName" mapper="com.ngdata.hbaseindexer.morphline.MorphlineResultToSolrMapper" read-row="never" > <!--param中的name參數(shù)用來指定當(dāng)前配置為morphlineFile文件 --> <!--value用來指定morphlines.conf文件的路徑,絕對或者相對路徑用來指定本地路徑,如果是使用Cloudera Manager來管理morphlines.conf就直接寫入值morphlines.conf"--><param name="morphlineFile" value="morphlines.conf"/> <!--value="ZDTableMap",這里test3Map是自定義,接下來要使用。其他的mapper,param name等屬性默認(rèn)即可--><param name="morphlineId" value="JastTableMap"/> </indexer>

5.配置Morphline文件

進(jìn)入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 : ["@{}"] } } ] } ]

上面設(shè)置類型都是string(根據(jù)數(shù)據(jù)會(huì)自動(dòng)轉(zhuǎn)換),如果需要設(shè)置int類型可以參考:?

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

注:

id:表示當(dāng)前morphlines的名稱,與上一步的value="JastTableMap"要一致importCommands:需要引入的命令包地址extractHBaseCells:該命令用來讀取HBase列數(shù)據(jù)并寫入到SolrInputDocument對象中,該命令必須包含零個(gè)或者多個(gè)mappings命令對象。mappings:用來指定HBase列限定符的字段映射。inputColumn:需要寫入到solr中的HBase列字段。值包含列族和列限定符,并用‘ : ’分開。其中列限定符也可以使用通配符*來表示,譬如可以使用c1:*表示讀取只要列族為data的所有hbase列數(shù)據(jù),也可以通過c1:na*來表示讀取列族為c1列限定符已na開頭的字段值.outputField:用來表示morphline讀取的記錄需要輸出的數(shù)據(jù)字段名稱,該名稱必須和solr中的schema.xml文件的field節(jié)點(diǎn)自定義的name名稱保持一致,否則寫入不正確type:用來定義讀取HBase數(shù)據(jù)的數(shù)據(jù)類型,HBase中的數(shù)據(jù)都是以byte[]的形式保存,但是所有的內(nèi)容在Solr中索引為text形式,所以需要一個(gè)方法來把byte[]類型轉(zhuǎn)換為實(shí)際的數(shù)據(jù)類型。type參數(shù)的值就是用來做這件事情的。現(xiàn)在支持的數(shù)據(jù)類型有:byte,int,long,string,boolean,float,double,short和bigdecimal。當(dāng)然你也可以指定自定的數(shù)據(jù)類型,只需要實(shí)現(xiàn)com.ngdata.hbaseindexer.parse.ByteArrayValueMapper接口即可實(shí)現(xiàn)接口可參考:?https://datamining.blog.csdn.net/article/details/103566964?source:用來指定HBase的KeyValue那一部分作為索引輸入數(shù)據(jù),可選的有‘value’和'qualifier',當(dāng)為value的時(shí)候表示使用HBase的列值作為索引輸入,當(dāng)為qualifier的時(shí)候表示使用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 服務(wù)

此時(shí)往hbase中插入數(shù)據(jù),可以自動(dòng)同步至 Solr 中,Solr Collection 為上面創(chuàng)建的 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 中所有數(shù)據(jù)

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.創(chuàng)建?instancedir

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

10. 創(chuàng)建 Solr collection

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

11. 創(chuàng)建 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:服務(wù)異常退出,查看日志發(fā)現(xiàn)沒報(bào)錯(cuò)

從服務(wù)器查看日志沒有異常,通過CDH查看日志發(fā)現(xiàn)內(nèi)存不足,在搭建集群時(shí)候,Key-Value Store Indexer 與 Solr 都要給夠相關(guān)內(nèi)存,具體大小根據(jù)實(shí)際情況來測試

Key-Value Store Indexer? 的配置參數(shù):

? ??Lily HBase Indexer 的 Java 堆棧大小(字節(jié))

Solr 的配置參數(shù)

總結(jié)

以上是生活随笔為你收集整理的CDH 6 安装 Hbase 二级索引 Solr + Key-Value Store Indexer的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。