Install solr 4.7.2 with tomcat 8

on with Leave a reply

Apache Solr recently released stable version 7.1, but I had a situation to configure the old Solr 4.7.2 with Tomcat 8 in Aws EC2 Linux AMI. So I thought to share steps install and configure. Hope someone will benefit

Install Tomcat 8 on EC2 LINUX AMI

First, let’s install the tomcat 8 in the ec2. Once you logged in the Ec2 instance run the following.

yum install tomcat8-webapps tomcat8-admin-webapps

Once installed, just verify the tomcat status

/etc/init.d/tomcat8 status

If all okay, then start the tomcat by ‘start’ command (sudo /etc/init.d/tomcat8 start). tomcat will run on 8080 port, so adjust your EC2 security group to open 8080 port for your IP address. Once that’s done, check your browser http://<yout_domain_or_ip>/:8080 to see the tomcat home page.

Install Solr 4.7.2 on EC2 LINUX AMI

Go to Apache Solr archive page to download the solr 4.7.2, then download the respective solr version solr-4.7.2.tgz.

wget http://archive.apache.org/dist/lucene/solr/4.7.2/solr-4.7.2.tgz

tar -vxf solr-4.7.2.tgz

sudo cp -R solr-4.7.2/ /opt/solr

sudo cp solr-4.7.2/example/webapps/solr.war /opt/solr/

sudo cp -r solr-4.7.2/example/lib/ext/* /usr/share/tomcat8/lib/

sudo mv /opt/solr/example /opt/solr/<your_namespance>

Once we completed the above steps. Let’s delete the unwanted examples

sudo rm -r /opt/solr/<your_namespance>/example-DIH/
sudo rm -r /opt/solr/<your_namespance>/exampledocs/
sudo rm -r /opt/solr/<your_namespance>/solr-webapp/

Steps to configuring the Solr in tomcat

As mentioned in the official Solr wiki doc, we need to configure the Solr for tomcat. so for that follow the below steps.

sudo vi /etc/tomcat8/Catalina/localhost/solr.xml

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

We should change the Solr persistence settings true otherwise, the changes made by solr web admin interface will be lost when we restart tomcat.

sudo vi /opt/solr/<your_namespance>/multicore/solr.xml

<solr persistent=”true”>

We need to adjust the folder permission for solr folder to restart the tomcat

sudo chown -R tomcat:tomcat /opt/solr/

sudo /etc/init.d/tomcat8 restart

Ahh! that’s all you should be able to see the Solr admin from the browser by accessing http://<your_ip>:8080/solr/

Let’s go little beyond the article context, I have existing solr index that’s copied from another server. So I am going to configure that index in the newly installed solr instance.

Let’s create new core for the index called newIndex. Once done create the following folders for core.

cd /opt/solr/<your_namespance>/multicore/
mkdir newIndex
cd newIndex
mkdir conf
mkdir data

Then we need to copy the solrconfig.xml and schema.xml from the old instance to ‘conf’ folder.

Once you copied conf, then copy index and tlog folder into the ‘data’ folder.

Go to core admin in the solr admin and create the new core called “newIndex”.  Hope your index is mapped to new core.

 

Hope it helped someone!

 

 

 

 

 

 

Posted in Apache solr and tagged , by .

About Gowri

I am professional web developer with 4+ years experience. PHP, jQuery, WordPress, Magento and Symfony2 are my key skills in web development. I am working with strong enthusiastic team with spirit. We provide all web related solution like HTML/CSS development, Web graphic design and Logo.

Leave a Reply

Your email address will not be published. Required fields are marked *