Loading

Thursday, August 11, 2011

Copying an EBS-backed Windows 2008 AMI Between AWS Regions - How-to

Unfortunately Amazon doesn't have an easy or native way to copy or move or launch an AWS AMI from one region to another.  There are a number of posts on the Internet about how to do this with a Linux AMI, but I haven't been able to find clear instructions on how to do this for a Windows AMI.  So, here we go...

The basic steps involve starting a temporary Windows instance in each of the two regions, say us-east-1 and us-west-1; attaching the EBS boot volume to the server in the "source" region; making an image or zip file of the volume; copying the volume to the temporary server in the "destination" region; extracting the file to a new volume; finally, attaching that volume to a server.

Notes:
  • This will take a while (several hours), particularly if your AMI is large.
  • Clean up the boot volume of the image you want to copy to another region by deleting any unnecessary files, such as temporary files, etc. as it will reduce the overall time this process takes.
  1. Launch a temporary Windows instance in the “source” region and another one in the “target” region. (You may not have to launch temporary servers if you have one available in each that can handle the load of compressing a large volume which can be quite CPU intensive.  Additionally you need to have enough available disk space for the compressed volume to be stored temporarily.)
  2. Determine the snapshot for the boot volume you want to migrate (you must own the AMI) using the command ec2-describe-images.


  3. Create a new EBS volume from that snapshot in the same zone as your origin server.  This can be done many ways, but here's how to do it from the command line using the AWS tools:
    ec2-create-volume --snapshot <snap ID> -z us-east-1c
  4. Attach that volume to your temporary server instance as, say, “xvdg”:
    ec2-attach-volume <volumeID> –i <instanceId> –d xvdg
     NOTE: You will be able to browse the contents of the volume in Windows Explorer.

  5. Connect to your temporary source server with RDP.
  6. Zip the entire contents of the newly attached volume.  NOTE: I used 7zip and sent the zipped file to another volume on the temporary source server in 1GB chunks (this makes it easier and quicker to transfer to the destination server; in particular you can begin copying the chunks soon as each is finished rather than waiting for one large file.)
  7. Copy that zipped file (or files) to your instance in the “target” region.  This could be done by a variety of methods.  I chose to copy my 1GB chunks to an Amazon S3 bucket, then I could easily download those onto the destination server.

    In the target region:

  8. Create an EBS volume of appropriate size (30GB for Windows 2008 by default) and attach it to your temporary destination server.
  9. Unzip the file to the new volume.  Again, I used 7zip.
  10. Detach the volume.

    Now, for the Windows specific stuff….

  11. Launch a basic Windows 2008 instance of the right architecture (32 or 64 bit).
  12. Soon as the instance is “running” (see Pinging Amazon EC2 Instances to determine exactly when your instance is available) stop it and wait for its state to become “stopped”.
  13. Once it stops, detach its “/dev/sda1” volume and delete it using ec2 commands:
    ec2-detach-volume <the_volumeID_of_sda1> –i <new_windows_instance>
    ec2-delete-volume <the_volumeID_of_sda1>

  14. Now attach the new volume (from steps 8-10) to the stopped Windows instance as ‘/dev/sda1’:
    ec2-attach-volume <vol_id> –i <windows_instance_id> –d /dev/sda1
  15. Start the instance to make sure it boots, and connect to it with RDP.
  16. When you’re satisfied that it boots and is setup the way you desire, stop the instance using ec2stop -i <instanceID>.
  17. Finally, create an AMI from that server by running ec2-create-image -i <instanceID>.
That's it.  Now you have an AMI in a different AWS zone that is a copy of one from your initial zone.

How Can I Improve My Web Site's Search Results Ranking?

Tonight my friend contacted me and asked how she could get her store's new website to show up in search results.  While I don't claim to be an expert I do have a little experience with web sites, ecommerce, blogging and SEO (search engine optimization).  Here's a list of what I told her just shooting from the hip.

I told her it's definitely a multi-faceted approach.  First, her site looks good, is easy to navigate and has relevant information.  Without a decent place to start none of the rest of this will matter.
  1. Start with a good site with good, relevant content.
  2. Be patient. It takes time to rise to the top, or even to rise at all.
  3. Get visitors. The more traffic your site gets naturally (sometimes called type-in traffic) the better it will rank in search results. Give the URL to all your customers. Print it on their receipt, on the merchandise bags, put a flyer in their bag. Put your sites address up in your stores. Outside the stores. Basically anywhere you can. Get your existing customers to go to the site.
  4. Add content (merchandise and info) to your site often as possible.  Keep the site fresh. Use the island names (or your location) in product descriptions if/when possible. Basically you want the search words people would use to find what you offer throughout your site as much as possible.
  5. Have your own blog and use it to make announcements about new products, etc.  This helps fulfill the previous suggestion. And post to it regularly. Again using key words.  And make sure it links back to your store.
  6. Inbound links are invaluable, particularly from higher traffic sites. Post the link on facebook, twitter or anywhere you can. Try to get written up and linked in your local paper, citysearch, kudzu, places like that. Trade links with other sites where it makes sense, etc. Inbound links are the holy grail of high-ranking search results, and ultimately more site traffic.
  7. Work your networks, get people going there, linking to it etc.
  8. Use site analytics.  Make sure to enable some kind of site analytics (either from your hosting provider or Google Analytics or other) so you can monitor activity to your site over time; and track key words people used to find your site; and where they came from (search engines, inbound links, etc.).
  9. While it's harder and harder these days to get good domain names it really helps if the site name is something that makes sense, is easy to remember.  It is also really important for it to match the name of your business.
Again, be patient.  It takes time to build traffic, especially search traffic and to get ranked higher in search results. While no one knows exactly the algorithms that Google and other search engines use it is no doubt a combination of the things listed above (and certainly more).  Build your traffic organically using the customers already interacting with you.  Make sure your site is easy to navigate, looks good and has lots of content, particularly the key words you believe people might use to find products or services you offer.

If you're ever in the Charleston, SC area go to Islands Mercantile on both Seabrook and Kiawah islands for some great T-shirts, hats and other souvenirs.