• CDH6 高版本hbase+solr实现二级索引


    之前的环境是单独下载的CDH组件包搭建的集群,但是因为hadoop版本过低导致漏洞无法修复,重新搭建高版本集群环境。

    新集群环境:

    主要组件:hadoop,hbase,zookeeper,Key-Value Store Indexer

    1.创建hbase表:

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

    2.使用CDH创建solr集合并修改配置:

    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任务:

    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
  • 相关阅读:
    在 Eclipse Workbench 之外使用 Eclipse GUI
    GB2312,GBK,Unicode
    木偶一之推荐系统
    Matlab:任意矩阵计算分布密度(海明距离的分布密度)
    live555在arm linux下的交叉编译,并下载的Arm板播放H264文件
    java设计模式之原型模式
    HDU 1102
    poj3661另一种做法(滚动数组)
    基于QT的小游戏细菌病毒战
    某代码查看器的保护突破
  • 原文地址:https://www.cnblogs.com/wanchen-chen/p/12934093.html
Copyright © 2020-2023  润新知