How to install Solr on Ubuntu with MySQL Data Import?
How to install Solr on Ubuntu with MySQL Data Import?
Apache Solr is an open source enterprise Search platform built in Java. Solr is written in Java and runs as a standalone full-text search server within a Servlet container such as Tomcat. Solr uses the Lucene Java search library at its core for full-text indexing and searching. This article lists all the steps that you need to perform to install the Solr with Tomcat.
Install JDK in your system. ( You can skip this step if already have JDK in your system)
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
Install Tomcat.
sudo apt-get install tomcat6 tomcat6-admin
http://<IP_ADDRESS>:8080
http://localhost:8080
vim /etc/default/tomcat6
JAVA_HOME=/usr/lib/jvm/java-7-oracle/
and restart tomcat server using: /etc/init.d/tomcat6 restart and check again if it is installed or not.
Install Apache Solr with tomcat
wget http://apache.techartifact.com/mirror/lucene/solr/3.6.2/apache-solr-3.6.2.tgz
tar xvfz apache-solr-3.6.2.tgz cd apache-solr-3.6.2
cp dist/apache-solr-3.6.2.war /var/lib/tomcat6/webapps/solr.war cp -fr example/solr /var/lib/tomcat6/
chown -R tomcat6:tomcat6 /var/lib/tomcat6/solr
/etc/init.d/tomcat6 restart
http://localhost:8080/solr/admin/
http://<IP_ADDRESS>/solr/admin/
Edit solrconfig.xml file
cd /var/lib/tomcat6/solr vim conf/solrconfig.xml
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>
Create data-config.xml file
<dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1/YOUR_DB_NAME" user="root" password="YOUR_DB_PASSWORD"/> <document> <entity name="id" query="select * from students" > <field column="id" name="id" /> <field column="fullname" name="fullname" /> <field column="first_name" name="first_name" /> <field column="last_name" name="last_name" /> </entity> </document> </dataConfig>
Edit schema.xml file
<field name="id" type="text_general" indexed="true" stored="true"/> <field name="fullname" type="text_general" indexed="true" stored="true"/> <field name="first_name" type="text_general" indexed="true" stored="true"/> <field name="last_name" type="text_general" indexed="true" stored="true"/> <dynamicField name="*" type="ignored" />
Copy Mysql Jdbc Driver into lib/ directory
Download Mysql Jdbc Driver from : http://dev.mysql.com/downloads/connector/j/5.0.html and after extracting copy .jar file in /var/lib/tomcat6/solr/lib if lib directory is not present just create it inside solr/.
/etc/init.d/tomcat6 restart
Import database into Solr
http://localhost:8080/solr/dataimport?command=reload-config
http://localhost:8080/solr/dataimport?command=full-import
http://localhost:8080/solr/admin/
http://<IP_ADDRESS>/solr/admin/
tail -n 500 /var/lib/tomcat/logs/catalina.TODAY'S_DATE.log
If that doesn’t help, please drop us a line here and we can help you out.