Here the instructions for a CentOS 6 with an already-installed Java 1.7 for Solr 5 without Tomcat.
cd yum install lsof unzip wget http://www.eu.apache.org/dist/lucene/solr/5.3.0/solr-5.3.0.tgz tar zxvf solr-5.3.0.tgz cd solr-5.3.0/bin
Now run the install_solr_service script as documented on official documentation:
mkdir /usr/local/etc/apache-solr-5 ./install_solr_service.sh ../../solr-5.3.0.tgz -i /usr/local/etc/apache-solr-5 -d /var/mysolr5 -u mysolr5 -s mysolr5 -p 5448
To get the current status:
service mysolr5 status
The service is already set to autostart:
chkconfig --list | grep solr mysolr5 0:off 1:off 2:on 3:on 4:on 5:on 6:off
If you want to secure the Solr instance running it only on localhost, you can add a custom SOLR_OPTS:
nano /var/mysolr5/solr.in.sh # Anything you add to the SOLR_OPTS variable will be included in the java # start command line as-is, in ADDITION to other options. If you specify the # -a option on start script, those options will be appended as well. Examples: # ... # run only on localhost SOLR_OPTS="$SOLR_OPTS -Djetty.host=127.0.0.1"
Apply the changes and then check where the service is running:
service mysolr5 restart netstat -tulpn | grep java tcp 0 0 ::ffff:127.0.0.1:4448 :::* LISTEN 11273/java tcp 0 0 ::ffff:127.0.0.1:5448 :::* LISTEN 11273/java
Before was available to all clients:
tcp 0 0 :::5448 :::* LISTEN 24541/java
As alternative of the standard service you can use a nice tool like supervisor using the -f option to execute the command from there: I try before without the argument and supervisord will start the service on the client but it will not stop. Not good. The -f (foreground) option can solve this issue but I haven’t tested yet.
Tomcat is another way to run solr. I’ve used it in the past for multicore solr, but I will not use it anymore because I prefer single core running on multiple instances on different port. With this approach you can have a solr 5.x and 3.x instances running on the same server, not exactly efficient for consumed resources but really really more easy to deploy and maintain than Tomcat / multicore. So I’m happy with the service right now.