solr8.x 进行shards多core查询时出现的问题解决

本文介绍了解决Solr集群环境下因版本不一致导致的IOException及401 Unauthorized错误的方法。通过调整Tomcat环境参数并正确配置Http2SolrClient以支持认证,最终解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

开发环境solrj8.2,solr7.7+tomcat8,配置的有账号密码。正常无bug出现

线上环境solrj8.2,solr8.9+tomcat8,配置的有账号密码。最初出现 IOException occured when talking to server at:xxxxx

出现原因:
shards原理时solr服务端解析客户端传递来的shards参数,再根据从shards参数解析来的solr地址去请求,再将响应结果合并返回到客户端。问题在于solr7.7依赖的时solrj7.7,而solrj7.7所使用的是Httpsolrclient,solrj8.9所使用的是Http2SolrClient,具体两者的去吧我就不赘述了,感兴趣的小伙伴可以去了解一下

解决办法:
在tomcat8的 catalina.sh 中添加环境参数

-Dsolr.http1=true

然后又出现问题:

 Error from server at null: Expected mime type application/octet-stream but got text/html. <!doctype html><html lang="en"><head><title>HTTP Status 401Unauthorized</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Apache Tomcat/8.5.72</h3></body></html>

出现原因:
Http2SolrClient 根据shards中的solr地址请求时未携带solr的账号密码 解决办法:
在tomcat8的 catalina.sh 中添加环境参数

-Dsolr.httpclient.builder.factory=org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory 
-Dbasicauth=username:password
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值