AWS Database Blog
Using Amazon EBS elastic volumes with Oracle databases (part 2): databases using LVM
August, 2024: This post has been reviewed and updated for accuracy.
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
pvcreate
command. - Add the new physical volume to the volume group using the
vgextend
command. - Extend the logical volume using the
lvextend
command. - 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
pvresize
command. - Resize the logical volumes using the
lvresize
command. - 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 19c database running on Red Hat Enterprise Linux (RHEL) 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 lsblk -o +SERIAL
command, NVMe EBS volumes have the EBS volume ID set as the serial number in the device identification. Use the Identify the EBS device document for other operating systems.
To continue, install the lvm
package if it’s not already installed. Verify the installation using the following command.
If lvm
in not installed, install it using the yum
command as shown following.
Create the physical volumes using LVM.
Note: Be aware of some device name considerations: Depending on the block device driver of the kernel, your device might be attached with a different name than you specified. Amazon EBS volumes are exposed as NVMe block devices on instances built on the AWS Nitro System. The block device driver can assign NVMe device names in a different order than what you specified for the volumes in the block device mapping. Use the steps in How to mount Linux volume and keep mount point consistency for EBS persistence.
Then we create the volume group using LVM.
Create the logical volume using LVM.
Verify the configuration using the pvdisplay
, vgdisplay,
and lvdisplay
commands as shown.
For storing the data files, create a directory called customdf
as shown following.
Create a file system on the logical volume and mount it at /u01/app/oracle/oradata/cdb1/pdb1/customdf/
as shown following.
Note: Both Ext4 and XFS support inline resizing. For this example, we use Ext4, because it’s a simpler choice.
To test create a big file tablespace called EVTestTablespace
with a 180-GB data file called evtestdf.dbf
, using SQL*Plus as shown following.
You can verify the disk utilization at the OS level using the df
command as shown following.
Now, verify the size and data file location of the newly created tablespace as shown in the following screenshot.
Step 2: Setting up the stored procedure
To insert records into the evtesttab
table while we increase the storage provisioned to the database, start the evtestproc
stored procedure.
We query the table from SQL Workbench to verify that records are being inserted.
Step 3: Resizing the EBS volume
We now increase the size of the EBS volumes 100 GB to 200 GB using the AWS CLI.
After a short while, we check the status of the volume modification request using the AWS CLI. You can see that the volume has entered the optimizing state. The AWS Management Console shows the new size, as shown in the following screenshot.
Step 4: Resizing the physical volumes, logical volumes, and file system
To resize the physical volumes, use the pvresize
command.
Verify that the new size is reflected using the pvdisplay
command.
We now resize the logical volume using the lvresize
command. The –l +100%FREE
option of the lvresize
command allocates all the newly added space to the logical volume.
Verify that the new volume size now appears using the lvdisplay
command.
We finally resize the file system (ext4
) using the resize2fs
command.
Verify that the file system has been resized using the df
command.
Step 5: Increasing the database storage
We now increase the database storage available by resizing the big file tablespace to 360 GB, using SQL*Plus as shown following
SQL> ALTER TABLESPACE EVTestTableSpace RESIZE 360G;
Tablespace altered.
The database storage is now increased to 360 GB, as shown in the following screenshot.
Step 6 – Verify that there was no database downtime while the storage was resized
To verify that the PL/SQL procedure execution was uninterrupted, we query the evtesttab
table. This query also verifies that records were inserted at 10-second intervals without any gaps, as shown in the following screenshot.
Using this example, we demonstrate how to increase the storage allocated to an Oracle database that uses LVM for storage management, without any impact on database availability. You can also change the IOPS provisioned for the database or change the EBS volume type (for example, from io1 to gp2) using elastic volumes. You can do so without any impact on database availability or performance.
In the next post, we discuss the storage layout on Amazon EC2 for Oracle databases that use Oracle Automated Storage Management (Oracle ASM). We also demonstrate how you can scale the database storage without impact on database availability.
About the Authors
Ashok Shanmuga Sundaram is a partner solutions architect with the Global System Integrator (GSI) team at Amazon Web Services. He works with the GSIs to provide guidance on enterprise cloud adoption, migration and strategy.
Ejaz Sayyed is a partner solutions architect with the Global System Integrator (GSI) team at Amazon Web Services. His focus areas include AWS database services and, database and data warehouse migrations on AWS.
Nael Haddad is a senior product manager with Elastic Block Store (EBS) team at Amazon Web Services. He is driving new features associated with multiple EBS product offerings.
Audit History
Last reviewed and updated in August, 2024 by
Tomris Postaci is a Senior Database Specialist Solutions Architect with Amazon Web Services. She focuses on helping customers to design, deploy, and modernize various database workloads.
Manoj Duvva is a Technical Account Manager at Amazon Web Services. In his role, Manoj collaborates with enterprise customers to architect, implement, and scale cloud-based applications to meet their business objectives. He is a subject matter expert in Amazon RDS for Oracle. Manoj is passionate about cloud computing, databases, automation, and artificial intelligence.
Ibrahim Emara is a Solutions Architect at AWS.