Search

Sunday 24 February 2019

Single/Multiple SOLR Cloud 7.5 instances and Zookeeper cluster install on Linux

Install Java (Oracle Open JDK)

Centos

sudo yum install java-1.8.0-openjdk.x86_64
sudo java -version

Ubuntu

sudo apt-get update && apt-get upgrade
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java11-installer

Install LSOF

Centos

sudo yum install lsof

Ubuntu

sudo apt-get install lsof

Disable Firewall

Centos

sudo firewall-cmd --state
sudo systemctl stop firewalld
sudo systemctl disable firewalld

Ubuntu

sudo ufw disable

Install WGET (WGET is installed by default on Ubuntu)

Centos

yum install wget

Edit File and Process limits

Due to the file handling requirements of SOLR, the number of open process and open file limits need to be increased.
Edit the following file by typing:
sudo vi /etc/security/limits.conf
and add this text to the bottom of the file:

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535

Additionally on Centos the 20-nproc.conf file needs to be edited to change the following file  - 4096 to 535535
sudo vi /etc/security/limits.d/20-nproc.conf

Stage 1 - Install Zookeeper (quorum cluster mode)

Create the Zookeeper user:
sudo groupadd zookeeper
sudo useradd -g zookeeper -d /opt/zookeeper -s /sbin/nologin zookeeper
Download a defined version of Zookeeper from an approved mirror:
Extract the archive and copy it to /opt/zookeeper/:
sudo mv zookeeper-3.4.13.tar.gz /opt
cd /opt
sudo tar xzf zookeeper-3.4.13.tar.gz
sudo mv zookeeper-3.4.13 zookeeper

cd zookeeper

sudo mkdir data

sudo chown -R zookeeper:zookeeper /opt/zookeeper/*

Edit the Zookeeper config file and add all of the servers that will be running Zookeeper (this typically needs to be an odd number):

sudo vi /opt/zookeeper/conf/zoo.cfg

and add the following (replacing your server IP's in the red text):
tickTime=2000 initLimit=10 syncLimit=5 dataDir=/opt/zookeeper/data clientPort=2181 server.1=10.10.10.10:2888:3888 server.2=10.10.10.11.5:2888:3888
Each node in the Zookeeper cluster needs to have an identifier, to do this, we create a file called myid in the zookeeper/data folder on each server. Just create the file and ensure that each server has a unique number that matches the zoo.cfg file. So for example. server.1=10.10.10.10:2888:3888 must have 1 as it's myid:
cd /opt/zookeeper/data

sudo vi myid

modify firewall to allow all port traffic between your Zookeeper/SOLR nodes

Once the firewall rules are in place Zookeeper can be started  Start Zookeeper on each server:
cd /opt/zookeeper/bin/
sudo ./zkServer.sh start

The zkServer.sh scripts accepts other arguments, as well as start. These are stop, restart and status

(Optional) If you wish to turn this Zookeeper installation into a service and you are running init.d

Setup systemd
vi /usr/lib/systemd/system/zookeeper.service
[Unit] Description=Zookeeper Service [Service] Type=simple WorkingDirectory=/opt/zookeeper/ PIDFile=/opt/zookeeper/data/zookeeper_server.pid SyslogIdentifier=zookeeper User=zookeeper Group=zookeeper ExecStart=/opt/zookeeper/bin/zkServer.sh start ExecStop=/opt/zookeeper/bin/zkServer.sh stop Restart=always TimeoutSec=20 SuccessExitStatus=130 143 Restart=on-failure [Install] WantedBy=multi-user.target
Then...
systemctl daemon-reload systemctl enable zookeeper.service systemctl start zookeeper.service
Test again
cd /opt/zookeeper/bin/ sudo ./zkCli.sh

Stage 2 - Install SOLR

Create a data folder in the root on your drive to store indexes
Create a user called solradmin
sudo mkdir /data
copy your SOLR config files onto your linux servers. Extract the compressed files into /home/solradmin/.
copy your solr.xml file (in this case from /home/solradmin) into /data:
sudo cp /home/solradmin/solr.xml /data
create a solrconfig folder in the root of your system:
sudo mkdir /solrconfig

Download and install SOLR

cd /

sudo wget http://apache.org/dist/lucene/solr/7.5.0/solr-7.5.0.tgz

sudo tar xzf solr-7.5.0.tgz solr-7.5.0/bin/install_solr_service.sh --strip-components=2

sudo ./install_solr_service.sh solr-7.5.0.tgz

sudo service solr restart
We need to customise the Solr startup configuration in /etc/default/solr.in.sh and add the following
Note - add all the Zookeeper nodes in the ZK_HOST parameter by IP or name (these are the same servers you added in the Zookeeper config setup, zoo.cfg):
#Replace these IP's below with your own IP's
ZK_HOST="10.10.10.10:2181,10.10.10.11:2181"
SOLR_OPTS="$SOLR_OPTS -Dsun.net.inetaddr.ttl=60 -Dsun.net.inetaddr.negative.ttl=60"
SOLR_HOME=/data
SOLR_HEAP="30g"
SOLR_JAVA_MEM="-Xms30g -Xmx30g"
Copy the rest of your custom config files and folders (listed below) into /solrconfig (in this case from /home/solradmin/config/):
field-aliases.yml schema.xml solrconfig.xml solr.xml velocity folder
sudo cp -r /home/solradmin/config/* /solrconfig
sudo chmod -R 777 /data
If all has gone well you should be able to access the default SOLR instance via a browser on port 8983.

Single or multiple SOLR instances

By default, this installation will run one SOLR instance per server on the default port of 8983. If you wish to run additional instances per server on their own port you will need to use a script similar to the following to force an instance on a new port. Create two relevant shell script text files, called solrstart.sh and solrstop.sh, make them executable and use the following to stop and start:
#In this instance we are using incremental port numbers, up from the default instance. This creates an additional two SOLR instances on every server you run the script
 
#solrstart.sh
sudo ./solr start -force -c -p 8984 -s /data/solr2
sudo ./solr start -force -c -p 8985 -s /data/solr3
 
 
#solrstop.sh
sudo ./solr stop -force -c -p 8984 -s /data/solr2
sudo ./solr stop -force -c -p 8985 -s /data/solr3

No comments:

Post a Comment