Reputation: 89
I have install solr 8.9.0 in cloud mode. I have created 2 shards. I have enabled the Basic Authentication using security.json. not use the authorization part.
security.json
{
"authentication":{
"blockUnknown": true,
"class":"solr.BasicAuthPlugin",
"credentials":{"solr":"Y6xFaUPypZOWNmgaU+IkZ8eP4TJxXW50= bWtoYjk2Yjhscmx6a2Jveg=="},
"realm":"My Solr users",
"forwardCredentials": false
}
}
Using below command upload security.json in zookeeper
solr zk cp file:D:\Asite_work\Solr_8.9.0\shard1\bin\security.json zk:/security.json -z "localhost:12181,localhost:12182"
When I hit http://localhost:8983/solr I got the Basic Authentication page and after enter the successful login details it worked properly but when I try to index using code I am getting the ERROR org.apache.solr.client.solrj.impl.CloudSolrClient$RouteException: IOException occurred when talking to server at: http://localhost:8983/solr/documents_shard1_replica_n1
My index code is below
final List<String> zkServers = new ArrayList<>();
zkServers.add("localhost:12181");
zkServers.add("localhost:12182");
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("solr", "Abc@123");
provider.setCredentials(AuthScope.ANY, credentials);
HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
CloudSolrClient sc = new CloudSolrClient.Builder(zkServers, Optional.empty()).withParallelUpdates(true).withHttpClient(client).build();
sc.setDefaultCollection("documents");
sc.connect();
UpdateResponse resp = sc.add(docs, SolrConstants.COMMIT_WITHIN);
Can anyone help me why I am getting this error? Anything's need to configure in zookeeper?
Upvotes: 1
Views: 21