Search code examples
javasolrsolr8

Setting up solr cloud on two machines


Enviornment - solr-8.9.0, java version "11.0.12" 2021-07-20 LTS, apache-zookeeper-3.6.1-bin/

To set-up solrCloud i have done following steps-

Setting-up Zookeeper on Node 1

a. Go inside <ZK_HOME>/conf directory.
b. Make a copy of zoo_sample.cfg & rename to zoo.cfg (or mv zoo_sample.cfg to zoo.cfg)
c. Edit zoo.cfg and modify data_dir parameter to a directory location where you would like Zookeeper to store its data.
dataDir=<ZK_HOME>/conf/data
d. Now start Zookeeper with command
./bin/zkServer.sh start

Solr Setup on Node 1 / Machine 1

a. Create directory solr-8.9.0/server/solr/node1/solr/.
b. Copy default zoo.cfg & solr.xml from solr-8.9.0/server/solr to solr5.x.x/server/solr/node1/solr/
c. Now lets start Solr using below command (basically you want to start in cloud mode with Zookeeper)
./bin/solr start -cloud -s solr-8.9.0/server/solr/node1/solr  -p 8983 -z <Node1 IP>:2181 -m 2g

Solr Setup on Node 2 / Machine 2

a. Create directory solr-8.9.0/server/solr/node1/solr/.
b. Copy default zoo.cfg & solr.xml from solr-8.9.0/server/solr to solr5.x.x/server/solr/node1/solr/
c. ./solr start -cloud -s solr-8.9.0/server/solr/node1/solr  -p 8983 -z <Node1 IP>:2181 -m 2g 

Upload configs to Zookeeper

a. ./server/scripts/cloud-scripts/zkcli.sh -zkhost <Node1 IP>:2181 -cmd upconfig -confname _defaults -confdir solr-8.9.0/server/solr/configsets/_defaults/conf

Creating a collection

http://<Node1 IP>:8983/solr/admin/collections?action=CREATE&name=<myCollection>&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=_defaults

But i am getting following error while creation of collection

{
  "responseHeader":{
"status":400,
"QTime":1213},
  "failure":{
"$Node2:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://$Node2:8983/solr: Path /home/solr/solr-8.9.0/server/solr/node1/solr/myCollection_shard1_replica_n2 must be relative to SOLR_HOME, SOLR_DATA_HOME coreRootDirectory. Set system property 'solr.allowPaths' to add other allowed paths.",
"$Node2:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://$Node2:8983/solr: Path /home/solr/solr-8.9.0/server/solr/node1/solr/myCollection_shard2_replica_n6 must be relative to SOLR_HOME, SOLR_DATA_HOME coreRootDirectory. Set system property 'solr.allowPaths' to add other allowed paths.",
"127.0.1.1:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Path /data/Lucene/solr/solrcloud/solr-8.9.0/server/solr/node1/solr/myCollection_shard2_replica_n4 must be relative to SOLR_HOME, SOLR_DATA_HOME coreRootDirectory. Set system property 'solr.allowPaths' to add other allowed paths.",
"127.0.1.1:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Path /data/Lucene/solr/solrcloud/solr-8.9.0/server/solr/node1/solr/myCollection_shard1_replica_n1 must be relative to SOLR_HOME, SOLR_DATA_HOME coreRootDirectory. Set system property 'solr.allowPaths' to add other allowed paths."},
"Operation create caused exception:":"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Underlying core creation failed while creating collection: myCollection",
  "exception":{
"msg":"Underlying core creation failed while creating collection: myCollection",
"rspCode":400},
  "error":{
"metadata":[
  "error-class","org.apache.solr.common.SolrException",
  "root-error-class","org.apache.solr.common.SolrException"],
"msg":"Underlying core creation failed while creating collection: myCollection",
"code":400}}

Why above error was occurred? What steps i am missing while setting up solrCloud on 2 machines with 1 zookeeper instance? Could someone help me find the missing piece?


Solution

  • As error suggest

    1. Use absolute path while starting the solr instance on both nodes.
    2. Use abosolute path for 'confdir' parameter while uploading configuration to zookeeper.