一、Cloudera Manager安裝如下插件
二错森;HBase部分
1;HBase需要開啟復制功能
?
2疫衩;建表
新建表涩维,需要開啟復本功能:
create "person_data",{NAME => "info", REPLICATION_SCOPE => 1}
如果表已存在:
disable ‘表名’
alter ‘表名’,{NAME => ‘列族名’, REPLICATION_SCOPE => 1}
enable ‘表名’
三患膛;SolrCloud部分
1;創(chuàng)建solrCloud
solrctl --zk xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181/solr instancedir --generate /opt/hbaseSolrConf
2;修改配置文件/opt/hbaseSolrConf/conf/schemal.xml
name:屬性的名稱人断,這里有個特殊的屬性“version”是必須添加的吭从。
type:字段的數(shù)據(jù)結(jié)構(gòu)類型,所用到的類型需要在fieldType中設置含鳞。
indexed:是否創(chuàng)建索引影锈。
stored:是否存儲原始數(shù)據(jù)芹务。如果不需要返回該字段而只需要通過該字段索引蝉绷,則可設置為false。
required:添加文檔時枣抱,該字段必須存在熔吗,類似mysql的not null。
3佳晶;初始化collection
solrctl --zk xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181/solr instancedir --create personDataCollection /opt/hbaseSolrConf/conf
4桅狠;新建collection
solrctl --zk xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181/solr collection --create personDataCollection -s 3 -r 2 -m 8
-s表示設置分片Shard數(shù)為3,建議設置為SolrCloud集群的機器數(shù)
-r表示設置的Replica數(shù)為1轿秧,創(chuàng)建的副本數(shù)為1中跌,建議設置為2及其以上
-m默認值是1,表示最大shards數(shù)目菇篡,應大于Shard*Replica
-c是指定zk上solr/configs節(jié)點下使用的配置文件名稱
-a是允許添加副本
5漩符;查看是否創(chuàng)建成功
solrctl --zk xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181/solr collection --list
四;HBase Index部分
1;在CMweb端驱还,修改Morphline配置文件(修改完后嗜暴,需要重啟生效,若需要針對多個列族或多個表創(chuàng)建索引议蟆,則可以增加morphlines闷沥,每個morphlines之間以逗號進行分隔。)
2咐容;2舆逃;修改morphline-hbase-mapper-personData.xml,并上傳至/opt/hbaseSolrConf
(file://C:\Users\root\AppData\Local\Temp\enhtmlclip\morphline-hbase-mapper-personData.xml)
3;添加Index
hbase-indexer add-indexer
--name personDataIndex
--indexer-conf /opt/hbaseSolrConf/morphline-hbase-mapper-personData.xml
--connection-param solr.zk=xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181/solr
--connection-param solr.collection=personDataCollection
--zookeeper xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181
4;查看Index
hbase-indexer list-indexers --zookeeper xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181
同步歷史數(shù)據(jù):
hadoop --config /etc/hadoop/conf.cloudera.yarn \
jar /opt/cloudera/parcels/CDH/lib/hbase-solr/tools/hbase-indexer-mr-*-job.jar \
-D 'mapred.child.java.opts=-Xmx1024m' \
--conf /etc/hbase/conf/hbase-site.xml \
--log4j /opt/cloudera/parcels/CDH/share/doc/search*/examples/solr-nrt/log4j.properties \
--hbase-indexer-file /opt/hbaseSolrConf/morphline-hbase-mapper-personData.xml \
--morphline-file /opt/hbaseSolrConf/morphlines.conf \(備注:將上面的Morphline配置文件復制一份即可)
--verbose \
--go-live \
--zk xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181/solr \
--collection personDataCollection
刪除索引:
1路狮;刪除Index
hbase-indexer delete-indexer --name personDataIndex --zookeeper xuehai-dn:2181,xuehai-nn:2181,xuehai-cm:2181
2鸟雏;刪除collection所有的doc
solrctl collection --deletedocs personDataCollection
3;刪除collection
solrctl collection --delete personDataCollection
4览祖;刪除instancedir
solrctl instancedir --delete personDataCollection
上述指令會將Collection進行刪除孝鹊,并將zookeeper中包含該Collection信息的collection和config進行清空。
如果需要徹底刪除某個Collection展蒂,需按順序執(zhí)行以上四條指令又活,并將/opt/hbaseSolrConf清空,即刪除掉schema.xml
參考:
https://blog.csdn.net/qq_34842671/article/details/86496983