Installing Lucene-solr with tomcat on ubuntu
This article explains steps to install Solr -Lucene search engine under Tomcat on ubuntu.Also important checks to avoid spending a lot of time in debugging are mentioned where-ever needed.
1) JAVA
First make sure you have latest java SDK installed.
Using – dpkg –get-selections | grep sun-java
This may give you following result if java is already installed
sun-java6-bin install
sun-java6-jdk install
sun-java6-jre install
If not, Install it using – apt-get install sun-java6-jdk
Make sure:- java was installed properly. check version of java installed with command – java version Or java showversion
Add below line in your “.bashrc” to set JAVA_HOME variable tomcat needs it.
export JAVA_HOME=/usr/lib/jvm/java-6-sun
2) TOMCAT
Install Tomcat 6 with-
apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples
Also install MYSQL java driver (if you need connecting to RDBMS MYSQL) with –
apt-get install libmysql-java
Once tomcat is installed make sure its installed properly by doing – curl http://localhost:8080
In above command use the port number configured for tomcat connector listens for HTML1.1. Check for it in”server.xml” under “/usr/lib/tomcat6/conf”
curl shall fetch html page showing “It works” heading and some instructions.
3) SOLR
If everything is good till now, its time to install Solr.
a) Download solr with-
wget -c http://apache.tradebit.com/pub/lucene/solr/1.4.1/apache-solr-1.4.1.zip
uncompress it with – unzip apache-solr-1.4.1.zip
b) Now copy the .war file from solr folder to tomcat webapps folder.
cp ~/apache-solr-1.4.1/dist/apache-solr-1.4.1.war /var/lib/tomcat6/webapps/solr.war
c) Also copy solr files as below-
cp -R ~/apache-solr-1.4.1/example/solr/ /var/lib/tomcat6/solr/
This shall copy “bin” and “conf” folder and readme.txt to “/var/lib/tomcat6/solr/”
“conf” folder shall have following files –
- dataimport.properties -(make sure this file has write permissions for tomcat)
- elevate.xml
- mapping-ISOLatin1Accent.txt
- protwords.txt
- schema.xml
- scripts.conf
- solrconfig.xm
- spellings.tx
- stopwords.tx
- synonyms.tx
- xslt (folder)
- my-data-config.xml (data config XML for your solr instance.you will need to edit this file so you can import mysql data in to solr)
d) Create the “solr.xml” file under “/var/lib/tomcat6/conf/Catalina/localhost/” with –
vi /etc/tomcat6/Catalina/localhost/solr.xml
Note:- XML file name under “/var/lib/tomcat6/conf/Catalina/localhost/” will be the path to access your solr instance like – http://localhost:8080/solr/
Add below contents in “solr.xml”
<Context docBase=”/var/lib/tomcat6/webapps/solr.war” debug=”0″ privileged=”true” allowLinking=”true” crossContext=”true”>
<Environment name=”solr/home” type=”java.lang.String” value=”/var/lib/tomcat6/solr” override=”true” />
</Context>
In above code set value of solr home to where you copied the Solr files in step (c)
Change directory to “/var/lib/tomcat6/solr/” and create data folder with “mkdir data”
Make sure the tomcat has write permissions to “data” folder.
This completes solr installation .make sure it works by browing here “http://localhost:8080/solr”.
This shall give you html page with meassge “Welcome to Solr” with link to solr admin page.
e) Make sure contents in solrconfig.xml in “/var/lib/tomcat6/solr/conf” is correct and what you want for your solr instance .Check that requestHandler with dataimport handler is defined this is important to import data from mysql.
f) Also make sure that “/var/lib/tomcat6/solr/bin” contains MySQL java connector jar, Else while dataimport it may throw exception that JDBC driver not found.
g) If you want another instance of Solrr for development purpose –
-Copy “solr.xml” to “solrdev.xml” in “/etc/tomcat6/Catalina/localhost/”.
-Also duplicate “solr” folder to “solrdev” in “/var/lib/tomcat6/”.
-Edit “solrdev.xml” to set solr home to “/var/lib/tomcat6/solrdev”.
-Edit “solrdev.xml” from “/var/lib/tomcat6/solrdev/conf” to use respecive “my-data-config.xml”
This instance can be accessed with “http://localhost:8080/solrdev”
Final step, restart Tomcat and check it here “http://localhost:8080/solr/”
use command “/etc/init.d/tomcat6 restart”
Here after refer to following links to successfully import data from MYSQL
http://wiki.apache.org/solr/DIHQuickStart
http://wiki.apache.org/solr/DataImportHandler
http://wiki.apache.org/solr/SearchHandler
http://wiki.apache.org/solr/SolrRequestHandler
For quick review https://docs.google.com/View?id=ddwrxhb8_86dtz2h9dc&amp;pli=1?
Quite a beautiful website. I built mine and i was looking for some ideas and your website gave me some. May i ask you whether you developed the website by youself?
Cheers
Yes we did it inhouse.
Yes, Site is developed inhouse.
Thanks for some quality points there. I am kind of new to online , so I printed this off to put in my file, any better way to go about keeping track of it then printing?
Subscribe to our RSS feed ,That’s best way to keep yourself updated with new articles or to refer old articles.
How can I add your rss to my miracle fruit website?
Great post, interesting reading.
Thanks. Miracle fruit
hello All
how could i configure hdfs files or hadoop file stor to solr in tomcat
and i have to index the hdfs files and search using solr.
any help …
tiru
This is often a amazing blog, would you be interested in working on an interview concerning just how you made it? If so e-mail myself!
Do you mind if I quote a couple of your articles as long as I
provide credit and sources back to your webpage? My blog site is in the very same
niche as yours and my visitors would really benefit from a lot of the
information you present here. Please let me know if this ok with you.
Many thanks!
Sure
Hi,
Could you tell me how to execute the following order, please?
Thanks
Edit “solrdev.xml” from “/var/lib/tomcat6/solrdev/conf” to use respecive “my-data-config.xml”
This instance can be accessed with “http://localhost:8080/solrdev”
Hi Irene,
Section (g) is for duplicating the instance and is steps are written orderly.
For configuring instance follow Step 3 – sections (a- h) in order.
Thanks.