zoukankan      html  css  js  c++  java
  • solr 创建指定路由的collection

    1.登录solr其中一个实例所在的主机

    2.生成配置文件
    $ solrctl instancedir --generate $HOME/solr_configs
    修改solrconfig.xml 和 schema.xml
    3.上传配置到zk
    $ solrctl instancedir --create <collection_name> $HOME/solr_configs
    查看
    $ solrctl instancedir --list
    4.创建collections

    隐式路由
    $ solrctl collection --create <collection_name> -s <shard_count> -r <replica_count> -m <count>

    solrctl instancedir --generate $HOME/suggest
    solrctl instancedir --create suggest $HOME/suggest
    solrctl collection --create suggest -s 2 -r 2 -m 2
    solrctl instancedir --update suggest  $HOME/suggest
    solrctl collection --reload suggest
    

      

    或者:

    显式路由的

    http://10.90.16.156:8983/solr/admin/collections?action=CREATE&name=goods&router.name=implicit&shards=shard1&replicationFactor=2&router.field=category&maxShardsPerNode=2

    maxShardsPerNode默认为1,需要根据实际情况调整,如果只有2台服务器,那么会出现如下错误:

      <?xml version="1.0" encoding="UTF-8" ?> 
     <response>
     <lst name="responseHeader">
      <int name="status">400</int> 
      <int name="QTime">25</int> 
      </lst>
      <str name="Operation createshard caused exception:">org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Cannot create collection goods. No live Solr-instances</str> 
     <lst name="exception">
      <str name="msg">Cannot create collection goods. No live Solr-instances</str> 
      <int name="rspCode">400</int> 
      </lst>
     <lst name="error">
     <lst name="metadata">
      <str name="error-class">org.apache.solr.common.SolrException</str> 
      <str name="root-error-class">org.apache.solr.common.SolrException</str> 
      </lst>
      <str name="msg">Cannot create collection goods. No live Solr-instances</str> 
      <int name="code">400</int> 
      </lst>
      </response>

    5.增加shard

    http://10.90.16.156:8983/solr/admin/collections?action=CREATESHARD&shard=shard2&collection=goods&replicationFactor=2

  • 相关阅读:
    无题
    【HNOI 2002 】营业额统计
    P1589
    【网络流24题】最长递增子序列
    【NOI2008】志愿者招募
    【NOI2015】软件包管理器
    P1347
    【BZOJ 3262三维偏序】陌上花开
    数论六·模线性方程组
    数论五·欧拉函数
  • 原文地址:https://www.cnblogs.com/treehesoft/p/7773434.html
Copyright © 2011-2022 走看看