Monday, January 21, 2019

Solr 7.6 - Solr Cloud installation

Solr 7.6 Getting Started

Solr documentation is huge.  In the time constrained age, of interest are the quick getting started.  As such the precise commands used to set up, and running SolrCloud7.6 with a three node external zookeeper ensemble is documented here.

Steps to create Solr Cloud:

  1. Install Zookeeper Ensemble
  2. Add a node
  3. Start Solr using the zookeeper configured in Step 1.
  4. Create ConfigSet
  5. Create Collection
  6. Access SolrCloud GUI

Install Zookeeper

Three node external zookeeper ensemble is used.  The three nodes used are:
  • wolf:2181
  • tiger:2181
  • lion:2181
The variable ZK_HOST would be wolf:2181,tiger2181,lion:2181

Add node

Adding a node to Solr Cloud provides detailed instructions to add a node to the cloud. 

Start Solr

The SolrCloud is also installed on the same nodes.

Start Solr using external zookeeper ensemble

<SOLR_HOME>/bin/solr start -c -z $ZK_HOST

Create ConfigSet

Without getting into detailed explanation of schema.xml, solrconfig.xml and other related configuration files, Sample Configuration files can be used to quickly get started.  Following script would generate a ConfigSet with the name tech, by uploading the configuration files stored in the configuration directory ~/solr/tech/.

#!/bin/sh

SOLR_HOME=~/solr-7.6.0
ZK_HOST=wolf:2181,tiger:2181,lion:2181
CONF_NAME=tech
CONF_DIR=~/solr/tech/

$SOLR_HOME/server/scripts/cloud-scripts/zkcli.sh -z $ZK_HOST -cmd upconfig -confname $CONF_NAME -confdir $CONF_DIR

Configure Zookeeper

Modify ZK_HOST in the file ~/SOLR_HOME/bin/solr.in.sh to read the ZK_HOST

ZK_HOST="wolf:2181,tiger:2181,lion:2181"

Create Collection

Following script can be used to create a new collection by the name mytech using the ConfigSet tech as created previsously with 3 shards per collection, and a replication factor of 2. 


#!/bin/sh



SOLR_HOME=~/solr-7.6.0
COLLECTION_NAME=mytech
CONFIG_NAME=tech
SHARD_COUNT=3
REPL_FACTOR=2
$SOLR_HOME/bin/solr create -c $COLLECTION_NAME -n $CONFIG_NAME -s $SHARD_COUNT -rf $REPL_FACTOR


Access SolrCloud GUI

The SolrCloud thus created can be accessed using the url http://wolf:8983/solr/.  The intutive user interface can be used to explore the various functionality provided by Solr.

Sample Data

Following sample data can be used to insert data from SolrCloud GUI:
id,cat,name,price,inStock,author,series_t,sequence_i,genre_s
0553573403,book,A Game of Thrones,7.99,true,George R.R. Martin,"A Song of Ice and Fire",1,fantasy
0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,"A Song of Ice and Fire",2,fantasy
055357342X,book,A Storm of Swords,7.99,true,George R.R. Martin,"A Song of Ice and Fire",3,fantasy
0553293354,book,Foundation,7.99,true,Isaac Asimov,Foundation Novels,1,scifi
0812521390,book,The Black Company,6.99,false,Glen Cook,The Chronicles of The Black Company,1,fantasy
0812550706,book,Ender's Game,6.99,true,Orson Scott Card,Ender,1,scifi
0441385532,book,Jhereg,7.95,false,Steven Brust,Vlad Taltos,1,fantasy
0380014300,book,Nine Princes In Amber,6.99,true,Roger Zelazny,the Chronicles of Amber,1,fantasy
0805080481,book,The Book of Three,5.99,true,Lloyd Alexander,The Chronicles of Prydain,1,fantasy

080508049X,book,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy


Sample Query

Once the data has been added to the cloud, Solr search can be executed. Screenshot of Sample Query is shown below:


No comments:

Post a Comment