Skip to main content

Looking to install Solr on your server?  Not sure if it worth the effort?  Well, Apache Solr is the open-source, popular, super fast open source enterprise search platform from the Apache Lucene project.  Written in Java, Solr is highly scalable, providing fault-tolerant distributed search and indexing.

Let's walk through the steps I went through to install Solr on Centos 7.

 

Step 1: Java

Check if Java is installed on your server:

java -version

Not there - then JAVA is the first step for you to set-up for Solr.  JAVA SE 8 or Later is required to run Apache Solr 8.  Utilisation taking after order to check in the event that you have Java introduced as of now on your system.

yum install java-11-openjdk

 

Step 2: Download & Extract Solr 8.11.2

You can download the latest version of Apache Solr from the official website or use the following command to download the Apache Solr.

cd /opt 
wget https://mirrors.estointernet.in/apache/lucene/solr/8.11.1/solr-8.11.1.tgz

However, revisiting this page, I've found the URL noted above failed... now use

wget https://www.apache.org/dyn/closer.lua/lucene/solr/8.11.2/solr-8.11.2.tgz

Now extract tar file using the following command:

tar xzf solr-8.11.2.tgz solr-8.11.2/bin/install_solr_service.sh –strip-components=2

Install Solr

./install_solr_service.sh solr-8.11.2.tgz

This action will create the account with the name of Solr on your system... using port 8983.

 

Step 3: Firewall

By default Solr runs on port 8983. If you have an active firewall, allow port 8983.

firewall-cmd --permanent --add-port=8983/tcp
firewall-cmd --reload

 

Step 4: Starting / stopping Solr

Use the following commands to Start and Stop the Solr service:

service solr start
service solr stop

 

Enable the service at boot time:

chkconfig solr on

 

Check the Solr status using the following command

service solr status

 

Step 5: Create a core

Create your first Solr collection using the following command

su - solr -c "/opt/solr/bin/solr create -c {corename} -n data_driven_schema_configs"

Replace {corename} with the name you want to use.  For me, I used devcore.  So my command was

su - solr -c "/opt/solr/bin/solr create -c devcore -n data_driven_schema_configs"

 

Step 6: Access Solr panel

OK, you have installed and fired up Solr.  Let's now see if you can access it via a web interface?  The port to access is 8983.  Using your IP Address or hostname, add :8983 at the end.  Used as

https://your_IP_Address:8983

 

Security

So you have installed and have Solr running.  The next step is security!

You can read more about security on the Solr security.json page.  Reading through the security.json page, you will need to find the solr.xml file.  If you don't know where it's located, use the find command:

find / -name solr.xml -type f

Which produced the results for me:

/opt/solr-8.11.2/server/solr/solr.xml
/opt/solr-8.11.2/example/exampledocs/solr.xml
/opt/solr-8.11.2/example/example-DIH/solr/solr.xml
/var/solr/data/solr.xml

In this instance, I'll use the solr.xml file in the /var directory.

 

If you need to tweak the jetty file... using the path above it will be located:

vim /opt/solr-8.11.2/server/etc/jetty.xml

 

Errors

After starting the Solr service the first time, I had the following error

*** [WARN] *** Your open file limit is currently 1024.
 It should be set to 65000 to avoid operational disruption.
 If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
*** [WARN] ***  Your Max Processes Limit is currently 4096.
 It should be set to 65000 to avoid operational disruption.
 If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Waiting up to 180 seconds to see Solr running on port 8983 [\]
Started Solr server on port 8983 (pid=13814). Happy searching!

 

You will have noticed that there are two errors in this output.

  1. Your open file limit is currently 1024.
  2. Your Max Processes Limit is currently 4096.

To learn more about Ulimits, the Solr Ulimit settings page is the home of solutions.  It is recommended that first, use ulimit -a command

ulimit -a

For me, this command produced:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 2061179
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 62987
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Solr Ulimit settings page recommends

The important settings to have set very high, unlimited if possible are:

  • max processes (ulimit -u): 65,000 is the recommended minimum.

  • file handles (ulimit -n): 65,000 is the recommended minimum. All the files used by all replicas have their file handles open at once so this can grow quite large.

  • virtual memory (ulimit -v): Set to unlimited. This is used to by MMapping the indexes.

  • max memory size (ulimit -m): Also used by MMap, set to unlimited.

To make the necessary changes, you will need to edit the limits.conf file.  This file is located in /etc/security directory.

vim /etc/security/limits.conf

Add at the bottom of the file the following

solr hard nofile 65535
solr soft nofile 65535
solr hard nproc 65535
solr soft nproc 65535

Then stop and start your Solr service using the following commands:

service solr stop
service solr start

When you restart your Solr service, you will no longer see the warnings.

 

Error - security.json file

If you receive the following error

Found 1 Solr nodes:

Solr process 19034 running on port 8983

ERROR: Failed to get system information from http://localhost:8983/solr due to: org.apache.solr.common.SolrException: Parse error : <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 javax.servlet.UnavailableException: Error processing the request. CoreContainer is either not initialized or shutting down.</title>
</head>
<body><h2>HTTP ERROR 404 javax.servlet.UnavailableException: Error processing the request. CoreContainer is either not initialized or shutting down.</h2>
<table>
<tr><th>URI:</th><td>/solr/admin/info/system</td></tr>
<tr><th>STATUS:</th><td>404</td></tr>
<tr><th>MESSAGE:</th><td>javax.servlet.UnavailableException: Error processing the request. CoreContainer is either not initialized or shutting down.</td></tr>
<tr><th>SERVLET:</th><td>default</td></tr>
<tr><th>CAUSED BY:</th><td>javax.servlet.ServletException: javax.servlet.UnavailableException: Error processing the request. CoreContainer is either not initialized or shutting down.</td></tr>
<tr><th>CAUSED BY:</th><td>javax.servlet.UnavailableException: Error processing the request. CoreContainer is either not initialized or shutting down.</td></tr>
</table>
<h3>Caused by:</h3><pre>javax.servlet.ServletException: javax.servlet.UnavailableException: Error processing the request. CoreContainer is either not initialized or shutting down.
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:162)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
    at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:322)
    at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
    at org.eclipse.jetty.server.Server.handle(Server.java:516)
    at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:400)
    at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:645)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:392)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
    at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.servlet.UnavailableException: Error processing the request. CoreContainer is either not initialized or shutting down.
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:376)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:357)
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201)
    at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191)
    at org.eclipse.jetty.server.handler.InetAccessHandler.handle(InetAccessHandler.java:177)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
    ... 15 more
</pre>

</body>
</html>

Check your security.json file.  Usually located /var/solr/data directory.  For me, this file had corrupted.  I cleared the file using the command

> security.json

Then re-entered the initial content that I needed.  Being

{
"authentication":{
   "class":"solr.BasicAuthPlugin",
   "credentials":{"solr":"{credential_code}"}
},
"authorization":{
   "class":"solr.RuleBasedAuthorizationPlugin",
   "permissions":[{"name":"security-edit",
      "role":"admin"}],
   "user-role":{"solr":"admin"}
}}

Replacing {credential_code} with an updated string.

 

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...
Andrew Fletcher06 Mar 2024
Terminal command to find and replace
In many terminal text editors, you use find command as reference in Terminal commands - find. &nbsp;How about find and replace. &nbsp;This action depends on the specific text editor you're using in the terminal. &nbsp;Here are a few common terminal text editors and how you can find and replace...
Andrew Fletcher17 Feb 2024
Drupal - Solr working through tm_X3b_en_body error
Having updated Solr, re-indexing wasn't working. The error in the logs wasDrupal\search_api_solr\SearchApiSolrException while indexing item entity:node/2386:en: Solr endpoint http://127.0.0.1:8983/ bad request (code: 400, body: Exception writing document id...