All versions download available at: https://archive.apache.org/dist/lucene/solr/
Java available at: http://java.com/en/download/index.jsp
Solr 4.10 - requires Java 7, compatible with Java 8
Required from: Solr 4.8.0
All previous versions 1.x, 2.x, 3.x seem to work with Java 6 (JRE 1.6)
Last: Solr 4.7.2
Java 1.6.0_65
If it is upgrade from prevoius OS X version, then you inherited Java 6 from latest update in 10.6.
Otherwise you have to install manually Java from Oracle, 6, 7 or 8. Choose the version according to your needs, but there is no reason not to go with latest one.
- Check your Java Runtime Envoronment version with
java -version
- Download appropriate
solr
version - unpack and move somewhere to
/opt
or/usr
(it may live with tomcat container and own user athome
) - once moved, go into
$(SOLR_dir)/examples
and executecp -a solr mysolr
or use some name on your own instead of mysolr - copy schema files from module
search_api_solr
from appropriate version e.gsolr-conf/4.x/*
over the same named files inmysolr/collection1/conf/
. Make sure they are placed over, check by comparing size and date. - You need also connector library
SolrPhpClient
- Now you need to configure
search_api
, addSolr
server, add index and configure fields for index.
This is very important link between any PHP and Solr. There is a change in Solr 4.x that throws error:
solrexception: unknown commit parameter 'waitflush'
get the latest version with
$ svn export http://solr-php-client.googlecode.com/svn/trunk/ SolrPhpClient
If you are looking for particular version of the library, add -r22
after export
You may start solr
each time you need it in terminal by issuing command that starts java with arguments pointing to your configuration (you may alias it or make shell command).
This way is useful if you need solr
temporarily. It will run until stopped by CTRL + C
or by closing terminal window.
$ alias solr="cd /opt/solr-4.7.2/example/; java -server $JAVA_OPTS -Dsolr.solr.home=mysolr -jar start.jar
You should save as solr
in path to your local commands, for example /usr/local/bin
Also, if you supply argument, you may start different solr
profiles in example/
like $ solr other-solr
Still, it is active process that is terminated by CTRL + C
or by closing terminal window.
#!/bin/sh
if [ -z "$1" ]; then
PROFILE="mysolr" # enabling some other profile as well, otherwise use default mysolr
else
PROFILE=$1
fi
cd /opt/solr-4.7.2/example/ && java -server $JAVA_OPTS -Dsolr.solr.home=$PROFILE -jar start.jar
You can run the process in background leaving terminal for some other things. However, it will still be terminated by closing terminal window and will output solr
response to the window.
You run process in background by appending ampersand at the end of command, $ solr &
or direct $ java -jar start.jar &
. This is not actually useful.
Better approach is to go detached. Start solr
and detach process from terminal.
- Start the process by alias, command or direct,
$ solr
- Pause the process with
CTRL + Z
or you may start it in background as$ solr &
- Start it running in background
$ bg
- Release it from terminal process with
$ disown
That will release the last job from current terminal. - Use
$ disown -r
to release all running background processes - Use
$ disown -a
to release all background processes - Use
$ disown -h
to keep background process in jobs list but also keep it on terminal process closing - Use
$ disown -h %1
same as previous but uses number to identify process as listed withjobs
- Use
$ jobs
to see all background running processes - Use
$ jobs -l
to see job number and PID too
Briefly, just use this commands
$ solr mysolr &
$ disown
Use different port like -Djetty.port=8980
java -server $JAVA_OPTS -Dsolr.solr.home=other-solr -Djetty.port=8980 -jar start.jar
This enables running, stopping and restarting as service and starting upon reboot
Copy this into file /etc/init.d/solr
#!/bin/sh
# Starts, stops, and restarts Apache Solr.
#
# chkconfig: 35 92 08
# description: Starts and stops Apache Solr
SOLR_DIR="/var/solr-4.10.3/example"
JAVA_OPTIONS="-Xmx1024m -DSTOP.PORT=8079 -DSTOP.KEY=mustard -Dsolr.solr.home=mysolr -jar start.jar"
LOG_FILE="/var/log/solr.log"
JAVA="/usr/bin/java"
case $1 in
start)
echo "Starting Solr"
cd $SOLR_DIR
$JAVA $JAVA_OPTIONS 2> $LOG_FILE &
;;
stop)
echo "Stopping Solr"
cd $SOLR_DIR
$JAVA $JAVA_OPTIONS --stop
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
Edit the line starting with SOLR_DIR to make sure it's pointing to the location where your solr installation lives.
Make the script executable:
$ sudo chmod a+rx /etc/init.d/solr
Now install the script using chkconfig:
$ sudo chkconfig --add solr
This will add the script to runlevels 3 and 5, so solr will start once the system is up. Check to make sure that things are properly set up by typing
$ chkconfig --list
You should see solr among the various services. You should also be able to use the service
command to stop and start solr (you actual system may call it services
or some other — this starts daemons from /etc/init.d
)
$ sudo service solr stop
Stopping Solr
$ sudo service solr start
Starting Solr
$ sudo service solr restart
Stopping Solr
Starting Solr
Solr
shouldn't be accessible over internet but you may need that briefly in order to debug, check or setup so you need to open Firewall for your own IP but do not forget to close it afterwards! You may also use temporary allow access.
If you use iptables add a rule to allow access to Solr's admin section and query Solr data (replace 0.0.0.0 with the correct IP address):
$ iptables -A INPUT -s 0.0.0.0 -p tcp -m tcp --dport 8983 -j ACCEPT
$ service iptables save
Or, if you want to allow port 8983 for all requests use:
$ iptables -A INPUT -p tcp -m tcp --dport 8983 -j ACCEPT
$ service iptables save
Also, if you're using a MySQL database connection for data importer you'll want to open a firewall exception for the localhost MySQL port:
$ iptables -A INPUT -s 127.0.0.1 -p tcp -m tcp --dport 3306 -j ACCEPT
$ service iptables save
$ iptables -L
...
ACCEPT tcp -- localhost anywhere tcp dpt:mysql
...
Your Solr is accessible on port 8983 or othewise configured and on link /solr
like:
http://mydomain.com:8983/solr
where you can see basic settings in dashboard and log status in logging which is crucial to hunting down any problems.
When you wish to see Solr index you select (default is) collection1
from Core selector
(bellow Thread dump
) where you may run default query that will give you rough picture what is inside Solr index(es).
Very useful overview full of information.
By Shay Anderson on October 2013
Last updated October 5, 2010. Created on August 10, 2009. Edited by rfay, phd_hiren_g, Francewhoa, jvandyk all @ drupal.org
frjo – 1 June, 2009 Update 2010-01-05