23

I want to stop solr by command so if find this article

http://rc98.net/solrinit

echo "Stopping Solr"
        cd $SOLR_DIR
        java -Xmx1024m -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar --stop

what is Xmx1024m ?

and where i will find DSTOP.KEY ?

Please tell proper procedure to start and stop solr by command line.

XMen
  • 29,384
  • 41
  • 99
  • 151

5 Answers5

39

solr stop -all # Stops all the ports

solr stop -p 8983 # Stop the particular port

If it shows the error ERROR: Port 8983 is already being used by another process., kill the console window which runs Solr by Ctrl-C and then try one of the above options. Because killing the console window does not stop the service.

chmodsss
  • 711
  • 8
  • 18
26

-XmX1024m - is the java parameter and specifies the maximum java heap size, which in your case is set to 1 GB.

stopkey is a secret key on startup which must also be present on the termination request to enhance security.

You can find a detailed explanation @ http://docs.codehaus.org/display/JETTY/Securing+Jetty

Example -

Starting solr with Jetty -

java -DSTOP.PORT=8079 -DSTOP.KEY=mysecret -jar start.jar

Stopping Solr with Jetty -

java -DSTOP.PORT=8079 -DSTOP.KEY=mysecret -jar start.jar --stop

the STOP.KEY is the secret key which should match during the stop command.

Jayendra
  • 52,349
  • 4
  • 80
  • 90
  • i am not able to do stop with , can u explain in step what i need to do start solr and stop solr ? – XMen Nov 02 '11 at 06:27
  • 2
    Updated the answer. Kindly take some efforts to go through the simple documentation mentioned in the answer. Its very clearly mentioned there. – Jayendra Nov 02 '11 at 10:22
  • when i run java -DSTOP.PORT=8079 -DSTOP.KEY=mysecret -jar start.jar after stoping solr in example directory it say address already in use and doesn't start the solr , what can be done – XMen Nov 03 '11 at 05:07
  • The commands work fine, and the stop command stops the process and the address in unbound. Check when the stop commond is execute does you jetty stop completely and there is no other jetty process running. – Jayendra Nov 03 '11 at 05:56
  • i have other jetty running in hbase and hadoop so how they can reflect in jetty of solr and why so i stop hbase , how can i proceed – XMen Nov 03 '11 at 06:13
  • That may not hinder it as it completely different process. can you check bringing it down, if the normal start stop works ? – Jayendra Nov 03 '11 at 10:17
  • no normal start doesn't then for stop i need to kill the process of start.jar – XMen Nov 04 '11 at 05:43
18

You could run (where 8983 is the default solr port)

lsof -i :8983

which will return PID#, then use

kill -9 PID#

to kill that pid (run it without the hash)

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
Maged Makled
  • 1,918
  • 22
  • 25
  • This worked for me as well. Couldn't get accepted answer to work. – Esteban May 14 '15 at 05:23
  • Or: "fuser -k 8983/tcp" (as seen in: http://stackoverflow.com/a/11596144/2265487) And include in .bashrc an alias for ease of use: alias solr_stop='fuser -k 8983/tcp' – ElMesa Jan 27 '16 at 18:00
  • 4
    That is a really bad idea!! Why not even let Solr have a chance to shut down cleanly by using `kill` (without `-9`) first. The `STOP.PORT` method is safest, but `kill`ing it normally works fine, too. With `kill -9` you risk a corrupted index and to loose all data. – Stefan Seidel Oct 19 '16 at 07:10
  • Doing this could have bad consequences. Try to close gracefully. Downvoted. – Tomas Gonzalez May 24 '22 at 03:35
7

This worked for me if rake sunspot:solr:stop doesn't work

ps -ef | grep solr

then using the information returned

sudo kill <process_id>

example:

sudo kill 792

WiredIn
  • 4,157
  • 4
  • 27
  • 23
  • You should not kill the process. Try to close gracefully. Solr needs to persist changes and so some cleanup before closing. – Tomas Gonzalez May 24 '22 at 03:36
1

For local operation, you can kill the Solr server by pressing Ctrl-c in the console window in which you started Solr. Typically, this is safe enough for development and testing

Nanhe Kumar
  • 15,498
  • 5
  • 79
  • 71