Tuesday, November 26, 2013

One of the differences between Amazon EC2 server instances and normal servers is that the server’s local disk storage state (i.e. changes to data) on EC2 instances does not persist over instance shutdowns and powering on. This was mentioned in my earlier post about hosting my Web site on Amazon EC2 and S3,
Therefore, it is a good idea to store your home directory, Web document root and databases on an Amazon EBS volume, where the data does persist like in a normal networked hard drive. Another benefit of using an Amazon EBS volume as a data disk is that it separates your operating system image from your data. This way, when you upgrade from a server instance with less computing power to one with more computing power, you can reattach your data drive to it for use there.
You can create an EBS volume and attach it to your EC2 server instance using a procedure similar to the following.
First, create an EBS volume.
You can use Elasticfox Firefox Extension for Amazon EC2 to:
  • create a EBS volume
  • attach it to your EC2 instance
  • alias it to a device, In this example, we use /dev/sdh
Then attach the “disk” to your EC2 instance and move your folders to it using a procedure similar to the following commands issued from a bash shell.
# Initialize (format) the EBS drive to prepare it for use
# Note: replace /dev/sdh below with the device you used for this EBS drive
mkfs.ext3 /dev/sdh
#
# Create the mount point where the EBS drive will be mounted
sudo mkdir /mnt/rj-09031301
# Side note: I use a naming convention of rj-YYMMDDNN to assign unique names
# to my disk drives, where YYMMDD is the date the drive was put into service
# and NN is the serial number of the disk created that day.
#
# Mount the EBS drive
sudo mount -t ext3 /dev/sdh /mnt/rj-09031301
#
# Temporarily stop the Apache Web server
sudo /etc/init.d/apache2 stop

#
# Move the current /home folder to a temporary backup
# This temporary backup folder can be deleted later
sudo mv /home /home.backup

#
# Symbolic link the home folder on the EBS disk as the /home folder
sudo ln -s /mnt/rj-09031301/home /home
#
# Start the Apache Web server
sudo /etc/init.d/apache2 start
Limitations:
One current limitation of EBS volumes is that a particular EBS disk can only be attached to one server instance at a given time. Hopefully, in a near future version upgrade of EC2 and EBS, Amazon will enable an EBS volume to be attached to multiple concurrent server instances. That will enable EBS to be used similar to how SAN or NAS storage is used in a traditional (pre cloud computing era) server environment. That will enable scaling Web (and other) applications without having to copy and synchronize data across multiple EBS instances. Until Amazon adds that feature, you will need to maintain one EBS disk per server and keep their data in sync. One method of making the initial clones is to use the feature that creates a snapshot of an EBS volume onto S3.

19 comments:

  1. An EBS volume should never be allowed to be concurrently connected to multiple servers because it's "Block" storage. If you want a volume connected to multiple servers, use an NFS mount served up from another EC2.

    ReplyDelete
  2. Hey really nice post keep share with us regarding AWS updates for more information get touch with these peoples will clear all doubts AWS Online Training Hyderabad

    ReplyDelete

  3. Great Post,really it was very helpful for us.
    Thanks a lot for sharing!
    I found this blog to be very useful!!
    AWS Cloud training in Bangalore

    ReplyDelete

  4. Nice and good article. It is very useful for me to learn and understand easily.
    AWS Training in Delhi
    AWS Training Course in Delhi

    ReplyDelete
  5. Really an awesome blog for the freshers. Thanks for posting the information.
    AWS Training in Delhi
    AWS Course in Delhi

    ReplyDelete
  6. Looking forward to reading more. Great article post. Thanks Again. Fantastic.

    ReplyDelete