Solrcloud Zookeper设置:等待4000毫秒后没有找到注册的领导者,收集:c1切片:shard2 [英] Solrcloud Zookeper Setup : No registered leader was found after waiting for 4000ms , collection: c1 slice: shard2

查看:814
本文介绍了Solrcloud Zookeper设置:等待4000毫秒后没有找到注册的领导者,收集:c1切片:shard2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用solr 4.10.3,我通过java中的嵌入式jetty服务器启动solr。我试图用2个分片(领导者)配置solrcloud。我有一个外部zookeeper设置,我指向zookeeper实例,同时启动这样的solr。

Am using solr 4.10.3, I start solr via embedded jetty server in java. Am trying to configure solrcloud with 2 shards(Leaders). I have an external zookeeper setup, I point to zookeeper instance while starting solr like this.

        System.setProperty("zkHost", "192.168.2.21:2111");
        System.setProperty("numShards", "2");
        System.setProperty("collection.configName", "configuration1");
        System.setProperty("bootstrap_confdir","/conf/zooconf");

我有两个运行的solr实例,一个在8983端口&其他在8984.问题是,我不确定两个solr节点是否被识别为领导者。由于我通过java启动solr,我无法在solr管理界面中查看状态。

I have two solr instances running, one in 8983 port & other in 8984. The problem is, am not sure whether both solr nodes are recognized as leader. Since i start solr via java, i cannot view the status in solr admin UI.

以下是我的solr.xml:

Following is my solr.xml :

<?xml version="1.0" encoding="UTF-8" ?>
<solr>
  <solrcloud>
    <str name="host">192.168.2.21</str>
    <int name="hostPort">${hostPort:8984}</int>
    <str name="hostContext">${hostContext:solr}</str>
    <int name="zkClientTimeout">${solr.zkclienttimeout:30000}</int>
    <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
  </solrcloud>

  <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
    <int name="socketTimeout">${socketTimeout:120000}</int>
    <int name="connTimeout">${connTimeout:15000}</int>
  </shardHandlerFactory>
</solr>

在main方法中,我连接到其中一个solr实例(8983)并使用以下内容创建核心代码段。

In main method i connect to one of the solr instances(8983) and create the core using the following code snippet.

    CloudSolrServer server = new CloudSolrServer("192.168.2.21:2111"); 
    server.setZkConnectTimeout(15*60*1000);
    server.setZkClientTimeout(15*60*1000);
    server.setParser(new BinaryResponseParser());
    server.setRequestWriter(new BinaryRequestWriter());     
    server.setDefaultCollection("C1");

    Create adminRequest = new Create();
    adminRequest.setAction(CoreAdminAction.CREATE);
    adminRequest.setCoreName("C1");
    adminRequest.setCollection("C1");
    adminRequest.setCollectionConfigName("configuration1");
    adminRequest.setDataDir("c:\\setup\somelocation");
    adminRequest.setInstanceDir("c:\\setup\somelocation\C1");
    adminRequest.process(solrServer);

当我执行此操作时,C1仅在一个solr实例中创建(8983)。 (不是应该在两个solr实例的数据目录中创建的核心。)。在添加文档时,抛出以下异常。

When i execute this, C1 is created in only one solr instance(8983). (isn't the core supposed to be created in two solr instance's data directories.?). And while adding the document, Following exception is thrown.


等待4000ms后未找到注册的领导者,集合:c1 slice:sh​​ard2

No registered leader was found after waiting for 4000ms , collection: c1 slice: shard2

这是添加文档时的clusterState:

This is the clusterState while adding document :

live nodes:[192.168.2.21:8984_solr, 192.168.2.21:8983_solr] collections: {
   C1=DocCollection(C1)=   {
      "shards":{
         "shard1":{
            "range":"80000000-ffffffff",
            "state":"active",
            "replicas":{
               "core_node1":{
                  "state":"active",
                  "core":"C1",
                  "node_name":"192.168.2.21:8983_solr",
                  "base_url":"http://192.168.2.21:8983/solr",
                  "leader":"true"
               }
            }
         },
         "shard2":{
            "range":"0-7fffffff",
            "state":"active",
            "replicas":{

            }
         }
      },
      "maxShardsPerNode":"1",
      "router":{
         "name":"compositeId"
      },
      "replicationFactor":"1",
      "autoAddReplicas":"false",
      "autoCreated":"true"
   }
}

如果我创建核心在添加文档之前的另一个solr实例(8984),它工作正常..文档被索引并分布在2个分片之间。我在做什么有什么不对吗?请帮帮我。

And if i create the core in the other solr instance(8984) before adding the document, it works fine.. Documents are indexed and distributed between 2 shards. Is there anything wrong that i am doing? Please help me out.

提前致谢..

推荐答案

我在创建adminRequest时添加了以下行,它工作了

I added the following lines while creating the adminRequest, it worked

adminRequest.setPath("/admin/collections");
adminRequest.setNumShards(2);

以前它的工作是因为默认路径指向旧的api / admin / cores 。我们需要确保在admin_quest对象中为 / admin / collections / solr / Collections + APIrel =nofollow> New Collection API

Previously it dint work because default path was pointing to the old api "/admin/cores". We need make sure that new api path "/admin/collections" is given in adminRequest object for the solrcloud operations mentioned in New Collection API.

这篇关于Solrcloud Zookeper设置:等待4000毫秒后没有找到注册的领导者,收集:c1切片:shard2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆