<!-- JSON-LD markup generated by Google Structured Data Markup Helper. -->
<script type="application/ld+json">
{
 "@context" : "http://schema.org",
 "@type" : "Article",
 "name" : "How to set up Solr as a system service",
 "author" : {
   "@type" : "Person",
   "name" : "Subham Majavadiya"
 },
 "image" : "https://global-uploads.webflow.com/5ef788f07804fb7d78a4127a/5ef788f17804fbc00ca41a9c_Set%20up%20solr.png",
 "articleSection" : "how to set up SOLR as a service.",
 "articleBody" : [ "Zookeeper", "Create user", "Download solr source code", "Add solr/zookeeper hosts", "Create ZooKeeper chroot", "Create Systemd Service File", "Reload &amp; test setup" ],
 "url" : "https://www.engati.com/blog/set-up-solr",
 "publisher" : {
   "@type" : "Organization",
   "name" : "Engati"
 }
}
</script>

How to set up Solr as a system service

Subham Majavadiya
|
2
min read
How to set up Solr as a system service

Most Linux distributions use the systems as a system and service manager. In this tutorial, I will show how to set up SOLR as a service.

What is Solr?

Solr is highly reliable, scalable and fault tolerant, Open-source REST-API based search engine developed under Apache Software Foundation umbrella, mature with a wide user base.

Solr is a full-text search, ready to deploy engine that can handle large volumes of text-centric data.

The purpose of Apache Solr is to index and search large amounts of text/web content and give relevant content based on search query.

Solr is also very modular. You can exchange or add functionality just by including your custom code in the form of a jar file and slightly changing the configuration.

Ps. Chatbots are also a great way to help your website visitors find the content that they're looking for. Get started with an Engati Chatbot today!

Setup prerequisites

Zookeeper

Zookeeper is a configuration-management application that comes prepackaged with Solr. It works well in the local environment, but as you increase the traffic or number of nodes, the prepackaged Zookeeper falls short of delivering proper support to your Solr cluster.
So in the production environment Zookeeper should be installed separately.

Create user

sudo useradd -m -p $(perl -e 'print crypt($ARGV[0], "password")' solr solr

Download solr source code

sudo su - solr
wget https://archive.apache.org/dist/lucene/solr/7.3.0/solr-7.3.0.tgz
tar xzf solr-7.3.0.tgz

Add solr/zookeeper hosts

I am setting up zookeeper and solr both in the same machine.

vi /etc/hostszokeeper.app.local 127.0.0.1
solr.app.local 127.0.0.1

Create ZooKeeper chroot

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

/home/solr/solr-7.3.0/bin/solr zk mkroot /solr -z zookeeper.app.local:2181

Create Systemd Service File

Create a systemd service file usingvi /etc/systemd/system/solr.service

[Unit]
Description=Apache SOLR
After=syslog.target network.target remote-fs.target nss-lookup.target[Service]
User=solr
Type=forking
PIDFile=/home/solr/solr-7.3.0/bin/solr-8983.pid
ExecStart=/home/solr/solr-7.3.0/bin/solr start -c -h solr.app.local -p 8983 -z zookeeper.app.local:2181/solr -noprompt
ExecStop=/home/solr/solr-7.3.0/bin/solr stop
Restart=on-abnormal[Install]
WantedBy=multi-user.target

Reload & test setup

sudo systemctl daemon-reload
sudo systemctl start solr
sudo systemctl status solr

Now go to the browser and hit http://solr.app.local:8983 to access admin UI.

Hope this helped you get a good idea of how you should set up Solr as a system service. Happy searching!

I've set up Solr as a system service... What's next?

When you combine search with chatbot automation, you can deliver well-rounded experiences to your customers at all times. Ready to explore?

Register with Engati to bring life to your customer interactions!

Tags
No items found.
About Engati

Engati is a one-stop platform for delighted customers. With our intelligent bots, we help you create the smoothest of Customer Experiences. And now, we're even helping you answer your customers' most complicated questions in real-time with Engati Live Chat. So, let's get started?

Get Started Free
Limited Time Offer - WhatsApp automation chatbot now available at a reduced price - 180 USD for 10K messages, 250 USD for 30K messages, 320 USD for 100K messages, all inclusive