Assuming you have Zookeeper installed and started, you can install and configure Solr. For additional information on SolrCloud setup, see the SolrCloud documentation.
This documentation assumes you are using Solr 5.3.2. Download Solr here and unzip it to the local file system. We'll call this location SOLR_HOME. Solr provides a number of examples and features out of the box. To simplify things and get to lean setup procedure, follow these steps:
./$SOLR_HOME/server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:2181 -cmd upconfig -confname blc -confdir /path/to/blcSolrConfig
blcSolrConfigdirectory to the Zookeeper Quorum using a configuration name of "blc" (more on this later)
blcSolrHome0anywhere on the file system (e.g.
blcSolrHome1anywhere on the file system (e.g.
blcSolrHome0as the home directory:
./$SOLR_HOME/bin/solr start -cloud -p 8983 -s /path/to/blcSolrHome0 -z localhost:2181,localhost:2182,localhost:2183
blcSolrHome1as the home directory:
./$SOLR_HOME/bin/solr start -cloud -p 8984 -s /path/to/blcSolrHome1 -z localhost:2181,localhost:2182,localhost:2183
Note that each of the Zookeeper instances can be configured on a different physical machine, as can each of the SolrCloud instances. The configuration name "blc" is used, when creating collections, to specify the configuration for the collection. See the collection API for more information on creating collections. Typically, Broadleaf will evaluate your cluster state and create the necessary collections and aliases for you but with SolrCloud, it is better to create the collections and aliases in advance so you can define the replication setup as well. That said, this is a good time to talk about collections and aliases in case you want to create them yourself.
SolrCloud allows you to create one or more collections. A collection is an abstraction on top of a Solr core. It is like a core, except that it can be distributed across multiple Solr servers. A collection can be aliased, meaning it can be assigned and referenced by another name. If you do not create the proper collections and aliases, Broadleaf will create the following:
blcCollectionX, where the "X" is a number selected by Broadleaf that is unique, starting at 0 (zero)
primary, which is assigned to
blcCollectionY, where the "Y" is a number selected by Broadleaf that is unique, starting at 1 (one), assuming that there is already a "blcCollection0"
reindex, which is assigned to
In other words, Broadleaf requires an alias called "primary" and an alias called "reindex". It requires each alias to be assigned to exactly 1 collection. The name of the aliases is important. The name of the collections are not. If the aliases exist and are assigned to collections, then Broadleaf will not create any. If they exist and are not assigned to collections, then Broadleaf will create the collections and assign the aliases to them. If the aliases do not exist, then Broadleaf will create the collections and the aliases and make the necessary assignments.
If Broadleaf is configured to do full reindexing (using the
SolrIndexService) it will reindex the collection aliased as "reindex" and then it will tell Solr to reassign the alias of the indices (essentially swapping aliases with their respective collections). This is similar to the concept of core swapping on an embedded or stand-alone Solr configuration. Although Solr allows a single alias to point to multiple collections, it is important that aliases and collections serving Broadleaf have a one-to-one relationship.
Creating the collections and aliases in advance can be done via a browser (see the collection API). It is recommended to create them as follows:
This can be done using the following URLs in a browswer. For example to create the collections:
Notice that as part of the collection creation, we are also specifying the
maxShardsPerNode. This will setup shard replication so that your indexes are reduncant across different nodes (see shards and indexing). This provides failover should a node be lost.
Now let's create the aliases:
Notice, that you are only creating the collections and aliases on a single Solr node, but you will be able access the collections via their aliases on both nodes:
Remember that creating the collections and aliases is not necessary as Broadleaf will happily do this for you if they do not exist.
The above instructions are generally portable to Windows. However, there are a few things to note:
%SOLR_HOME%\server\scripts\cloud-scripts\zkcli.bat -zkhost localhost:2181 -cmd upconfig -confname blc -confdir "C:\path\to\blcSolrConfig"
%SOLR_HOME%\bin\solr.cmd start -p 8983 -s "C:\path\to\blcSolrHome0" -z "localhost:2181,localhost:2182,localhost:2183"
%SOLR_HOME%\bin\solr.cmd start -p 8984 -s "C:\path\to\blcSolrHome1" -z "localhost:2181,localhost:2182,localhost:2183"