For a few weeks now, I’ve been involved with getting SOLR up and running (actually a bit more than that :). I’ve had my share of issues getting things to work exactly as intended and will be writing a series of posts that explain how to accomplish various tasks with this wonderful and powerful piece of software.
For starters, this post describes a simple way of getting multicore (multi-index for those of you used to lucene terminology) to work with a fresh tomcat install.
- Download and install Tomcat 6.x in a directory of your choice. Tomcat 6.x can be downloaded from http://tomcat.apache.org/download-60.cgi
- Download SOLR and unzip it to a directory, henceforth referred to as <solrdist>. We’re using SOLR 4 which is yet unreleased at the time of writng but can be downloaded from https://builds.apache.org/job/Solr-trunk/lastSuccessfulBuild/artifact/artifacts/
- Create a directory that will host all the SOLR related files and directories, .. henceforth referred to <solrhost> (C:\java\solr4tomcatinstall\solrhost in this example).
- Edit bin/catalina.bat by appending <solrhost> to the JAVA_OPT variable eg. add this line early in the file around where CATALINA_HOME is first referenced. Note that the Xmx parameter and value are optional (use / tweak this setting if you have heap errors when using SOLR).
set JAVA_OPTS=%JAVA_OPTS% -Dsolr.solr.home=C:\java\solr4tomcatinstall\solrhost -Xmx1000m
- Edit Tomcat’s conf/server.xml and add the following URIEncoding attribute to the correct Connector element:
<Server ...> <Service ...> <Connector ... URIEncoding="UTF-8"/> ... </Connector> </Service> </Server>
- In the <solrhost> directory, create a file called solr.xml that looks like this.
<?xml version="1.0" encoding="UTF-8" ?> <solr persistent="true" sharedLib="lib"> <cores adminPath="/admin/cores"> <core schema="schema.xml" instanceDir="cores\" name="dummycore" dataDir="dummycore" conf="solrconfig.xml"/> </cores> </solr>
- In the <solrhost> directory, create the following directories: cores, cores/conf and lib . The lib directory will contain all the shared SOLR and third party libs. The cores directory will contain the indices for all cores created in future
- Now, copy all the jars (including those in subdirectories) from <solrdist>/contrib/* and <solrdist>/dist/ to <solrhost>/lib . These will be shared across all cores, as configured in the solr.xml a couple of steps above. Do not copy the solr*.war file.
- Copy the solr*.war file from <solrdist>/dist/ to <tomcat>/webapps/ and rename it as solr.war .
- Copy <solrdist>/ example/solr/conf to <solrhost>/cores/conf . The configuration will be customized later.
- Now, attempt to start tomcat via <tomcat>/bin/catalina.bat run . There should be no errors
- Navigate to the SOLR management UI at http://localhost:8080/solr/ . The UI should load and “dummycore” should be visible and available.