Solrj cannot connect to zookeeper from Solr Cloud example

I launched Solrcloud by running the above bin/solr -e cloud example, in which case I managed to start the three Solr cloud nodes and created the gettingstarted collection:

 http://localhost:8983/solr/admin/collections?action=CREATE&name=gettingstarted&numShards=3&replicationFactor=2&maxShardsPerNode=2&collection.configName=gettingstarted 

I think it comes with a built-in zookeeper running on port 9983 because I saw this output when I started the cloud:

 ... Starting up Solr on port 7574 using command: bin/solr start -cloud -p 7574 -s "example/cloud/node2/solr" -z localhost:9983 Waiting up to 30 seconds to see Solr running on port 7574 [/] ... 

However, when I tried to connect to SolrCloud using SolrJ, it was not able to get the error message:

 Exception in thread "main" org.apache.solr.common.SolrException: Cannot connect to cluster at localhost:9983/solr: cluster not found/not ready 

enter image description here

Can someone help me understand what is going on here?

+5
source share
2 answers

The code does not work because you are trying to point CloudSolrServer to a znode that does not exist. Your zkhost is not configured with chroot /solr . The configurations seem to be stored in the root of the node.

So change the line

 String zkHostString = "localhost:9983/solr"; 

to

 String zkHostString = "localhost:9983"; 

and your code should work.

+4
source

It depends on your zkHost. If your zkHost contains / solr, then it should be localhost: 2181 / solr or localhost: 9983 / solr; Otherwise localhost: yourport

+1
source

Source: https://habr.com/ru/post/1244680/


All Articles