How to collect Clusterstate.json file (Apache Solr)

What is Clusterstate.json

The Clusterstate.json file consists of information about the collection, shard, and replica like where it is hosted and the current state of the replica (either active or in downstate). This helps us to understand the current status of Solr and all of its collection

To troubleshoot issues related to Apache Solr, the Clusterstate.json file is the one mandatory point, Where we need to start

Why do we need to collect Clusterstate.json

— There are multiple times, We can see issues while accessing the Solr collection (For example: Let’s say you are seeing the below Error message in the Solr logs and you are unable to query a collection

==2022-01-02 23:17:00.168 ERROR (qtp1434533899-22) [c:collections:shard2 r:core_node8 x:collections_shard2_replica_n6] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: no servers hosting shard: shard1
        at org.apache.solr.handler.component.HttpShardHandler.prepDistributed(HttpShardHandler.java:489)
        at org.apache.solr.handler.component.SearchHandler.getAndPrepShardHandler(SearchHandler.java:249)2022-01-04 11:30:01.342 ERROR (qtp1434533899-26567) [c:collections:shard2 r:core_node7 x:collections_shard2_replica_n4] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: No registered leader was found after waiting for 4000ms , collection: collections slice: shard1
==

— The next action item, Would be to check the Clusterstate.json file to make sure the collection and its replica have an active leader, Based on that we can proceed to troubleshoot further

How to collect the Clusterstate.json file

Check the status of SOLR collection:

    curl -ik --negotiate -u : "http://$(hostname -f):<port>/solr/admin/collections?action=clusterstatus&wt=json&indent=true"

Example Output:

"shard1":{
      "range":"80000000-ggggggg",
      "state":"active",
      "replicas":{
        "core_node2”:{
          "core”:”collections_shard1_replica_n1",
          "base_url":"https://<hostname>:8995/solr",
          "node_name”:”<hostname>:8995_solr",
          "state":"down",
          "type":"NRT",
          "force_set_state":"false"},
        "core_node3”:{
          "core":"collections_shard1_replica_n2",
          "base_url":"https://<hostname>:8995/solr",
          "node_name":"<hostname>:8995_solr",
          "state":"down",
          "type":"NRT",
          "force_set_state":"false"}}},

In the above output, We can understand the collection replica are not active and are in the “DOWN” state. From there we need to troubleshoot, why this collection went down (All the best for that 🙂 )

"state":"down

Let us know if you have any simple and easiest way to get this information, Send us a chat if you have any further questions on troubleshooting.

Good Luck for your learning, Hit like if this blog helped you

Similar Posts