Using Amazon EBS elastic volumes with Oracle databases (part 2): databases using LVM
In part 1 of this blog series, we discuss the elastic volumes feature. We also discuss Oracle database storage layouts for simple databases that use a single Amazon EBS volume without LVM for database storage. In this post, part 2 of the series, we discuss the storage layout for Amazon EC2 for Oracle databases that use LVM for storage management. In addition, we demonstrate how you can scale the database storage without an impact on availability.
Storage operations for databases using LVM
In this section, we briefly discuss the storage layout for Amazon EC2 for Oracle databases that use LVM for storage management. Then we discuss how Oracle database storage modifications like increasing the storage provisioned or changing the IOPS provisioned were done before elastic volumes were introduced. We also cover the associated challenges. Finally, we demonstrate how to address some of these challenges with elastic volumes by using an example.
Storage layout for databases using LVM
For larger databases that require multiple EBS volumes for database storage, you can use an LVM to manage the storage. In this scenario, you create volume groups and add the EBS volumes to the volume groups. Then you create logical volumes from the volume groups and create your file systems on top of the logical volumes. The following diagram shows this database storage layout using LVM.
Oracle database storage operations without elastic volumes
To increase the storage or IOPS provisioned for systems using multiple EBS volumes and LVM for storage management, you create new EBS volumes. You then add them to volume groups using the following steps:
- Create a new EBS volume and attach it to the EC2 instance.
- Create a physical volume using the
- Add the new physical volume to the volume group using the
- Extend the logical volume using the
- Resize the file system.
Although this increases the total storage capacity and IOPS available due to the addition of the new EBS volume, the data is not evenly distributed across your EBS volumes. This unevenness can result in hot spots. You have to manually rebalance or redistribute your data (Oracle data files) across the EBS volumes.
Oracle database storage operations using elastic volumes
To modify an EBS volume, use the
modify-volume command from the AWS CLI or the Modify Volume option from the AWS Management Console. Specify the new volume size and IOPS. If you modify only the IOPS provisioned without changing the volume size, no changes are required at the operating system or LVM level. If you modify the EBS volume size, perform the following additional steps:
- Resize the physical volumes using the
- Resize the logical volumes using the
- Resize the file system.
When you modify the size or IOPS of an EBS volume, the data is automatically spread across multiple backend devices. This approach helps avoid hot spots and ensure that you get the IOPS provisioned.
Example: increasing the storage for a database that uses LVM
In this section, we demonstrate how to increase the storage provisioned for an Oracle database that uses LVM for storage management, without any downtime. For this demonstration, we use an Oracle 12c database running on Amazon Linux that uses LVM for storage management. Two EBS volumes, each with 100 GiB of storage, are presented as physical volumes to the LVM. From these volumes, a logical volume of 200 GiB is created for Oracle database storage. During this demonstration, we increase the storage provisioned to the database from 200 GiB to 400 GiB without downtime.
To demonstrate that the resize is performed without any database downtime, we created a database stored procedure called
evtestproc. This procedure inserts records into a table called
evtesttab at 10-second intervals. We run this procedure while we perform the resize operation. We can confirm that the resize was done without any database downtime by verifying that records were inserted into the
evtesttab table at 10-second intervals without any gap. For the definition of the
evtestproc stored procedure, see part 1 of this blog series.
Step 1: Verifying the current setup
From the AWS Management Console, verify the size of the EBS volumes. Currently the size is 100 GiB, as seen in the following screenshot.
Verify that the volumes are attached to the instance using the