使用 CloudSolrClient 连接到 solrcloud 时出错

Errors connecting to solrcloud using CloudSolrClient

我正在尝试使用 solrj CloudSolrClient 连接到 solrCloud,但出现错误。

以前直接调用单个solr节点,现在改用solrcloud。我尝试了在线文档中指定的各种不同的 url 格式。

SolrClient solrClient = new CloudSolrClient.Builder(zkUrl).build();
SolrQuery solrQuery = new SolrQuery();

solrQuery.setRequestHandler(FIELD_LIST_HANDLER);
QueryRequest req = new QueryRequest(solrQuery);
req.setBasicAuthCredentials(zkUser, zkPassword);
QueryResponse response = req.process(solrClient, core);

使用以下 zkHost 字符串时出现各种错误。

主机:2181

2019-08-21 15:53:17 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [host:2181], down?)] with root cause org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: host:2181/admin/collections?action=CLUSTERSTATUS&wt=javabin&version=2

http://host:2181

2019-08-21 15:55:53 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [http://host:2181], down?)] with root cause org.apache.http.NoHttpResponseException: host:2181 failed to respond at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141)

主机:2181/solr

2019-08-21 16:00:11 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [host:2181/solr], down?)] with root cause org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: host:2181/solr/admin/collections?action=CLUSTERSTATUS&wt=javabin&version=2 at org.apache.http.impl.client.CloseableHttpClient.determineTarget(CloseableHttpClient.java:95)

http://host:2181/solr

2019-08-21 15:57:23 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [http://host:2181/solr], down?)] with root cause org.apache.http.NoHttpResponseException: host:2181 failed to respond at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141)

我需要更改什么才能使用 solrj CloudSolrClient 通过 zookeeper 成功查询 solr?

我已从终端成功与 zookeeper 实例通信。

$ echo stat | nc host 2181
Zookeeper version: 3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
Clients:
 /130.10.31.81:60381[0](queued=0,recved=1,sent=0)
 /135.40.74.31:48984[1](queued=0,recved=817933,sent=817933)

Latency min/avg/max: 0/0/80
Received: 1893410
Sent: 1893706
Connections: 2
Outstanding: 0
Zxid: 0xa00000636
Mode: follower
Node count: 214

原来solrurls和zkurls都可以提供给CloudSolrClient.Builder。我能够通过使用 SolrClient solrClient = new CloudSolrClient.Builder(hosts, Optional.empty()).build(); 接受 zkUrls 而 CloudSolrClient.Builder(hosts).build() 接受 solr Urls

来解决上一个问题

当配置 itme clusterprops.json 在 zookeeper 中不可用时,我也得到了这个 ClientProtocolException / 内容:

{"urlScheme":"https"}