How to Start Solr Automatically

How to start Solr automatically?

If you have root access to your machine, there are a number of ways to do this based on your system's initialization flow (init scripts, systemd, etc.)

But if you don't have root, cron has a clean and consistent way to execute programs upon reboot.

First, find out where java is located on your machine. The command below will tell you where it is:

$ which java

Then, stick the following code into a shell script, replacing the java path below (/usr/bin) with the path you got from the above command.

#!/bin/bash

cd /usr/java/apache-solr-1.4.0/example
/usr/bin/java -jar start.jar

You can save this script in some location (e.g., $HOME) as start.sh. Give it world execute permission (to simplify) by running the following command:

$ chmod og+x start.sh

Now, test the script and ensure that it works correctly from the command line.

$ ./start.sh

If all works well, you need to add it to one of your machine's startup scripts. The simplest way to do this is to add the following line to the end of /etc/rc.local.

# ... snip contents of rc.local ...
# Start Solr upon boot.
/home/somedir/start.sh

Alternatively, if you don't have permission to edit rc.local, then you can add it to your user crontab as so. First type the following on the commandline:

$ crontab -e

This will bring up an editor. Add the following line to it:

@reboot /home/somedir/start.sh

If your Linux system supports it (which it usually does), this will ensure that your script is run upon startup.

If I don't have any typos above, it should work out well for you. Let me know how it goes.

How to run solr on a windows server so it starts up automatically?

Create a batch file with the command you need and run it on startup: some of these ideas might be of use.

If you ran solr inside tomcat, you could start tomcat as a windows service and set the service to start automatically.

Run Solr 6.0.1 in background on Windows server

You can use NSSM to register Solr as a Windows Service.

"c:\Program Files\nssm\win64\nssm" install solr6

It's important that you use the -f parameter to run Solr in the foreground (which in this case means "run it inside NSSM"). This can be changed in the box that pops up for NSSM ("Arguments"). You can also pick which user to run the service as under "Log on".

How to run multiple SOLR instances automatically on startup?

Changed the commands a little bit and it worked.

cd /home/ubuntu/solr1/example
nohup /usr/bin/java -jar start.jar > output.log 2>&1 &

cd /home/ubuntu/solr2/example
nohup /usr/bin/java -Djetty.port=8984 -jar start.jar > output2.log 2>&1 &

How to start Solr Cloud collection without -e -cloud

All collections are available by default, so starting Solr in cloud mode should be enough.

bin/solr start -c

The default port is 8983, so there is no need to give the -p parameter unless you're changing it.



Related Topics



Leave a reply



Submit