Tuesday 22 March 2011

Installing SOLR on EC2

Detailed below are my steps for installing Solr on EC2 with Ubuntu

Before we go any further , i would like you to note that I am making the assumption that 
you have already signed up for Amazon Web Services and you have also downloaded the command line tools.

If you are not there yet then you are going to have to follow the following resources 
before going any further.


* Install the command line tools https://help.ubuntu.com/community/EC2StartersGuide

Once you are ready please continue.

As of now Lucidworks do not provide an AMI for installing Solr outside of the US.
I am going to need to create my own AMI to solve this problem.
Fortunately this is a fairly simple task - especially if you use the nightly build.

You will need to start by creating a new instance.

Using the ec2 command line tool "ec2-run-instances" fire up a new EC2 Instance based off Ubuntu
The format is as follows

ec2-run-instances AMI-IMAGE-ID --instance-type INSTANCE-TYPE --region eu-west-1 -k AMAZON-KEY

For the purposes of the demo i am using a t1.micro just so we can get the hang of the process. In no way am I recommending that you run the whole SOLR stack on a t1.micro - that's crazy talk. Personally I wouldnt recommend anything lower than a m1.large for production unless you have a very specific use case. eg: very low traffic, very small document set. (Please evaluate sphinx to make sure SOLR is right for you - life might get a lot easier ) Anyhow..

to determine the AMI you wish to use you can query AWS using "ec2-describe-images"
eg


#> ec2-describe-images --region eu-west-1 --all | grep 'ubuntu'


There are plenty of AMI's to choose from so pipe the output into grep to help search for the one 
you are looking for. Or just choose the same one as me. Pick one with "ebs" store you will need this especially if you are testing out a micro instance. The AMI id's are listed in the second column.

Once you are ready to roll issue the following command to fire up the instance...





#> ec2-run-instances ami-e974439d --instance-type t1.micro --region eu-west-1 -k myAWSkey
When this has completed output on the command line will contain the id of the instance you have just fired up. You will now use this information to get the public DNS of the instance. (This is needed so you can log into the VM)

The standard ubuntu instances can be accessed through SSH. 

#> ssh -i /etc/aws-keys/YOUR-AWS-KEY.pem ubuntu@your.public.aws.dns.eu-west.compute.amazon.com
From here on in you are in a standard ubuntu install - so you can go ahead and configure it how you might need. However for our purposes we are just going to set up a search user and place the latest SOLR nightly there for further usage.

#> sudo useradd -d /home/search -m search
Now lets go to that newly created folder and install the nightly

#> sudo useradd -d /home/search -m search
#> cd /tmp
#> wget http://mirror.lividpenguin.com/pub/apache//lucene/solr/1.4.1/apache-solr-1.4.1.tgz
#> gunzip apache-solr-1.4.1.tgz
#> tar -xvf apache-solr-1.4.1.tar
Now lets move it to the search users folder

#> mv /tmp/apache-solr-1.4.1 /home/search

Before we can run Solr for the first time - you will need to install JAVA

#> sudo apt-get update
#> sudo apt-get install openjdk-6-jre-headless
If you have any problems with the install failing try again adding --fix-missing
Thats basically it for now you can  run solr by issuing the 
following command

#> sudo java -server -jar /home/search/apache-solr-1.4.1/example/start.jar
Of course, right now this isnt going to be of much use to you! 
But it at least gives you some steps to go through in order to get a Solr server up and running on EC2.

If you have been following my other posts , or maybe you have a Solr set-up from the nightlies running in a development sandbox. You could quite easily zip up the entire folder and install it on the instance by using "scp" to copy it up - and then follow the rest of the steps.

I hope this helps get you started.

I will probably be doing a follow-up post on this tommorow , so keep posted and let me know if you have any issues.

N.


5 comments:

  1. Thanks for the informative post

    ReplyDelete
  2. Hi geekpoet,

    Thanks for the Solr installation article on AWS. It was a nice read. I have shared my experience on deploying & configuring solrcloud (v4.x) on AWS in this article. I thought it will be useful for the readers of your blog post.

    http://harish11g.blogspot.in/2013/03/Apache-Solr-cloud-on-Amazon-EC2-AWS-VPC-implementation-deployment.html

    http://harish11g.blogspot.in/2013/03/Configuring-installing-Apache-Solrcloud-solr4.x-on-Amazon-VPC-EC2-AWS.html

    Thanks
    Harish Ganesan

    ReplyDelete
  3. It’s interesting to read content. I appreciate your blog AWS online Training

    ReplyDelete