SOLR Config Tips

Increasing SOLR Heap Size:

If you manage a large number of files (especially text based documents) and are seeing SOLR crash with out of memory error in its logs, you can use the following tip to see if this solves the issue.

By default, Solr ships with 512MB for heap size. In some installations with large number of files (especially text based documents), this heap memory is not enough.  SOLR might crash in these cases with out of memory error in its logs.

  • Follow these steps to increase the heap size. 
  • In this example, the heap size is increased to 2G. 
  • Administrators can increase it more depending on their site needs.

To increase the Solr heap size:

  1. If SOLR server is not stopping when stopped from services, open the control panel and kill the java process. Make sure no process is listening at port 8983.
  2. SOLR may require more memory depending on the amount of data being indexed (JAVA OOM errors). In that case, the only option is to bump of the system memory and increase the JAVA heap limit

    Update Java heap limit for SOLR To 2GB
    In the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\solrservice\
    Look for the APP Parameters and add -m 2G 
    Restart the service.
  3. Start the SOLR service from FileCloud control panel or Windows services panel.

Changing Solr Temporary folder:

Changing java.io.tmpdir variable
1- in Linux
Add the following line to /etc/default/solr.in.sh:
SOLR_OPTS="$SOLR_OPTS -Djava.io.tmpdir=/your/tmp/dir"

2- in Windows
Add the following line to C:\xampp\solr\bin\solr.in.cmd
SOLR_OPTS="$SOLR_OPTS -Djava.io.tmpdir=/your/tmp/dir"

Make sure to restart Solr for the changes to take effect.

Enabling Authentication for Solr:

  1. Create a new file with name  security.json at /opt/solr76data/var/solr/data/security.json for Linux or C:\xampp\solr\server\solr\security.json for Windows
  2. Add the following lines to security.json file. This enables login with username "solr" and password "SolrRocks"
Enable Solr authentication
{
	"authentication": 
	{
		"blockUnknown": true,
		"class":"solr.BasicAuthPlugin",
		"credentials": {
			"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="
		}
	},
	"authorization":
	{
		"class":"solr.RuleBasedAuthorizationPlugin",
		"permissions":
		[
			{
				"name":"security-edit",
				"role":"admin"
			}
		],
		"user-role":
		{
			"solr":"admin"
		}
	}
}

3. Restart Solr and check http://localhost:8983/solr for authentication

4. Add the following entries to the cloudconfig:

cloudconfig.php entries
define("TONIDOCLOUD_SOLR_USERNAME", "solr");
define("TONIDOCLOUD_SOLR_PASSWORD", "SolrRocks"); 

5. To change the password please use the following command:

curl –user solr:SolrRocks http://localhost:8983/solr/admin/authentication -H 'Content-type:application/json' -d '{"set-user":{"solr":"NewPassword"}}'

6. To change the password for SSL protected SOLR server please use the following command:

curl -u solr:SolrRocks https://your_domain_name:8983/solr/admin/authentication -H 'Content-type:application/json' -d '{"set-user":{"solr": "codelathe"}}'

NOTE: "solr" username can be changed to anything but it has to be replaced for all the steps (including the initial config).


7. To make solr daemon detect Solr status you need to update the following config files:

Changing java.io.tmpdir variable
1- in Linux
Add the following line to /etc/default/solr.in.sh:
SOLR_AUTH_TYPE="basic"
SOLR_AUTHENTICATION_OPTS="-Dbasicauth=solr:codelathe"

2- in Windows
Add the following line to C:\xampp\solr\bin\solr.in.cmd
SOLR_AUTH_TYPE="basic"
SOLR_AUTHENTICATION_OPTS="-Dbasicauth=solr:codelathe"

This necessary only if authentication is enabled on solr