CDH6 高版本hbase+solr實現二級索引

以前的環境是單獨下載的CDH組件包搭建的集羣,可是由於hadoop版本太低致使漏洞沒法修復,從新搭建高版本集羣環境。java

新集羣環境:shell

主要組件:hadoop,hbase,zookeeper,Key-Value Store Indexervim

 

1.建立hbase表:oop

hbase shell
create 'users', { NAME => 'info', REPLICATION_SCOPE => '1' }

2.使用CDH建立solr集合並修改配置:ui

1)建立solr實體配置文件本地目錄,tsolr會自動建立

# solrctl instancedir --generate /opt/tsolr

建立後會在tsolr目錄下生成一個conf文件夾,裏面是相關配置文件。


2)編輯conf文件夾裏的managed-schema文件,hbase表中須要索引的列對應managed-schema的filed節點
例:
<field name="firstname_s" type="string" indexed="true" stored="true" required="false" multiValued="false" />
   <field name="lastname_s" type="string" indexed="true" stored="true" required="false" multiValued="false" />
   <field name="age_i" type="string" indexed="true" stored="true" required="true" multiValued="false" />

注意:conf中的solrConfig.xml能夠設置提交方式。設置方式參考:https://blog.csdn.net/qq_40570699/article/details/100560066


3)建立collection實例並配置文件上傳到zookeeper

# solrctl instancedir --create tsolr /opt/tsolr

注意:以前若是有建立過,須要先刪除再建立,或者覆蓋更新

(# solrctl instancedir --update tsolr /opt/tsolr)


4)上傳到zookeeper以後,其餘節點就能夠從zookeeper下載配置文件。接着建立collection

# solrctl collection --create tsolr -s 15 -r 2 -m 50
(紅色參數表示s表示設置Shard數爲15,-r表示設置的replica數爲2,-m表示最大shards數目,collection名稱是tsolr!)

3.建立indexer模板,而且執行indexer任務:.net

1.編輯 vim /opt/tsolr/users.xml
<?xml version="1.0"?>
<indexer table="indexdemo-user">
  <field name="firstname_s" value="info:firstname"/>
  <field name="lastname_s" value="info:lastname"/>
  <field name="age_i" value="info:age" type="int"/>
</indexer>

2.執行hbase-indexer
cd /opt/cloudera/parcels/CDH-6.0.0-xxxxx/bin
../hbase-indexer add-indexer -n myindexer -c demo/user_indexer.xml -cp solr.zk=flzxldyjdata1:2181,flzxldyjdata2:2181,flzxldyjdata3:2181,flzxldyjdata4:2181,flzxldyjdata5:2181/solr -cp solr.collection=collection1
相關文章
相關標籤/搜索