Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Install Apache Solr on Ubuntu 16.04

DZone's Guide to

How to Install Apache Solr on Ubuntu 16.04

Follow these steps to learn how to install Apache Solr, a search platform, onto your Alibaba Cloud instance running Ubuntu.

· Open Source Zone ·
Free Resource

New Report Reveals Open Source Risk Is Still a Mystery to Many. Read more.

Introduction

Apache Solr is a free and open source search platform written in Java that can be used to build search applications. It was built on top of Lucene project that provides full-text search, spell suggestions, custom document ordering and ranking, Snippet generation, and highlighting. Apache Solr allows us to create custom search engines that index databases, files, and websites. It is specially designed for scalability and fault tolerance. Apache Solr runs as a standalone full-text search server and uses the Lucene Java search library at its core for full-text indexing and search. You can also use Apache Solr with Hadoop to handles a large amount of data.

Features

  • Solr supports different file formats like XML, JSON and .CSV.
  • Solr can be deployed in any kind of systems such as standalone, distributed, cloud, etc.
  • Allows us to customize the components of Solr easily.
  • Solr provides an user-friendly, and feature-powered web interface that can be used to manage logs, add, delete, update and search documents.
  • Provides advanced text search capabilities including phrases, wildcards, joins, grouping and much more across any data type.

Requirements

  • A fresh Alibaba cloud instance with Ubuntu 16.04 server installed.
  • A static IP address 192.168.0.103 is configured on the instance.
  • A Root password is setup on the server. 

Launch Alibaba Cloud ECS Instance

First, log in to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

apt-get update -y

Install Java

By default, the latest version of Java is not available in Ubuntu 16.04 default repository. So, you will need to add the Java repository to your system. You can add Java repository using the following command:

apt-get install python-software-properties -y
add-apt-repository ppa:webupd8team/java

Once the Java repository is installed, update the repository and install Java with the following command:

apt-get update -y
apt-get install oracle-java8-installer -y

Once Java is installed, you can verify the version using the following command:

java -version

You should see the following output:

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Install Apache Solr

First, you will need to download the latest version of the Solr from their official website. You can do this using the following command:

cd /opt/
wget http://redrockdigimark.com/apachemirror/lucene/solr/7.3.1/solr-7.3.1.tgz

Now, extract the Solr service installation file from Solr source by running the following command:

tar xzf solr-7.3.1.tgz solr-7.3.1/bin/install_solr_service.sh

Next, install Solr as a service using the following command:

./install_solr_service.sh solr-7.3.1.tgz

Once Solr is installed, you should see the following output:

Service solr installed.
Customize Solr startup configuration in /etc/default/solr.in.sh
● solr.service - LSB: Controls Apache Solr as a Service
Loaded: loaded (/etc/init.d/solr; bad; vendor preset: enabled)
Active: active (exited) since Sun 2018-05-20 07:37:04 IST; 5s ago
Docs: man:systemd-sysv-generator(8)
Process: 2926 ExecStart=/etc/init.d/solr start (, /SUCCESS)
May 20 07:36:32 Node1 solr[2926]: *** [WARN] *** Your open file limit is currently 1024.
May 20 07:36:32 Node1 solr[2926]:  It should be set to 65000 to avoid operational disruption.
May 20 07:36:32 Node1 solr[2926]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
May 20 07:36:32 Node1 solr[2926]: *** [WARN] ***  Your Max Processes Limit is currently 3820.
May 20 07:36:32 Node1 solr[2926]:  It should be set to 65000 to avoid operational disruption.
May 20 07:36:32 Node1 solr[2926]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
May 20 07:37:04 Node1 solr[2926]: [458B blob data]
May 20 07:37:04 Node1 solr[2926]: Started Solr server on port 8983 (). Happy searching!
May 20 07:37:04 Node1 solr[2926]: [14B blob data]
May 20 07:37:04 Node1 systemd[1]: Started LSB: Controls Apache Solr as a Service.

You can check the status of Solr service at any time by running the following command:

service solr status

Output:

● solr.service - LSB: Controls Apache Solr as a Service
   Loaded: loaded (/etc/init.d/solr; bad; vendor preset: enabled)
   Active: activating (start) since Thu 2018-05-24 21:22:20 IST; 49s ago
     Docs: man:systemd-sysv-generator(8)
  Control: 569 (solr)
   CGroup: /system.slice/solr.service
           └─569 /bin/sh /etc/init.d/solr start
May 24 21:22:20 Node1 systemd[1]: Starting LSB: Controls Apache Solr as a Service...
May 24 21:22:21 Node1 su[580]: Successful su for solr by root
May 24 21:22:21 Node1 su[580]: + ??? root:solr
May 24 21:22:22 Node1 su[580]: pam_unix(su:session): session opened for user solr by ()
May 24 21:22:42 Node1 solr[569]: *** [WARN] *** Your open file limit is currently 1024.
May 24 21:22:42 Node1 solr[569]:  It should be set to 65000 to avoid operational disruption.
May 24 21:22:42 Node1 solr[569]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
May 24 21:22:42 Node1 solr[569]: *** [WARN] ***  Your Max Processes Limit is currently 9628.
May 24 21:22:42 Node1 solr[569]:  It should be set to 65000 to avoid operational disruption.
May 24 21:22:42 Node1 solr[569]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh

Create Your First Solr Collection

Now, create your first collection in Apache Solr by running the following command:

cd /opt
solr -c "/opt/solr/bin/solr create -c letsstarted -n data_driven_schema_configs"

You should see the following output:

Created new core 'letsstarted'

Access Solr Web Interface

Apache Solr is now up and running on port 8983. Open your web browser and type the URL http://yourdomain.com:8983, you should see the following page:

Image title

Now, click on the "Core Slector" on the left sidebar and select your created collection. You should see the statics of created collection in the following page:

Image title

Next, on the left sidebar click on the Documents, you should see the following page:

Image title

Here, add some documents like "Linux Cookbook" as shown in the following output:

{
 "id": 1,
 "book_title": "Linux Cookbook",
 "published": 2018,
 "description": "All about Linux"
}

Now, click on the Submit Document button to add your documents to the Index, you should see the following output:

Status: success
Response:

{
  "responseHeader": {
    "status": 0,
    "QTime": 1611
  }
}

Now, on the left sidebar click on the Query button, you should see the following page:

Image title

Now, click on the Execute Query button, you should see your created documents in the following page:

Image title


Software composition Analysis for DevSecOps. Start finding vulnerabilities in your open source components today.

Topics:
apache ,solr ,ubuntu ,open source ,search platform ,java ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}