• How to set up Amazon EBS with a Wowza media server

    This article describes how to set up Amazon Elastic Block Store (EBS) with a Wowza media server on demand (VOD) application. Amazon EBS provides block-level storage volumes for use with Amazon Elastic Compute Cloud (Amazon EC2) instances.

    Amazon EBS volumes are network-attached and persist independently from the instance lifespan. EBS storage volumes can be attached to a running Amazon EC2 instance and exposed as a device within the instance. You can mount multiple EBS volumes on one EC2 instance; however, you can't mount one EBS volume on multiple EC2 instances. You can create a snapshot of a volume (which is stored on Amazon S3) from which you can create as many identical volumes as needed.

    Note: Amazon EC2 API Tools are required. You must have at least version 1.3-24159:
    C:\cd %EC2_HOME%\bin
    C:\ec2tools\bin> ec2ver
    1.3-24159 2008-05-05

    To set up Amazon EBS

    1. Get the latest pre-built Wowza media server for Amazon EC2 Amazon Machine Image (AMI).

    2. Start a new instance:
      C:\ec2tools\bin> ec2-run-instances -z us-east-1a --key mykeypair ami-78f71311
      RESERVATION     r-5400d63d      857774236421    default INSTANCE        i-111111      ami-78f71311                    pending wowza_keypair   0               m1.small        2008-09-04T21:31:25+0000        us-east-1a      aki-a71cf9ce    ari-a51cf9cc
      Note the Instance ID (i-111111).

    3. Check to see if the new instance is running:
      C:\ec2tools\bin> ec2-describe-instances i-111111
      RESERVATION     r-5400d63d      857774236421    default INSTANCE        i-111111      ami-78f71311    ec2-75-101-203-182.compute-1.amazonaws.com      domU-12-31-39-00-88-C3.compute-1.internal       running wowza_keypair   0       8ED157F9        m1.small        2008-09-04T21:31:25+0000
      Note the external DNS (ec2-75-101-203-182.compute-1.amazonaws.com).

    4. Create a new EBS volume:
      C:\ec2tools\bin> ec2-create-volume -z us-east-1a -s 10
      VOLUME  vol-VOLAAA    10              us-east-1a      creating        2008-09-
      Note the new volume ID (vol-VOLAAA).

    5. Check the new volume:
      C:\ec2tools\bin> ec2-describe-volumes vol-VOLAAA
      VOLUME  vol-VOLAAA    10              us-east-1a      available       2008-09-
    6. Attach the new volume to the new instance on device /dev/sdh:
      C:\ec2tools\bin> ec2-attach-volume -d /dev/sdh -i i-111111 vol-VOLAAA
      The new EBS volume is prepared.

    7. Now open a secure Telnet (SSH) connection to the instance to format and mount the new EBS volume.

      The xfs file system is recommend. You might have to install:
      [root@~]# yum install xfsprogs
      Installed: xfsprogs.i386 0:2.9.4-4.fc8
    8. Format and mount the new volume:
      [root@~]#  mkfs.xfs /dev/sdh
      [root@~]#  echo "/dev/sdh /wmscontent xfs noatime 0 0" >> /etc/fstab
      [root@~]#  mkdir /wmscontent
      [root@~]#  mount /wmscontent
    9. The new EBS volume is ready to use. Copy your content to it via FTP, load from Amazon S3 (S3Sync), or copy from the instance storage.

    10. Now open the [install-dir]/conf/yourApp/Application.xml file in a text editor and update the StorageDir property with the location of the new EBS volume:
    11. Restart the Wowza media server. Your app should be able to play videos from the new volume.

    When your EBS volume is full, you can make a snapshot of it and save it on Amazon S3. The snapshot can also be used to create identical new volumes.

    To create a EBS volume snapshot

    1. Using Amazon EC2 tools, create a snapshot of the EBS volume:
      C:\ec2tools\bin> ec2-create-snapshot vol-VOLAAA
      SNAPSHOT        snap-111111   vol-VOLAAA    pending 2008-09-05T11:42:06+0000
      Note the new snapshot ID (snap-111111).

    2. Check progress of the snapshot creation:
      C:\ec2tools\bin> ec2-describe-snapshots snap-111111
      SNAPSHOT        snap-111111   vol-VOLAAA    completed       2008-09-05T11:42:06+0000        100%

    The snapshot is saved on Amazon S3 and can be used to create new volumes to be mounted on other EC2 instances.

    You can use the above snapshot to create a new EBS volume that's already formatted and loaded with content.

    To create a new EBS volume from a snapshot

    1. Create another EC2 instance:
      C:\ec2tools\bin> ec2-run-instances -z us-east-1a --key mykeypair ami-78f71311
      Note the instance ID (i-IIII2222).

    2. Create another EBS volume using the above snapshot (snapshot ID=snap-111111):
      C:\ec2tools\bin> ec2-create-volume -z us-east-1a --snapshot snap-111111 vol-VOLBBBB
    3. Attach the new EBS volume to the new EC2 instance:
      C:\ec2tools\bin> ec2-attach-volume -d /dev/sdh -i i-IIII2222 vol-VOLBBBB
    4. Mount the new volume on the new instance. This is the same as above except that new volume is already formatted and has the content saved from the first volume that you snap-shotted.
      [root@~]#  echo "/dev/sdh /wmscontent xfs noatime 0 0" >> /etc/fstab
      [root@~]#  mkdir /wmscontent
      [root@~]#  mount /wmscontent
    5. Clean up.

      Unmount the EBS volume:
      [root@~]#  umount /wmscontent
      Using EC2Tools:
      C:\ec2tools\bin> ec2-detach-volume vol-VOLAAA
      C:\ec2tools\bin> ec2-delete-volume vol-VOLBBB
      C:\ec2tools\bin> ec2-delete-snapshot snap-111111
      C:\ec2tools\bin> ec2-terminate-instances i-111111
      C:\ec2tools\bin> ec2-terminate-instances i-IIII2222


    Originally Published: 10-01-2010.

    If you're having problems or want to discuss this article, post in our forum.