From charlesreid1

Line 73: Line 73:
==Using Tomcat==
==Using Tomcat==


{{mbox|text='''NOTE:''' This installation procedure is for Solr 3.6 and Tomcat 6.0. If you have an older version of Solr, you may need a different installation procedure (see e.g. http://wiki.apache.org/solr/SolrTomcat)
{{mbox|text='''NOTE:'''  
 
* This installation procedure is for Solr 3.6 and Tomcat 6.0. If you have an older version of Solr, you may need a different installation procedure (see e.g. http://wiki.apache.org/solr/SolrTomcat or http://www.ibm.com/developerworks/java/library/j-solr1/)
 
* This installation procedure will walk you through how to create an instance of Solr that runs on a Tomcat server. The way this works is, Tomcat will run an instance of Solr out of an arbitrary directory containing the Solr example you built above.
}}
}}


You can run Solr through [[Tomcat]], another Apache product that is basically a Java-based HTTP server (as opposed to the C-based [[Apache]] HTTP server). See the [[Tomcat]] page for installation/run instructions for Tomcat.
You can run Solr through [[Tomcat]], a Java-based HTTP server from the Apache Software Foundatino (contrast that with the more common C-based [[Apache]] HTTP server). See my [[Tomcat]] page for installation/run instructions for Tomcat.
 
===Download Solr===
 
See above.
 
===Build Solr and Solr example===
 
See above.
 
===Create Solr user in Tomcat===
 
in <code>$CATALINA_HOME/conf/tomcat-users.xml</code>, define a new admin user for Solr:
 
<pre>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="password" roles="manager,admin"/>
</pre>
 
===Create standalone Solr example directory===
 
You will want to create a standalone directory that holds your Solr example. Tomcat will run a particular instance of Solr out of this standalone directory. I used <code>/opt/solr</code>.
 
Now you'll copy the Solr example that you built above into <code>/opt/solr</code>:
 
<pre>
$ cp -r /path/to/apache-solr-6.0/example /opt/solr/.
</pre>
 
===Specify Solr Data Directory===
 
To specify where the Solr instance is located, you'll need to edit <code>/opt/solr/conf/solrconfig.xml</code> and change the <code>dataDir</code> tag to point to the standalone Solr example's data directory:
 
<pre>
<dataDir>${solr.data.dir:/opt/solr/example/solr/data}</dataDir>
 
</pre>
 
===Tell Tomcat How To Run Solr===
 
You can tell Tomcat how to run Solr by creating a <code>docBase</code> fragment that points to the Solr war file. Create this file:
 
<pre>
$CATALINA_HOME/conf/Catalina/localhost/solr-example.xml
</pre>
 
with the following contents:
 
<pre>
 
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/example/solr/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/opt/solr/example/solr" override="true"/>
</Context>
 
</pre>
 
===Test It Out===
 
Start up the Tomcat server:
 
<pre>
$CATALINA_HOME/bin/startup.sh run
</pre>
 
and go to
 
<pre>
http://localhost:8080/solr-example/admin
</pre>
 
and you should see something like this:
 
[[Image:SolrExample2.png|600px]]
 
 
 
Ant dist made the war file
 
Ant example built the example
 
 
The Solr installation directory will be denoted <code>$SOLR_HOME</code>. For me, this was <code>${HOME}/pkg/solr/3.6.0/solr</code>.
 
The Solr example that you built (above) should be located in <code>$SOLR_HOME/example/solr</code>.
 
The solr.war file (war = web app resource) should be located in <code>$SOLR_HOME/example/webapps/solr.war</code>.
 
The data directory should be located in <code>$SOLR_HOME/example/solr/data</code>.
 
===Installing/Running Solr From Alternate Directory===
 
 
 
 
 
 


The Solr installation directory will be denoted <code>$SOLR_HOME</code>. The Solr example should be located in <code>$SOLR_HOME/example/solr</code>.


Copy the .war file (war = web app resource) from <code>./solr/example/webapps/solr.war</code>
[[Category:Programs]]
[[Category:Web]]

Revision as of 04:20, 8 June 2012

Solr is a search engine server that allows for querying via HTTP, JSON, or XML, and returns results in JSON or XML.

I'm trying to use it to create a searchable database of text files.

Installation

Download it and compile it by using Ant (a Java-based make program):

$ wget http://mirror.metrocast.net/apache/lucene/solr/3.6.0/apache-solr-3.6.0-src.tgz

$ tar xzf apache-solr-3.6.0-src.tgz

$ cd apache-solr-3.6.0

$ ant ivy-bootstrap # this installs ivy, an Ant dependency

$ ant compile

It'll take a couple of minutes to finish.

Test

You can test everything by running

$ ant test

Making War

Make a .war file by doing this:

$ cd /path/to/apache-solr-3.6.0/solr

$ ant dist

Again, this will take a while.

Making Example

Make the Ant example by typing

$ cd /path/to/apache-solr-3.6.0/solr

$ ant example



Running Solr

Using Jetty (Defualt)

{{ibox|text="NOTE: The installation process described below is for Solr 3.6 and Tomcat 6.0. Older versions of Solr may require a different installation procedure (see, e.g., http://wiki.apache.org/solr/SolrTomcat)

To run Solr, you have to have a web server running locally. The example that is distributed with Solar is also distribute with Jetty, a lightweight Java web server. After you've finished running the above commands and have made the Solr example, type:

$ java -jar start.jar

This will start the Jetty server and get Solr running from within Jetty. Visiting hlocalhost:8983/solr/admin should look something like this:

SolrExample1.png

Using Tomcat

You can run Solr through Tomcat, a Java-based HTTP server from the Apache Software Foundatino (contrast that with the more common C-based Apache HTTP server). See my Tomcat page for installation/run instructions for Tomcat.

Download Solr

See above.

Build Solr and Solr example

See above.

Create Solr user in Tomcat

in $CATALINA_HOME/conf/tomcat-users.xml, define a new admin user for Solr:

<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="password" roles="manager,admin"/>

Create standalone Solr example directory

You will want to create a standalone directory that holds your Solr example. Tomcat will run a particular instance of Solr out of this standalone directory. I used /opt/solr.

Now you'll copy the Solr example that you built above into /opt/solr:

$ cp -r /path/to/apache-solr-6.0/example /opt/solr/.

Specify Solr Data Directory

To specify where the Solr instance is located, you'll need to edit /opt/solr/conf/solrconfig.xml and change the dataDir tag to point to the standalone Solr example's data directory:

 
<dataDir>${solr.data.dir:/opt/solr/example/solr/data}</dataDir>

Tell Tomcat How To Run Solr

You can tell Tomcat how to run Solr by creating a docBase fragment that points to the Solr war file. Create this file:

$CATALINA_HOME/conf/Catalina/localhost/solr-example.xml

with the following contents:


<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/example/solr/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/opt/solr/example/solr" override="true"/>
</Context>

Test It Out

Start up the Tomcat server:

$CATALINA_HOME/bin/startup.sh run

and go to

http://localhost:8080/solr-example/admin

and you should see something like this:

SolrExample2.png


Ant dist made the war file

Ant example built the example


The Solr installation directory will be denoted $SOLR_HOME. For me, this was ${HOME}/pkg/solr/3.6.0/solr.

The Solr example that you built (above) should be located in $SOLR_HOME/example/solr.

The solr.war file (war = web app resource) should be located in $SOLR_HOME/example/webapps/solr.war.

The data directory should be located in $SOLR_HOME/example/solr/data.

Installing/Running Solr From Alternate Directory