Table of Contents
- Introduction
- Requirements
- Installing Java
- Downloading and Installing Apache Solr
- Allow Solr Through the Firewall
- Accessing the Solr Web Interface
- Securing the Solr Admin Page
- Summary
Introduction
Apache Solr is a free, open-source, and popular enterprise search platform built on Apache Lucene. It allows you to create custom search engines that index files, databases, and websites. Solr is specially designed for scalability and fault tolerance. Solr provides lots of features such as distributed indexing, replication, load balancing, automated failover and recovery, and centralized configuration management.
In this tutorial, we will learn how to install and do some basic configuration of Apache Solr on CentOS 7.
Requirements
- A server running CentOS 7.
- A non-root user with sudo privilege setup on your server.
Installing Java
Before starting, update your system with the latest versions of installed packages.
sudo yum update
You will need to install the latest version of Java on your server as Java is a prerequisite for installing Solr.
To install Java, run the following command:
sudo yum install java-1.8.0-openjdk.x86_64
Once Java is installed, you can verify it by running the following command:
sudo java -version
Output:
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)
Downloading and Installing Apache Solr
First you will need to download the latest version of Apache Solr from the Apache website.
You can easily download it using the wget
command:
wget http://apache.org/dist/lucene/solr/6.3.0/solr-6.3.0.tgz
Once the download is completed, extract the service installation file with the following command:
tar xzf solr-6.3.0.tgz solr-6.3.0/bin/install_solr_service.sh --strip-components=2
Install Solr as a service by running the following command:
sudo bash ./install_solr_service.sh solr-6.3.0.tgz
You should see the following output:
We recommend installing the 'lsof' command for more stable start/stop of Solr
Extracting solr-6.3.0.tgz to /opt
Installing symlink /opt/solr -> /opt/solr-6.3.0 ...
Installing /etc/init.d/solr script ...
Installing /etc/default/solr.in.sh ...
Service solr installed.
Customize Solr startup configuration in /etc/default/solr.in.sh
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.
Started Solr server on port 8983 (pid=6426). Happy searching!
Found 1 Solr nodes:
Solr process 6426 running on port 8983
{
"solr_home":"/var/solr/data",
"version":"6.3.0 a66a44513ee8191e25b477372094bfa846450316 - shalin - 2016-11-02 19:52:42",
"startTime":"2016-11-30T06:49:18.927Z",
"uptime":"0 days, 0 hours, 0 minutes, 18 seconds",
"memory":"85.4 MB (%17.4) of 490.7 MB"}
You can start|stop|restart the Solr service with the following commands:
sudo service solr start
sudo service solr stop
sudo service solr restart
Allow Solr through Firewall
By default Solr listens on port 8983
, so you will need to allow this port through firewall.
You can do this by running the following command:
sudo firewall-cmd --zone=public --add-port=8983/tcp --permanent
sudo firewall-cmd --reload
Accessing Solr Web Interface
Now that we have enabled access through the firewall, it is time to access Solr web interface.
Open your web browser and type the URL http://your-server-ip:8983/solr
. You should see the Solr dashboard as below:
Securing Solr Admin Page
By default the Apache Solr server admin pages are left unprotected. It is recommended that you secure it with a password.
To do so, you will need to modify webdefault.xml
file:
sudo nano /opt/solr/server/etc/webdefault.xml
Add the following lines before <web-app>
:
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>samplerealm</realm-name>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure resources</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
Create a samplerealm.txt
file:
sudo nano /opt/solr/server/etc/samplerealm.txt
Add the following lines:
admin: admin@123,user
This sets admin
as your username, admin@123
as the password and user
as the role which you have defined in webdefault.xml
file.
Next you will also need to modify jetty.xml
file:
sudo nano /opt/solr/server/etc/jetty.xml
Find the section <Configure id="Server" class="org.eclipse.jetty.server.Server">
and add the following lines of code below it:
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">samplerealm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/samplerealm.txt</Set>
<Set name="refreshInterval">0</Set>
</New>
</Arg>
</Call>
Save the file and restart the Solr service.
sudo service solr restart
Open your web browser and type the URL http://your-server-ip:8983/solr
, it will ask you for credentials. Provide admin
as your username and admin@123
as a password. You can also change the username and password as you wish by editing the samplerealm.txt
file.
Summary
In this tutorial we have demonstrated how to install Solr on a CentOS 7 server. Feel free to comment below if you have any questions or ran into issues following the tutorial.
Hi Hitesh
After follow step for "Securing Solr Admin Page" ..solr admin page is not accessible it give error like "HTTP ERROR: 503 Problem accessing /solr/. Reason: Service Unavailable.
The currently defined JAVA_HOME (/usr/local/jdk) refers to a location where Java could not be found. Aborting. Either fix the JAVA_HOME variable or remove it from the environment so that the system PATH will be searched.
i have probloem same as pdpatel.er issue. after change all file and restart the service solr still stop.
i use
update yum
, then check java version that are 1.8... but when i want toservice solr start
after 180sec show this error:```
[root@server1 ~]# service solr stop
No process found for Solr node running on port 8983
[root@server1 ~]# service solr start
Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'.
Waiting up to 180 seconds to see Solr running on port 8983 [|] Still not seeing Solr listening on 8983 after 180 seconds!
2017-12-04 14:42:45.175 WARN (main) [ ] o.e.j.x.XmlConfiguration Config error at < Arg name="threadpool">
</arg>
```
A tutorial is installed for the happiness and entertainment of the people. The motive of the tutorial and british assignments help is assigned for the motivating elements for the help of the individuals.