Solr tomcat setup

In the production env, we need to create sponge account to do below steps.
for now, just use solr as example.
Server is SOLRMASTER

1. Install JDK or JRE(1.6)

2. Download the Solr and tomcat binary.
You can get it from here.
[solr@SOLRMASTER ~]$ pwd
/home/solr
[solr@SOLRMASTER ~]$ ls -lrt
total 91372
-rw-r--r-- 1 root    root          1261 Apr 23 11:05 id_dsa_2048_a.pub
-rw-r--r-- 1 solr clouduser 86744700 May 11 01:02 apache-solr-3.6.0.tgz
-rw-r--r-- 1 solr clouduser  6697806 May 21 23:31 apache-tomcat-6.0.35.tar.gz

3. untar the tomcat and solr and rename tomcat
[solr@vm-c179-e1f7 ~]$tar -xvf apache-solr-3.6.0.tgz
[solr@vm-c179-e1f7 ~]$tar -xvf apache-tomcat-6.0.35.tar.gz
[solr@vm-c179-e1f7 ~]$mv apache-tomcat-6.0.35 tomcat

~/tomcat -- this is $CATALINA_HOME

4 create solr related dirs
$cd ~
$mkdir -p ~/sponge/solr    -- this is $SOLR_HOME
$mkdir -p ~/sponge/solrData -- this is for solr index data

5 copy the Solr example/solr to ~/sponge/solr
[solr@vm-c179-e1f7 example]$ pwd
/home/solr/apache-solr-3.6.0/example
[solr@vm-c179-e1f7 example]$ cp -r ./solr ~/sponge/


6 change the index data dir for solr, the file is $SOLR_HOME/conf/solrconfig.xml
  <dataDir>${solr.data.dir:/home/solr/sponge/solrData}</dataDir>
 
7 copy the solr war to the solr home
[solr@vm-c179-e1f7 dist]$ pwd
/home/solr/apache-solr-3.6.0/dist
[solr@vm-c179-e1f7 dist]$ cp ./apache-solr-3.6.0.war ~/sponge/solr/solr.war

8 Create a Tomcat Context fragment to point docBase to the $SOLR_HOME/solr.war file and solr/home to $SOLR_HOME:
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/home/solr/sponge/solr/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/home/solr/sponge/solr" override="true"/>
</Context>
place the file in $CATALINA_HOME/conf/Catalina/localhost/solr.xml

9 URI Charset Config $CATALINA_HOME/conf/server.xml
<Server ...>
<Service ...>
   <Connector ... URIEncoding="UTF-8"/>
   ...
</Service>
</Server>

10 start tomcat server
$cd $CATALINA_HOME/bin
$export JAVA_OPTS="$JAVA_OPTS -Xms512M -Xmx1024M -Dfile.encoding=UTF8"
$./startup.sh

11 To use the indexing examples in the Solr Tutorial, use the -Durl parameter, e.g.
$cd ~/apache-solr-3.6.0/example/exampledocs
$java -jar -Durl=http://localhost:8080/solr/update post.jar solr.xml monitor.xml

12 check whether the index is built into solr.
http://SOLRMASTER:8080/solr/select/?q=id:SOLR1000

你可能感兴趣的:(tomcat)