zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    常用正则表达式
    java中的异或运算
    Eclipse 中,web项目在Tomcat运行时填写不了Server name
    错误: 找不到或无法加载主类 tomcat-juli.jar
    Hadoop学习之Ubuntu12.04 Hadoop 环境搭建笔记
    ubuntu安装 cober 笔记
    Ubuntu中安装JDK
    对象调用很容易忽视的地址问题
    2018.09.27_练习时的tips
    网页的组成(一)
  • 原文地址:https://www.cnblogs.com/wanchen-chen/p/12934093.html
Copyright © 2011-2022 走看看