Solr can be run on Amazon's EC2.
:TODO: This page is a work in progress that will reflect how to run Solr 4.3 on AWS EC2 with screenshots when I am done. -MDB
Create an Instance
Follow the Getting Started with Amazon EC2 Linux Instances guide to become familiar with EC2 instances, security groups, instance keys, and EBS volumes.
Create a security group for Solr servers. It should allow access to ports 22 and 8983 for the IP you're working from, with routing prefix /32 (e.g., 188.8.131.52/32). This will limit access to your current machine. If you want wider access to the instance available to collaborate with others, you can specify that, but make sure you only allow as much access as needed. A Solr instance should not be exposed to general Internet traffic. If you need help figuring out what your IP is, you can always use whatismyip.com. Please note that production security on AWS is a wide ranging topic and is beyond the scope of this tutorial.
- Create instance
- Click on Launch instance in the EC2 section of the AWS console.
- b. Choose "Classic Wizard".
- c. For this demo, we're going to use the 64-bit version of Ubuntu 12.04.2.
- d. We're using an m1.large instance for this example. For production use, you're likely going to have to go through an exercise to find the right instance size that matches your content and usage patterns. An m1.large is definitely big enough for this demo, however.
- e. You don't need to make any changes on the Advanced Options screen.
- f. We are going to need to make some changes to the storage configuration, however. Click edit.
- g. The root volume is fine for this exercises, but we're going to create a separate EBS volume to store our Solr install and data. By storing this on a seperate volume, we can easily recover from a failed instance or decide to switch to a larger or smaller one by spinning down the instance and attaching our separate EBS volume to a new one.
- h. We're going to add a new volume here. No need to tweak iops or other settings other than the size.
- OK, we have the disks we want. Click Continue.
- j. Give your instance a name. The one here is just an example. The name will make it easy to find in the AWS Console, but doesn't affect much else.
- k. We're going to need a keypair to log in to our instance and configure settings. If you have one set up in your account already, you can elect to use that, but here we're creating a new one for the instance. Make sure you download it and save it in a safe place. If you're using Mac OS X or Linux or Unix, a good place to keep it is in the .ssh folder in your home directory. Create it if it doesn't exist already.
- l. Choose the security group we created in step #3.
- k. OK, looking good. Click Launch!
Log In to Instance
OK, your instance should be coming up now. You can track the progress in the EC2 Console. When the state becomes Running, grab your server key and log in! First, grab the hostname from the detail view of the host. It will look something like ec2-50-18-121-236.compute-1.amazonaws.com. With command line ssh, it looks something like:
ssh -i ~/.ssh/[KEYNAME.pem] ubuntu@[HOSTNAME]
So, for example,
ssh -i ~/.ssh/solr.pem firstname.lastname@example.org
(This assumes you stored the key in your .ssh folder as previously mentioned.)
Windows users who don't have command line SSH set up can download PuTTY and import the key by following http://blog.linuxacademy.com/linux/connect-to-amazon-ec2-using-putty-private-key-on-windows/
If everything goes well, you should be greeted with a message welcoming you to Ubuntu and displaying some OS statistics. You're in!
We attached an EBS volume to the host when we created it, but we didn't specify an image to use, so it came blank. That's easy to fix:
sudo apt-get -y install xfsprogs sudo mkfs.xfs /dev/xvdc sudo mkdir /ebs sudo mount /dev/xvdc /ebs
Et voila, our ebs volume is formatted with XFS and is now available at the path /ebs. Notice that you don't need a password to run sudo.
We're going to install Solr right on the volume alongside the index. This will make it easy to migrate instance sizes by simply detaching the ebs volume and attaching to a new instance, or by taking a snapshot and restoring it elsewhere.
cd /ebs curl -O http://apache.mirrors.lucidnetworks.net/lucene/solr/4.3.0/solr-4.3.0.tgz tar xf solr-4.3.0.tgz
- Launch Jetty
- Index some stuff
10. Dials to tweak