Using this fantastic GIST of Kalharbi at https://gist.github.com/kalharbi/fd29661b9926eb087c45 , I have configured SolrCloud on my localhost with three ZooKeeper server on port 2181, 2182 & 2183 where their roles are follower, follower, & Leader respectively.
I have uploaded two different configurations namely tr_config & rp_config to ZooKeeper and create two collections using below commands
My config folder contains some files like schema.xml,solrconfig.xml etc,at
-/opt/solr/server/solr/configsets/tr_config
-/opt/solr/server/solr/configsets/rp_config
Upload config To ZooKeeper:
./server/scripts/cloud-scripts/zkcli.sh -cmd upconfig -zkhost 127.0.0.1:2181 -confdir ./server/solr/configsets/tr_config/conf/ -confname tr_config
./server/scripts/cloud-scripts/zkcli.sh -cmd upconfig -zkhost 127.0.0.1:2181 -confdir ./server/solr/configsets/rp_config/conf/ -confname rp_config
Create Collections:
curl 'http://localhost:8983/solr/admin/collections?action=CREATE&name=transactions&numShards=2&replicationFactor=1&collection.configName=tr_config'
curl 'http://localhost:8983/solr/admin/collections?action=CREATE&name=properties&numShards=2&replicationFactor=1&collection.configName=rp_config'
It works properly but then I have changed the solrconfig.xml on properties collection and update configuration again to ZooKeeper server,then it showing lockType.native issue on solr initialization, so then I have set lockType:none on solrconfig.xml. and it works again. but when I run all solr instances on different ports like 8983, 8984 & 8985 using command
$ ./bin/solr start -c -p 8983 -z 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
$ ./bin/solr start -c -p 8984 -z 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
$ ./bin/solr start -c -p 8985 -z 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
It shows
no servers hosting shard: shard1
but If I stop the other solr instances on 8984 and 8985 port and restart 8983 then all my docs are queryable. again if I start any of the 8984 or 8985 solr instance, 8983 instance again non queryable.
The problem may be the data indexing directory are same for all three solr instances, but I don't know how to configure it differently for every other solr collections. So experts give some light on my below problems.
What is the problem ? why not able to run three instances while I am updating the configuration on ZooKeeper.?
How can I change the maxShardsPerNode ?
Thanks in Advance
You've probably already solved it - using the same data directory for all nodes will not work (or as you've discovered, it'll give weird errors). If you're going to run multiple nodes, you'll have to provide them each with a different solr.home
directory.
You can set this when starting Solr:
-s <dir>
Sets the solr.solr.home system property; Solr will create core directories under this directory. This allows you to run multiple Solr instances on the same host while reusing the same server directory set using the -d parameter. If set, the specified directory should contain a solr.xml file, unless solr.xml exists in ZooKeeper. The default value is server/solr.
In relation to maxShardsPerNode
, I don't think you can't. When you create the collection, that setting will be "set in stone" for the collection. There is however work in progress on the Rebalance API to make these things easier.
For now you could use the manual SPLITSHARD command to split a shard into two different pieces. This can be done while the server is responding to requests, and will split the shard in two halves.