Below are the steps to install Solr and Zookeeper on Debian 12.7.
I have these servers:
Solr Nodes:
hqew1ww-rg-p04-solr-1 172.24.122.4:8983/solr/
hqew1ww-rg-p04-solr-2 172.24.122.5:8983/solr/
hqew1ww-rg-p04-solr-3 172.24.122.6:8983/solr/
Update System
$sudo apt update && sudo apt upgrade -y
Install Java JDK
$sudo apt install default-jdk
Check Java
$java -version
Download Solr, Install, Check Services
$cd /opt/
$sudo wget https://archive.apache.org/dist/lucene/solr/8.11.2/solr-8.11.2.tgz
$sudo tar xzf solr-8.11.2.tgz
$sudo bash solr-8.11.2/bin/install_solr_service.sh solr-8.11.2.tgz
$sudo systemctl status solr
Download Zookeeper
$sudo wget https://downloads.apache.org/zookeeper/stable/apache-zookeeper-3.8.4-bin.tar.gz
$sudo tar -xvzf apache-zookeeper-3.8.4-bin.tar.gz
Rename Directory
$sudo mv apache-zookeeper-3.8.4-bin zookeeper
Create a Zookeeper User and Group
$sudo useradd -m -r -d /var/lib/zookeeper -s /bin/false zookeeper
Set Ownership and Permissions
$sudo vim /opt/zookeeper/conf/zoo.cfg
Config file content:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/var/lib/zookeeper
clientPort=2181
server.1=172.24.122.4:2888:3888
server.2=172.24.122.5:2889:3889
server.3=172.24.122.6:2890:3890
The Command Below Starts the Zookeeper (If you want to test before run as a service)
$/opt/zookeeper/bin/zkServer.sh start
The Command Below Connects to Zookeeper
$/opt/zookeeper/bin/zkCli.sh -server 127.0.0.1:2181
To Stop
$/opt/zookeeper/bin/zkServer.sh stop
Create a System Service
$sudo vim /etc/systemd/system/zookeeper.service
[Unit]
Description=Zookeeper Daemon
Documentation=http://zookeeper.apache.org
Requires=network.target
After=network.target
[Service]
Type=forking
WorkingDirectory=/opt/zookeeper
User=zookeeper
Group=zookeeper
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop /opt/zookeeper/conf/zoo.cfg
ExecReload=/opt/zookeeper/bin/zkServer.sh restart /opt/zookeeper/conf/zoo.cfg
TimeoutSec=30
Restart=on-failure
[Install]
WantedBy=default.target
Reload System Daemon
$sudo systemctl daemon-reload
Start the Zookeeper Service and Enable It to Start After System Reboot Using the Following Commands:
Error Encountered
I found an error when I tried to start the service due to permission issues. The reason is that I ran the command /opt/zookeeper/bin/zkServer.sh start
using my root account. The directory /opt/zookeeper/logs/
did not have permission for the zookeeper user, and the directories were created when I tried to run the service to test using bash.
These Were the Errors:
hqew1ww-rg-p04-solr-1 zkServer.sh[3724919]: /opt/zookeeper/bin/zkServer.sh: line 164: /opt/zookeeper/bin/../logs/zookeeper-zookeeper-server-hqew1ww-rg-p04-solr-1.out: Permission denied
hqew1ww-rg-p04-solr-1 zkServer.sh[3724920]: /opt/zookeeper/bin/zkServer.sh: line 175: /var/lib/zookeeper/zookeeper_server.pid: Permission denied
You Can Check the Permissions:
$ls -lha /opt/zookeeper/logs/
$ls -lha /var/lib/zookeeper
Solution:
Simply delete the directories or configure the ownership. The owner should be the zookeeper user.
###
Solr Cloud (Cluster)
###
$sudo vim /etc/default/solr.in.sh
Restart Solr and Zookeeper
I had an issue with ZooKeeper when I opened Solr and checked the nodes. I received the following message:
'Only one zk allowed in standalone mode'
The issue was related to the configuration file.
server.1=172.24.122.4:2888:3888
server.2=172.24.122.5:2889:3889
server.3=172.24.122.6:2890:3890
You must use 'server' at the beginning of the line; any other value will cause your ZooKeeper to fail.