2016-03-08 95 views
5

我通過運行包含的例子bin/solr -e cloud開始Solrcloud從Solr的雲實例飼養員,並且在這種情況下,我成功地啓動了三個節點Solr的雲和創建gettingstarted集合:Solrj無法連接

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

我認爲它與在端口9983上運行的嵌入式動物園管理員,因爲我看到這個輸出,當我開始雲:

... 
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 [/] 
... 

然而,當我試圖連接使用SolrJ的SolrCloud時,它失敗,出現錯誤信息:

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

誰能幫我明白這到底是怎麼回事呢?

+0

對於任何人想知道,Zookeeper連接字符串應該包含zookeeper集羣中的所有zookeeper服務器,用逗號分隔,有些zookeeper配置使用chroot或應用程序根目錄,這是''/ solr''出現在查詢字符串的末尾。當你在Zookeeper中的''/ solr''上有一個chroot時,這將是必需的。對於大多數配置,這可以省略。 –

+0

@BenDeMott也許這應該是一個答案? –

回答

4

代碼失敗,因爲您試圖將CloudSolrServer指向一個不存在的znode。 您的zkhost未配置/solr chroot。配置似乎存儲在根節點。

因此改線

String zkHostString = "localhost:9983/solr"; 

String zkHostString = "localhost:9983"; 

和你的代碼應該工作。

1

這取決於你的zkHost。如果你的zkHost包含/ solr,那麼它應該是localhost:2181/solr或localhost:9983/solr;否則,localhost:yourport