This is a quick step by step or how to on running multiple instances of SOLR on Apache Tomcat. We will also setup basic password protection so that SOLR can have some protection. Before installing make sure selinux and you firewall is configured properly or disabled.
# = command
1. Install Tomcat
See what is available
# yum search tomcat
In my case tomcat5 is available, i will also install tomcat5-webapps for the fancy welcome page and admin interface.
# yum install tomcat5 tomcat5-webapps
Yum will go out and find all the dependencies and ask your permission to install. If you are ok installing the dependencies then type y and allow yum to continue with the installation.
Note: for Tomcat 5.5 xalan.jar is required (i have seen it installed automatically by yum on one occasion)
# yum search xalan
i get xalan-j2 so…
# yum install xalan-j2
then we need to create a sym link to tomcat
# ln -s /usr/share/java/xalan-j2.jar /var/lib/tomcat5/common/lib/xalan-j2.jar
NOTE: I just had trouble with these steps on Centos 5.6 x86_64, installing java-1.6.0-openjdk-devel and restarting tomcat fixed this.
Error:
# cat cataline.out…
SEVERE: Exception starting filter SolrRequestFilter
java.lang.NoClassDefFoundError: java.util.concurrent.atomic.AtomicBoolean
Solution:
# yum install java-1.6.0-openjdk-devel
start tomcat
# /etc/init.d/tomcat5 start
Verify that tomcat is running and able to accept connections by using your web browser to open “http://<your host>:<tomcat port>/”
tomcat port is generally 8080
2. Get SOLR. start here http://www.apache.org/dyn/closer.cgi/lucene/solr/. I like to install solr in /opt.
# mkdir /opt/solr
# mkdir /opt/solr/bin
# mkdir /opt/solr/download
# cd /opt/solr/download
# wget http://www.motorlogy.com/apachemirror//lucene/solr/3.1.0/apache-solr-3.1.0.tgz
# tar xvf apache-solr-3.1.0.tgz
# ln -s /opt/solr/download/apache-solr-3.1.0/example/webapps/solr.war /opt/solr/bin/solr-3.1.0.war
The strategy above allows us to run different versions of SOLR.
3. Create SOLR instance directory
# mkdir /opt/solr/test
# cd /opt/solr/test
# cp -r /opt/solr/download/apache-solr-3.1.0/example/solr/* .
Set permissions on the solr directory so that it can create and write it’s data dir.
# chmod 775 .
# chgrp tomcat .
4. Configure Tomcat
create the file with the contents below.
# vi /opt/solr/test/test.xml
1 2 3 | <Context docBase="/opt/solr/bin/solr-3.1.0.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="/opt/solr/test" override="true" /> </Context> |
link the tomcat config file to the correct directory so that tomcat will pick it up.
# ln -s /opt/solr/test/test.xml /etc/tomcat5/Catalina/localhost/test.xml
restart tomcat
# /etc/init.d/tomcat5 restart
You should now be able to access SOLR through your web browser “http://<your host>:<tomcat port>/test/”. If you can’t check the tomcat logs, mine is at /var/log/tomcat5/catalina.out
5. Configure basic authentication to protect SOLR
Add lines to tomcat-users.xml between
vi /etc/tomcat5/tomcat-users.xml
1 2 | <role rolename="test_solr"/> <user username="testsolr" password="password" roles="test_solr"/> |
Add to web.xml between <web-app> and </web-app>
vi /var/lib/tomcat5/webapps/test/WEB-INF/web.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <security-constraint> <web-resource-collection> <web-resource-name>Solr authenticated application</web-resource-name> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>test_solr</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>Basic Authentication</realm-name> </login-config> <security-role> <description>TEST SOLR</description> <role-name>test_solr</role-name> </security-role> |
Comments (0)