How to stop solr with command line

2020-05-19 06:31发布

问题:

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.

回答1:

-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.



回答2:

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.



回答3:

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)



回答4:

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



回答5:

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



标签: solr