Resourceful EBS Volume Management on Eucalyptus

Follow

Eucalyptus Version:  All

Resourceful EBS Volume Management on Eucalyptus

As mentioned in Amazon Elastic Cloud Compute documentation [1], software RAID can be used to get better I/O performance regarding EBS volume usage. As a cloud administrator, limits can be set for EBS volumes.  The following Eucalyptus cloud properties can be configured per cluster (i.e. availability zone):

  • storage.maxtotalvolumesizeingb - this is the size calculated from adding all the volumes within an account
  • storage.maxvolumesizeingb - the maximum size of a volume created by a user of an account

These limitations are helpful from a cloud administrator point of view, but from a cloud user's point of view, they can be seen as restrictive.  To help cloud user, there are techniques that can be utilized to help manage EBS volumes per instance.  The technique that will be discussed in this knowledge base is utilizing RAID and LVM to allow space to grow in a dynamic manner without interrupting an application's performance.  

EBS Volume Management Example

To leverage the use of RAID and LVM, make sure a filesystem is used that allows online resizing.  This knowledge base will utilize the XFS filesystem.  Another filesystem that can be resized online is ext4 [2]. This example will also use the following:

To get started, make sure an instance has been launched, and xfsprogs, mdadm and lvm2 have been installed:

sudo apt-get install -y xfsprogs mdadm lvm2

After installing the software, create the number of volumes desired to be part of the RAID0 setup with euca-create-volume:

[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 5 -z LayinDaSmackDown 
VOLUME vol-F9943E5A 5 LayinDaSmackDown creating 2014-04-26T14:52:25.512Z
[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 5 -z LayinDaSmackDown 
VOLUME vol-E61A3ED8 5 LayinDaSmackDown creating 2014-04-26T14:52:28.206Z
[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 5 -z LayinDaSmackDown 
VOLUME vol-59D6412D 5 LayinDaSmackDown creating 2014-04-26T14:52:31.275Z
[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 5 -z LayinDaSmackDown 
VOLUME vol-34934279 5 LayinDaSmackDown creating 2014-04-26T15:51:01.075Z

Once the volumes are created, attach them to the instance using euca-attach-volume:

[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sdd vol-F9943E5A 
ATTACHMENT vol-F9943E5A i-E8A84094 /dev/sdd attaching 2014-04-26T15:37:56.175Z
[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sde vol-59D6412D
ATTACHMENT vol-59D6412D i-E8A84094 /dev/sde attaching 2014-04-26T15:38:31.425Z
[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sdf vol-E61A3ED8
ATTACHMENT vol-E61A3ED8 i-E8A84094 /dev/sdf attaching 2014-04-26T15:38:45.837Z
[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sdg vol-34934279
ATTACHMENT vol-34934279 i-E8A84094 /dev/sdg attaching 2014-04-26T15:52:47.408Z

Next, SSH into the instance, confirm that the volumes are attached, and create the RAID0 device:

[hspencer@odc-d-06-07 ~]$ ssh -i account1-user01.priv ubuntu@euca-10-104-7-10.eucalyptus.euca-hasp.eucalyptus-systems.com
ubuntu@euca-172-17-112-244:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 2.2G 0 disk
└─vda1 253:1 0 2.2G 0 part /
vdb 253:16 0 12.8G 0 disk
vdc 253:32 0 5G 0 disk
vdd 253:48 0 5G 0 disk
vde 253:64 0 5G 0 disk
vdf 253:80 0 5G 0 disk
ubuntu@euca-172-17-112-244:~$ sudo mdadm --verbose --create /dev/md0 --level=0 --chunk=256 --raid-devices=4 /dev/vdc /dev/vdd /dev/vde /dev/vdf

Use blockdev to increase the readahead of /dev/md0 to help improve performance.

ubuntu@euca-172-17-112-244:~$ sudo blockdev --getra /dev/md0
2048
ubuntu@euca-172-17-112-244:~$ sudo blockdev --setra 131072 /dev/md0
ubuntu@euca-172-17-112-244:~$ sudo blockdev --getra /dev/md0
131072

Create the physical volume group using pvcreate:

ubuntu@euca-172-17-112-244:~$ sudo pvcreate /dev/md0
Physical volume "/dev/md0" successfully created

Create the volume group using vgcreate:

ubuntu@euca-172-17-112-244:~$ sudo vgcreate vg01 /dev/md0
Volume group "vg01" successfully created

Create logical volume using lvcreate:

ubuntu@euca-172-17-112-244:~$ sudo lvcreate --name lv_storage --extents 100%FREE vg01
Logical volume "lv_storage" created

Format the logical volume with the XFS filesystem:

ubuntu@euca-172-17-112-244:~$ sudo mkfs.xfs -f /dev/vg01/lv_storage

After its completed, create a directory, and mount the device:

ubuntu@euca-172-17-112-244:~$ sudo mkdir /storage
ubuntu@euca-172-17-112-244:~$ sudo mount -t xfs -o noatime,noexec,nodiratime /dev/vg01/lv_storage /storage

Once this is completed, an application (e.g. MySQL [3], MongoDB [4], PostgreSQL, [5], etc.) can begin to use the /storage directory.  

When the directory starts to reach capacity, just create new EBS volumes, attach to the instance, create a new RAID device, extend the volume group and the logical volume, and grow the XFS filesystem accordingly:

[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 2 -z LayinDaSmackDown
VOLUME vol-F8EC39EE 2 LayinDaSmackDown creating 2014-04-26T17:12:29.680Z
[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 2 -z LayinDaSmackDown 
VOLUME vol-7C7C3D46 2 LayinDaSmackDown creating 2014-04-26T17:12:32.169Z
[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 2 -z LayinDaSmackDown 
VOLUME vol-1081430E 2 LayinDaSmackDown creating 2014-04-26T17:12:34.199Z
[hspencer@odc-d-06-07 ~]$ euca-create-volume -s 2 -z LayinDaSmackDown 
VOLUME vol-A4103EB8 2 LayinDaSmackDown creating 2014-04-26T17:12:36.238Z
[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sdh vol-F8EC39EE 
ATTACHMENT vol-F8EC39EE i-E8A84094 /dev/sdh attaching 2014-04-26T17:35:17.485Z
[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sdi vol-7C7C3D46
ATTACHMENT vol-7C7C3D46 i-E8A84094 /dev/sdi attaching 2014-04-26T17:35:40.919Z
[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sdj vol-1081430E 
ATTACHMENT vol-1081430E i-E8A84094 /dev/sdj attaching 2014-04-26T17:36:01.724Z
[hspencer@odc-d-06-07 ~]$ euca-attach-volume -i i-E8A84094 -d /dev/sdk vol-A4103EB8
ATTACHMENT vol-A4103EB8 i-E8A84094 /dev/sdk attaching 2014-04-26T17:36:25.929Z
[hspencer@odc-d-06-07 ~]$ ssh -i account1-user01.priv ubuntu@euca-10-104-7-10.eucalyptus.euca-hasp.eucalyptus-systems.com
ubuntu@euca-172-17-112-244:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 2.2G 0 disk
└─vda1 253:1 0 2.2G 0 part /
vdb 253:16 0 12.8G 0 disk
....
vdg 253:96 0 2G 0 disk
vdh 253:112 0 2G 0 disk
vdi 253:128 0 2G 0 disk
vdj 253:144 0 2G 0 disk
ubuntu@euca-172-17-112-244:~$ sudo mdadm --verbose --create /dev/md1 --level=0 --chunk=256 --raid-devices=4 /dev/vdg /dev/vdh /dev/vdi /dev/vdj
ubuntu@euca-172-17-112-244:~$ sudo blockdev --getra /dev/md1
2048
ubuntu@euca-172-17-112-244:~$ sudo blockdev --setra 131072 /dev/md1
ubuntu@euca-172-17-112-244:~$ sudo blockdev --getra /dev/md1
131072
ubuntu@euca-172-17-112-244:~$ sudo vgextend vg01 /dev/md1
No physical volume label read from /dev/md1
Physical volume "/dev/md1" successfully created
Volume group "vg01" successfully extended
ubuntu@euca-172-17-112-244:~$ sudo lvextend -l +100%FREE /dev/vg01/lv_storage
Extending logical volume lv_storage to 13.98 GiB
Logical volume lv_storage successfully resized
ubuntu@euca-172-17-112-244:~$ sudo xfs_growfs /storage

Using this technique helps not only the cloud administrator, but also the cloud user, by dynamically controlling the growth of storage used by an instance without stopping the running application.

References

[1]   Amazon Elastic Compute Cloud - RAID Configuration
[2]   RedHat 6 Storage Administration - Resizing an ext4 File System
[3]   MySQL 5.7 Reference - Setting Up MySQL on an EC2 AMI
[4]   MongoDB - Amazon EC2
[5]   PostgreSQL 9.3 Server Administration

 

 

 

 

Have more questions? Submit a request

Comments

Powered by Zendesk