Big Data Hadoop & Spark

How to Install SOLR on CentOS

Apache Solr is an open source search engine.  It helps in accessing large libraries in a fast and responsive way.
Why Solr?
With this new technology in the market of Big Data, we came up with many new languages. Using Solr, there is no need of new languages.

  • Simply put full text and expect an answer
  • Solr queries the data inside, without actually writing queries, but by only writing simple natural texts. Which is later changed into queries and a result is driven.
  • Solr makes multiple databases centralized with the search option.
  • The indexing is totally controlled by developer at the backend, the client will only use the front-end dashboard to perform text queries.

Steps to Install Solr and Make it Work

Assuming you do not have any dependencies present in your system. Let’s check all the way from starting step-by-step along with screenshots.
Step 1: Update your system
Open your terminal and type in the following command:
Sudo yum update
It may ask for a password, provide your root password.

Let your system update completely. It may take some time, so be patience and do not turn off your machine.

Step 2: Install the latest version of Java

Although you may have installed Java which is already present in a system.
We need the latest version of Java as Solr dependencies.
Check the latest version of Java present at your time of installation by the following command.

[[email protected] ~]$ yum list available | grep -i jdk
java-1.6.0-openjdk-demo.x86_64              1:1.6.0.41-1.13.13.1.el6_8  updates
java-1.6.0-openjdk-devel.x86_64             1:1.6.0.41-1.13.13.1.el6_8  updates
java-1.6.0-openjdk-javadoc.x86_64           1:1.6.0.41-1.13.13.1.el6_8  updates
java-1.6.0-openjdk-src.x86_64               1:1.6.0.41-1.13.13.1.el6_8  updates
java-1.7.0-openjdk-demo.x86_64              1:1.7.0.121-2.6.8.1.el6_8   updates
java-1.7.0-openjdk-javadoc.noarch           1:1.7.0.121-2.6.8.1.el6_8   updates
java-1.7.0-openjdk-src.x86_64               1:1.7.0.121-2.6.8.1.el6_8   updates
java-1.8.0-openjdk.x86_64                   1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-debug.x86_64             1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-demo.x86_64              1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-demo-debug.x86_64        1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-devel.x86_64             1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-devel-debug.x86_64       1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-headless.x86_64          1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-headless-debug.x86_64    1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-javadoc.noarch           1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-javadoc-debug.noarch     1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-src.x86_64               1:1.8.0.121-0.b13.el6_8     updates
java-1.8.0-openjdk-src-debug.x86_64         1:1.8.0.121-0.b13.el6_8     updates
ldapjdk.x86_64                              4.18-6.el6                  base
ldapjdk-javadoc.x86_64                      4.18-6.el6                  base


.
Copy the latest version name and give input to the next command. Refer to the screenshot below.

[[email protected] ~]$ yum install java-1.8.0-openjdk.x86_64

It will ask for permission to download the file.
Give yes.

Now to confirm if Java installed successfully, type the following command:

[[email protected] ~]$ java -version
java version “1.7.0_121”
OpenJDK Runtime Environment (rhel-2.6.8.1.el6_8-x86_64 u121-b00)
OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)

If the command does not show a similar output similar as shown below, then reboot your system.
Note: Also, update your .bashrc.

Step 3: Download Solr

Follow the hyperlink below to get the solr.tar.gz file for your Linux system.
link for google drive
Now, untar the file using the following command:

[[email protected]]$ tar -xvf solr-6.4.0.tgz


This will give your Solr framework to work with. I have kept my untar file in /usr/local/ so I will not make any changes to the framework by mistake.

Step 4: Ignite the Solr Engine

Change the directory where you have your Solr Engine
[[email protected]]$ cd /usr/local/solr-6.4.0
And give the following command to start the Engine:
Note: The command give below will only work on a specific version of Solr 6.4. The reason is that Solr is changing the framework very frequently in order to achieve ease.

[[email protected] solr-6.4.0]$ bin/solr start -e cloud -noprompt
Welcome to the SolrCloud example!
Starting up 2 Solr nodes for your example SolrCloud cluster.
Creating Solr home directory /usr/local/solr-6.4.0/example/cloud/node1/solr
Cloning /usr/local/solr-6.4.0/example/cloud/node1 into
/usr/local/solr-6.4.0/example/cloud/node2
Starting up Solr on port 8983 using command:
bin/solr start -cloud -p 8983 -s “example/cloud/node1/solr”
Waiting up to 180 seconds to see Solr running on port 8983 [-] Started Solr server on port 8983 (pid=25562). Happy searching!
Starting up Solr on port 7574 using command:
bin/solr start -cloud -p 7574 -s “example/cloud/node2/solr” -z localhost:9983
Waiting up to 180 seconds to see Solr running on port 7574 [/] Started Solr server on port 7574 (pid=25904). Happy searching!
INFO – 2017-02-01 15:05:55.371; org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; Cluster at localhost:9983 ready
Connecting to ZooKeeper at localhost:9983 …
INFO – 2017-02-01 15:05:56.482; org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; Cluster at localhost:9983 ready
Uploading /usr/local/solr-6.4.0/server/solr/configsets/data_driven_schema_configs/conf for config gettingstarted to ZooKeeper at localhost:9983
Creating new collection ‘gettingstarted’ using command:
http://localhost:8983/solr/admin/collections?action=CREATE&name=gettingstarted&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=gettingstarted
{
“responseHeader”:{
“status”:0,
“QTime”:69702},
“success”:{
“192.168.98.128:8983_solr”:{
“responseHeader”:{
“status”:0,
“QTime”:61751},
“core”:”gettingstarted_shard2_replica1″},
“192.168.98.128:7574_solr”:{
“responseHeader”:{
“status”:0,
“QTime”:61686},
“core”:”gettingstarted_shard2_replica2″}}}
Enabling auto soft-commits with maxTime 3 secs using the Config API
POSTing request to Config API: http://localhost:8983/solr/gettingstarted/config
{“set-property”:{“updateHandler.autoSoftCommit.maxTime”:”3000″}}
Successfully set-property updateHandler.autoSoftCommit.maxTime to 3000
SolrCloud example running, please visit: http://localhost:8983/solr
[[email protected] solr-6.4.0]$

Refer the screenshot for the same below.


Once you get a message in your terminal stating solrCloud is running, go to a Web browser to check if it is working.
Type the following address path to enter Solr work engine.
http://localhost:8983/solr
Where 8983 is the default port for Solr.
This is the dashboard for Solr. Where the first thing we see is the time that Solr is running since.
Also, we find the Lucene version the Solr is using. Lucene is the platform that Solr uses to run in the background.

Step 5: Starting the Solr Core 

We will see how to start core which is already defined in the package. We need to give the following command in terminal to include inside the running Solr framework.
Command: bin/post -c gettingstarted example/exampledocs/*.xml
*Note: I am already present inside the Solr directory

This will include all the examples already present in XML formats in example/exampledocs/.
Now again come to the browser where Solr UI was running.
And press getting started as shown below. And then press Query.

You may need a new form to fill with lots of fields to fill. Do not worry, just check if q has *:* present inside, and press ExecuteQuery. Refer to the following screenshots:


The q represents the query (here, All data) and wt represents the result format (here, JSON format)
You will find results appear on the right-hand side of the same page, as shown below. Refer the screenshot below:
Result contains 3 major parts

  • ResponseHeader
  • Response
  • Docs

Hence your solr is installed and ready to play.

Keep visiting www.acadgild.com for more updates on the Technologies and Certification courses.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Close