I’ve been attempting to set up Solr Cloud locally in Vagrant for several days with various entries around and the Solr Cloud tutorial without much luck until now. I would like to share my experience with setting Solr Cloud up and continue to build on this posting with problems I come across.
Goals and assumptions for this tutorial are:
Solr 4.7.0 – this’s the latest version of Solr at the time.
Tomcat7 – Solr comes with Jetty.
ZooKeeper 3.4.5 – Solr has ZooKeeper build in but it’s not recommended to use it in production.
Ubuntu LTS 12.04
Assuming you have Virtualbox and Vagrant installed clone my git repository to get started.
git clone email@example.com:thehar/thehar-vagrant.git
Type: `vagrant up` and let Vagrant do the magic of bringing up your host. After Vagrant has completed type `vagrant ssh` and you should have a working VM to start your work in.
Now that we are in your VM lets start by installing Tomcat 7. Next, lets grab the source for Solr and Zookeeper.
sudo apt-get install tomcat7 tomcat7-admin
Unpack downloaded software.
tar zxfv zookeeper-3.4.5.tgz
tar zxfv solr-4.7.0.tgz
Create a directory for zookeeper data and set configuration to point to that place.
sudo mkdir -p /opt/zookeeper/data
cp conf/zoo_sample.cfg conf/zoo.cfg
Change the dataDir and paste appropriate path: /opt/zookeeper/data.
sudo ./bin/zkServer.sh start
Now lets create two Solr shards. Go to Solr directory and have a look into example. Lets replicate example into two directories.
cp -a example / /opt/solr1
cp -a example / /opt/solr2
Next, start the first Solr instance. This loads the solr config to all zookeeper data directories.
java -Dbootstrap_confdir=./solr/collection1/conf/ -Dcollection.configName=collection1 -DnumShards=2 -DzkHost=localhost:2181 -jar start.jar
# Background the process: Ctrl+z and bg
java -Djetty.port=7574 -DzkHost=localhost:2181 -jar start.jar
You can view your empty Solr Cloud at http://localhost:8983/solr/#/~cloud