Setup solr using zookeeper ensemble on ubnutu


Setup Oracle Java:
Follow quick step given below to setup java latest version on your system,

java -version
tar -zxvf jdk-8u45-linux-x64.tar.gz
sudo mkdir -p /usr/lib/jvm/jdk1.8.0_45
sudo mv jdk1.8.0_45/* /usr/lib/jvm/jdk1.8.0_45/
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_45/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_45/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0_45/bin/javaws" 1
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_45/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_45/bin/javac
sudo update-alternatives --set javaws /usr/lib/jvm/jdk1.8.0_45/bin/javaws
java -version
vim ~/.bashrc
export JAVA_HOME="/usr/lib/jvm/jdk1.8.0_45"
export PATH="$PATH:$JAVA_HOME/bin"
source ~/.bashrc
echo $PATH

For more detail kindly visit how-to-install-oracle-jdk-7-on-ubuntu-12-04

Setup Zookeeper Ensemble: (

Consider we have 2 servers (, and we are setting up 6 zookeeper nodes called znodes.
Follow quick step given below to setup Zookeeper Ensemble on your system,

wget ''
tar -xvf zookeeper-3.4.6.tar.gz
sudo mkdir -p /usr/lib/zookeeper-3.4.6
sudo mv zookeeper-3.4.6/* /usr/lib/zookeeper-3.4.6/
cd /usr/lib/zookeeper-3.4.6/
sudo cp conf/zoo_sample.cfg conf/zoo_1.cfg
sudo vim conf/zoo_1.cfg

Add following configs,


Repeat above setting for all servers.

Make data directories:(Repeat for all servers)

sudo mkdir -p /var/lib/zookeeper/1/
sudo sh -c 'echo "1" > /var/lib/zookeeper/1/myid'

Start servers:(Repeat for all servers)
sudo bin/ start zoo_1.cfg

Check Status:

bin/ status zoo_1.cfg
echo status | nc localhost 2187

Test Client:

bin/ -server
[zk: 1] ls /
[zk: 2] get /configs/gettingstarted/solrconfig.xml
[zk: 3] quit

Stop Servers:(Repeat for all servers)
sudo bin/ stop zoo_1.cfg

For more detail kindly visit Setup-zookeeper-ensemble-on-ubuntu

Setup Solr:

Consider we have 2 servers (, and we are setting up 2 solr instances in shard=1:replication:2 setup.
wget ''
SolrCloud Standalone Setup using Embedded Zookeeper (Testing environment): (
Please follow above link for demos.

SolrCloud Mode Setup using External Zookeeper Ensemble (Testing environment): (
cd solr-5.2.0/tar -zxvf solr-5.2.0.tgz

Create Node:

mkdir -p example/cloud/node1/solr
cp server/solr/solr.xml example/cloud/node1/solr
mkdir -p example/cloud/node2/solr
cp server/solr/solr.xml example/cloud/node2/solr
bin/solr start -cloud -s example/cloud/node1/solr -h -p 8983 -z,,,,,
bin/solr start -cloud -s example/cloud/node1/solr -h -p 8983 -z,,,,,

Create Collection:
bin/solr create -c gettingstarted -d basic_configs -rf 2


bin/solr status
bin/solr healthcheck -c gettingstarted

Delete Collection:
bin/solr delete -c gettingstarted


bin/solr restart -cloud -s example/cloud/node1/solr -h -p 8983 -z,,,,,
bin/solr restart -cloud -s example/cloud/node1/solr -h -p 8983 -z,,,,,

Stop Node:
bin/solr stop -all;

Clean all Testing files:
rm -Rf example/cloud/

SolrCloud as a Service using External Zookeeper Ensemble (Production environment): (

Run Installation script:

tar xzf solr-5.2.0.tgz solr-5.2.0/bin/ --strip-components=2
sudo bash ./ -help
sudo bash ./ solr-5.0.0.tgz -i /opt -d /var/solr -u solr -s solr -p 8983
sudo bash ./ solr-5.2.0.tgz
id: solr: no such user
Creating new user: solr
Adding system user `solr' (UID 109) ...
Adding new group `solr' (GID 116) ...
Adding new user `solr' (UID 109) with group `solr' ...
Creating home directory `/home/solr' ...
Extracting solr-5.2.0.tgz to /opt
Creating /etc/init.d/solr script ...
Adding system startup for /etc/init.d/solr ...
Waiting to see Solr listening on port 8983 [/]
Started Solr server on port 8983 (pid=1704). Happy searching!
Service solr installed.
sudo service solr status
sudo service solr stop

Setup SolrCloud:

To run Solr in SorlCloud add following setting in environment specific include file (/var/solr/,

If you’re using a ZooKeeper instance that is shared by other systems, it’s recommended to isolate the SolrCloud znode tree using ZooKeeper’s chroot support. For instance, to ensure all znodes created by SolrCloud are stored under /solr, you can put /solr on the end of your ZK_HOST connection string, such as:

If using a chroot for the first time, you need to bootstrap the Solr znode tree in ZooKeeper by using the script, such as:
/opt/solr/server/scripts/cloud-scripts/ -zkhost -cmd bootstrap -solrhome /var/solr/data

If above script couldn’t be able to create ‘solr’ chroot because of 0 core (As we have not create any core yet) then create one by zookeeper client,

/usr/lib/zookeeper-3.4.6/bin/ -server
[zk: 2] create /solr solr

Note: Above fix is not specified anywhere in Solr Doc.
sudo service solr start

Upload a configuration directory: (
/opt/solr/server/scripts/cloud-scripts/ -zkhost -cmd upconfig -confname data_driven_schema_configs -confdir /opt/solr/server/solr/configsets/data_driven_schema_configs/conf

To delete wrong config use zookeeper client,

/usr/lib/zookeeper-3.4.6/bin/ -server
[zk: 8] rmr /configs

Create Collection:(



For more detail kindly visit Install-solr-on-ubuntu

Important Download links,

Search Engine research:




PHP Client:

Symfony Bundle:

Thank you.

This entry was posted in Java, Solr, Uncategorized, Zookeeper and tagged , , . Bookmark the permalink.

Leave a Reply