6

I have made some changes at Solr Schema file and I see I 'am forced to restart SolR in order to have Solr running with new schema updates.

This is hosted on a server where solr is running from a start.jar file but I'am not sure how it was started(maybe with nohup)

I have found a way to stop SolR from another question(https://stackoverflow.com/questions/2150767/how-to-start-solr-automatically):

kill `ps uax | grep -i "java -jar start.jar" | head -n 1 | awk '{print $2}'`

After this, I start SolR with "java -jar start.jar".

Is this a correct way to do the restart or is there built-in/better way to restart the jar?

Orlando
  • 171
  • 1
  • 1
  • 3

4 Answers4

4

At Websolr, we use a combination of a custom init.d script plus Monit to start Solr and ensure that it stays running.

That said, for a simpler self-hosted setup, I would recommend using Upstart to start and stop Solr, if your system has Upstart available. Upstart scripts have the benefit of being fairly simple, and Upstart does a good job restarting processes in the event they crash. Plus the start and stop commands (start and stop, respectively) are pretty easy to remember for the next time you need to make Solr aware of new configs.

Here is a good blog post covering starting Solr with Upstart. I've copied their upstart script below; be sure to update the relevant paths to match your system:

description "Solr Search Server"

# Make sure the file system and network devices have started before
# we begin the daemon
start on (filesystem and net-device-up IFACE!=lo)

# Stop the event daemon on system shutdown
stop on shutdown

# Respawn the process on unexpected termination
respawn

# The meat and potatoes
exec /usr/bin/java -Xms128m -Xmx256m -Dsolr.solr.home=/path/to/solr/home -Djetty.home=/path/to/jetty -jar /path/to/jetty/start.jar >> /var/log/solr.log 2>&1
Nick Zadrozny
  • 201
  • 1
  • 3
4

You can try this approach http://wiki.apache.org/solr/CoreAdmin#RELOAD.

Using a command like this

http://localhost:8983/solr/admin/cores?action=RELOAD&core=core0

will just reload all your configuration files and you will not have problems in doing SOLR queries querying while the core is restarted.

Dorin
  • 141
  • 4
  • 2
    This doesn't work in a standard installation. Probably I need to enable SolR multicore features to be able to use this kind of reload. – Orlando Aug 25 '11 at 15:51
  • 1
    It worked for me: My solr.xml cores configuration looks like this: I used this link to reload core: http://localhost:8983/solr/admin/cores?action=RELOAD&core=collection1 – Dorin Aug 26 '11 at 10:23
  • Using the included Jetty (start.jar) seems a kludge. Consider setting it up in Tomcat in a multicore configuratiob. I included instructions in http://stackoverflow.com/questions/7188816/how-to-start-and-stop-solr-from-a-user-created-windows-service/7203038#7203038 – Jesvin Jose Aug 26 '11 at 10:49
1

For SolrCloud, from the solr folder run:

bin/solr restart -e cloud -noprompt
haky_nash
  • 111
  • 2
  • When you execute this command, by default it does not use the system wide configuration located in `/etc/default/solr.in.sh` but uses the `solr.in.sh` script located next to the `bin/solr` script. Do not do this unless you specify the same global configuration to use like the default service does by specifying the environment variable: `SOLR_INCLUDE="/etc/default/solr.in.sh"` – Ben DeMott Feb 08 '17 at 19:52
-1

you can press CTRL + C it will be stop solr and restart with java -jar start.jar

Sagar Patel
  • 111
  • 1
  • OP doesn't know how the jar was started, and has as such no access to a console where he can press CTRL + C. – jornane Mar 31 '16 at 07:17