Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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");

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.

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>

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);

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.

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

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"
   }
}

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.

Thanks in advance..

like image 379
Vijay Avatar asked Nov 10 '22 16:11

Vijay


1 Answers

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

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

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.

like image 125
Vijay Avatar answered Nov 14 '22 23:11

Vijay