Skip to main content

Posts

Showing posts from December, 2014

SolrCloud: how to add a shard to an existing collection

If a shard it's becoming too big you cannot simply add a new shard to a collection, but the correct procedure is to split the shard in two parts. The original shard remains the same and Solr creates two new shards each of which contains a part of the documents of the original shard. The two new shards will start to receive the requests directed to the original shard, and the latter must be deactivated manually. If needed you can move the new shards to other cluster nodes. Split the shard in two parts The command to split a shard into two parts is: curl 'http://localhost:8983/solr/admin/collections?action=SPLITSHARD&collection=examplecoll&shard=shard1&async=true' Here "shard1" is the id of the shard to be split and "examplecoll" is the name of the collection to which the shard belongs. Note the async parameter: it's better to execute this command in an asynchronous way because it can last for a long time depending on the numb

SolrCloud: how to add a new collection to a running cluster

It's easy to find examples about how to start a SolrCloud cluster with a default collection, but it's not as easy to find examples that tell you how to add a new collection to an already running cluster. Here I'm going to describe the main steps. Load the collection configuration in ZooKeeper The collection configuration is nothing else than the "conf" directory of a core when Solr is in a "non Cloud" setup: when Solr is in a Cloud setup the files contained in the "conf" directory cannot be stored on a single node, but they must be loaded in ZooKeeper to be distributed to all cluster nodes. To accomplish this task there's the zkcli.sh script contained in the Solr distribution in the  example/scripts/cloud-scripts  directory: it's a simplified version of the ZooKeeper script having the same name. ./zkcli.sh --zkhost localhost:2181 --cmd upconfig --confdir /node1/solr/examplecoll/conf --confname examplecollcfg Here  /node1/s