AWS Database Blog
Using Amazon EBS elastic volumes with Oracle databases (part 3): databases using Oracle ASM
October 2024: This post was reviewed for accuracy.
In parts 1 and 2 of this blog series, we discuss the elastic volumes feature for Amazon EBS and how it works with Oracle database storage layouts. We discuss elastic volumes with databases that use operating-system file systems and that use Logical Volume Managers (LVM) for database storage management. In this post, we discuss the storage layout on Amazon EC2 for Oracle databases that use Oracle Automated Storage Management (Oracle ASM). We demonstrate how you can scale the database storage without impact on availability. We also look at some of the advantages of using elastic volumes with Oracle databases.
Storage operations for databases using Oracle ASM
In this section, we briefly discuss the storage layout on Amazon EC2 for Oracle databases that use Oracle ASM for storage management. Then we discuss how Oracle database storage modifications like increasing the storage or changing the IOPS provisioned were done before the elastic volumes feature was introduced. We also discuss the associated challenges. Finally, we demonstrate how to address some of these challenges using elastic volumes with an example.
Storage layout for databases using Oracle ASM
Oracle ASM is a volume manager that is used to manage storage for Oracle databases. It includes a file system designed specifically for databases. Oracle ASM distributes data across disks to ensure uniform performance. It can also rebalance the data automatically after storage configuration changes like addition or removal of disks.
When using Oracle ASM, you create ASM disk groups that contain one or more ASM disks. An ASM disk is a storage device like an EBS volume. The ASM disk groups are exposed as file interfaces to the Oracle database instances for storing database files like data, control, redo log files, and so on. Oracle ASM uses an Oracle ASM instance. This instance is a special Oracle instance used to configure and manage the disk groups. It also provides file layout information to the Oracle database instance. Once the database instance obtains the necessary extents map, it will perform storage I/O operations directly without going through an Oracle ASM instance.
The following diagram depicts a database layout using Oracle ASM. There are two ASM disk groups—DATA and RECO, with five and three ASM disks (EBS volumes) respectively.
Oracle database storage operations without elastic volumes
To increase the storage or IOPS provisioned for your database, you create new ASM disks (EBS volumes). You add them to the ASM disk group using the following steps:
- Create a new EBS volume and attach it to the EC2 instance
- Create a primary partition on the device
- Create an ASM disk and make it available to Oracle ASM by using the
oracleasm createdisk
command - Add the ASM disk to the ASM disk group using the
ALTER DISKGROUP … ADD DISK
command
After any storage configuration change, Oracle ASM automatically initiates a rebalance operation to distribute the data evenly across the disks. The power setting controls the speed of the rebalancing operation . You can set the default power limit by using the ASM_POWER_LIMIT
database initialization parameter, or you can specify it using the POWER
clause of the ALTER DISKGROUP
statement.
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 Oracle ASM level. If you modify the EBS volume size, then you need to resize the ASM disks using the ALTER DISKGROUP … RESIZE ALL
command.
When you modify the size or IOPS of an EBS volume, the data is automatically spread across multiple backend devices. This approach helps to avoid hot spots and ensure that you get the IOPS provisioned.
Example: increasing the storage for a database that uses Oracle ASM
In this section, we demonstrate how to increase the storage provisioned for an Oracle database that uses Oracle ASM for storage management, without any downtime. For this demonstration, we use an Oracle 19c database running on Red Hat Enterprise Linux. We have attached six EBS volumes of 50 GiB each to the EC2 instance, which are presented as ASM disks to Oracle ASM. We have created an ASM disk group DATA with a total size 300 GB from these six ASM disks. During this demonstration, we increase the storage provisioned to the database from 300 GiB to 600 GiB without downtime.
To demonstrate that the resize was performed without any database downtime, we have 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, it is 50 GB as seen in the following screenshot for one of the six EBS volumes.
Next, we query the v$asm_diskgroup
view. We see that the DATA disk group has a total size of 300 GB and contains six ASM disks (backed by the six EBS volumes) of 50 GB each, as shown in the following screenshot.
We have created a big file tablespace, 250 GB in size, called EVTestTablespace
as shown in the following screenshot.
From the following screenshot, we can see that a little over 250 GB has been used from the 300 GB provisioned for the ASM disk group called DATA.
Step 2: Setting up the stored procedure
Start the evtestproc
stored procedure to insert records into the evtesttab
table while we increase the storage provisioned to the database.
We query the table from a different session to verify that records are being inserted.
Step 3: Resizing the EBS volumes
We now increase the size of the EBS volumes from 50 GB to 100 GB using the AWS CLI.
We do this for each of the six EBS volumes. After a short while, we check the status of the volume modification request using the AWS CLI. Now you can see that the volume has entered the optimizing state, and the new size is reflected in the AWS Management Console, as seen in the following screenshot.
Note: If you need to determine the EBS volume that is mapped to an ASMLIB disk, see the following example:
Use the following script to find the devices mapped to the ASMLIB disks:
Once you have identified the path of the mapped device, you can determine its EBS volume ID by matching the device path to the path mentioned in the EBS volume console page. For NVMe EBS volumes, use the steps listed in this document to identify the EBS device.
Use lsblk command to confirm the new size of the EBS volumes at the OS level:
Step 4: Resizing the disk partitions on the EBS volumes
The partition must be resized before Oracle ASM recognizes the new size. You can use the following steps to resize the partition online:
Use the growpart
command to resize the partition as shown.
We repeat the preceding steps to resize the partitions on all the six EBS volumes.
Verify that the partition has been extended. Use the lsblk
command. The partition size should now be equal to the volume size.
After growing the partitions, resize the diskgroup to use the new disks’ size using the below statement:
Finally, we query the ASM views and verify that the ASM disks are reflecting the new size (100 GB), as shown in the following screenshot.
Note: If you are resizing the disks to a value greater than 2TB and you encountered ORA-15099
error, make sure that the COMPATIBLE.ASM or COMPATIBLE.RDBMS disk group attribute is set to 12.1 or greater.
Step 5: Increasing the database storage
We now increase the database storage available by resizing the big file tablespace to 500 GB, as shown in the following screenshots.
From the following screenshot, we can see that a little over 500 GB has been used from the 600 GB provisioned for the DATA ASM disk group.
Step 6: Verifying that there was no database downtime while the storage was resized
We query the evtesttab
table to verify that the PL/SQL procedure execution was uninterrupted. The 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 Oracle ASM for storage management, without any impact on database availability. You can also change the IOPS provisioned for the database using elastic volumes without any impact on database availability or performance. In addition, you can change the EBS volume type (for example, from io2 to gp3) using elastic volumes without any impact on database availability or performance.
512B and 4K sector size challenge
One of the points that should be considered while managing ASM disks on EC2 is the sector size of the underlying EBS storage. EBS advertises 512-byte or 4,096-byte (4K) physical sectors to the operating system. The advertised sector size of EBS volumes depends on three factors – the instance’s hypervisor, operating system, and volume configuration. If any one of these does not support 4K physical sectors, EBS will default to advertising 512-byte sectors. When changing the EC2 instance class or upgrading the OS, it is critical to consider potential impacts on the EBS volume sector size. Failure to account for sector size changes may result in errors when mounting ASM disk groups. Use the following commands to verify the physical and logical sector sizes:
Advantages of using elastic volumes
- Ease of maintenance – You can use elastic volumes to increase the storage provisioned easily, without downtime or performance impact, by using simple API calls. Similarly, you can use elastic volumes to adjust the IOPS provisioned for your database easily, without downtime or performance impact, by using simple API calls. You can also automate these operations.
- Predictable spiky workloads – Some workloads have spikes that are predetermined and easily predictable, like month-end processing. We can use elastic volumes to dial up the IOPS provisioned for the database during the spikes and dial it down afterward. By doing this, you can meet the performance requirements of the database and keep costs to a minimum at the same time.
- Cost reduction – EBS io2 volumes offer the highest performance but are expensive compared to gp3 volumes, which offer a balance between price and performance. If you have a database that is used mostly during weekdays, you can dial down the IOPS provisioned during the weekend to save costs. Similarly, you can change the volume type from io2 to gp3 during the weekend to save costs.
Let’s look at the potential cost savings using the following example.
Suppose that you have a database that is deployed in the US-East (Ohio) Region, and it has a storage requirement of 1 TB and a peak IOPS requirement of 30,000. The database is mostly accessed during the weekdays (Monday–Friday) and has minimal usage during the weekend (Saturday–Sunday).
If you use only io1 volumes throughout the month for database storage, the EBS charges are $2075 per month as calculated in the following table.
Provisioned | EBS Pricing for io1 Volumes* | Monthly Cost | |
Storage | 1 TB | $0.125 per GB-month | $125 |
IOPS | 30000 | $0.065 per provisioned IOPS-month | $1950 |
Total Monthly EBS Charges | $2075 |
*As of this writing, in the US-East (Ohio) Region.
The same configuration, with gp2 volumes instead of io1 volumes, costs only $100 per month as calculated in the following table.
Provisioned | EBS Pricing for gp2 Volumes* | Monthly Cost | |
Storage | 1 TB | $0.10 per GB-month | $100 |
Total Monthly EBS Charges | $100 |
*As of this writing, in the US-East (Ohio) Region .
The database is hardly accessed during the weekends. Thus, we can use elastic volumes to switch to gp2 volumes during the weekends (two days) and switch back to io1 volumes during the weekdays (five days) to save costs.
In this scenario, by switching between io1 and gp2 volume types, the monthly EBS charges reduce to $1512 as calculated in the following table. This is a savings of 27 percent each month compared to using only io1 volumes ($2075 per month).
Volume Type | Monthly Cost | Percentage Used in a Month | Optimized Monthly Cost |
IO1 | $2075 | 5 out of 7 days or 71.5 % of the time | $1483.6 [71.5 % of $2075] |
GP2 | $100 | 2 out of 7 days or 28.5% of the time | $28.5 [28.5 % of $100] |
Total Monthly Cost | $1512.1 |
- Debugging production issues – Suppose that you run into database performance issues in production (say, after an application patch release or an application version upgrade). In this case, you can use elastic volumes to temporarily increase the IOPS provisioned for your database until you debug and identify the problem. After the issue is resolved, you can dial down the IOPS to the normal level. You can perform this operation easily and without any application or database downtime.
- Performance testing – You can use the same QA environments for functional and performance testing. For example, you can design the QA environments to use gp3 volumes to optimize storage costs. For performance testing, you can simply change the storage type from gp3 to io2 for the duration of the performance testing activity. You can switch back to gp3 again once done. This approach eliminates the need for you to clone your functional testing environment for performance testing and saves costs at the same time.
Summary
Using the elastic volumes feature of Amazon EBS, you can increase the volume size, change the IOPS, or change the volume type while the volume is in use. In this three-part blog post, we show you how to scale the storage of your Oracle databases running on Amazon EC2 without impact on database availability or performance. We also discuss the various advantages of using elastic volumes feature with Oracle databases, including cost savings.
You can find more information on elastic volumes in the Amazon EBS documentation.
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 October, 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.