Lesson 2 of 4 · AWS Database Administration

Amazon RDS

Running Oracle, SQL Server, Db2, PostgreSQL, MySQL, and MariaDB on Amazon RDS: licensing, instance classes and storage, parameter and option groups, Multi-AZ, read replicas, backups, and upgrades.

Beginner 9 sections 8 min read

What RDS does for you

Amazon RDS (Relational Database Service) runs Oracle, SQL Server, Db2, PostgreSQL, MySQL, and MariaDB as managed services. AWS runs the servers and storage, installs patches, takes backups, and handles failover. You still design, tune, secure, and look after the databases themselves.

Each RDS database runs on a DB instance: a managed server with one engine on it. For most engines, one DB instance holds one or more databases; an RDS for Oracle instance holds one database (or, in the multitenant setup, one container database with its pluggable databases).

AWS takes care ofYou still take care of
Hardware, operating system, and engine installationChoosing the engine, version, size, and settings
Applying patches, in the maintenance window you chooseDeciding when to upgrade, and testing upgrades first
Automated backups and point-in-time restoreSetting retention, and testing restores
Detecting failures and failing over to a standbyChoosing Multi-AZ and read replicas to meet the RPO and RTO
Encrypting storage, when you switch it onUsers, permissions, network access, and auditing
Schema design, query tuning, and cost

The trade-off is access. There's no operating system login, and no full administrator account inside the database. On RDS for Oracle, for example, you can't connect AS SYSDBA. Instead, the master user you create has most DBA privileges, and AWS provides the rdsadmin package for tasks that would normally need SYS, such as killing a session or switching the redo log:

-- RDS for Oracle: end a runaway session, then switch the online redo log
EXEC rdsadmin.rdsadmin_util.kill(sid => 123, serial => 4567);
EXEC rdsadmin.rdsadmin_util.switch_logfile;

Engines and licensing

For commercial engines, the license is part of the decision and often the biggest part of the bill:

EngineLicensing on RDS
OracleLicense Included for Standard Edition 2, where the license is part of the hourly price, or bring your own license (BYOL) for Enterprise Edition or Standard Edition 2.
SQL ServerLicense Included, for Express, Web, Standard, and Enterprise editions.
Db2Bring your own IBM license, or pay for one by the hour through AWS Marketplace.
PostgreSQL, MySQL, MariaDBNo license cost: the engines are open source.

Enterprise Edition features, such as partitioning and Active Data Guard, need Enterprise Edition licenses, and some extra-cost options, such as the Diagnostics and Tuning Packs, must also be licensed when you use them.

Instance classes and storage

A DB instance's size comes from its instance class, which sets its vCPUs and memory, plus the storage you attach:

Class familyExampleDesigned for
Burstable (db.t)db.t3.mediumDevelopment, testing, and light workloads. Cheap, with short bursts of extra CPU.
General purpose (db.m)db.m6i.largeMost production workloads, with a balance of CPU and memory.
Memory optimized (db.r, db.x)db.r6i.xlargeLarge caches and heavy query loads, where memory matters most.

A g in the class name, such as db.m7g, means an AWS Graviton processor, which costs less for the same work. Graviton classes are available for PostgreSQL, MySQL, and MariaDB, but not for Oracle or SQL Server.

For storage, General Purpose SSD (gp3) suits most databases and lets you set IOPS and throughput separately from size. Provisioned IOPS SSD (io2) is for the most demanding, I/O-heavy workloads. Storage can grow automatically with storage autoscaling, but allocated storage can never be reduced, so start modestly.

Parameter groups and option groups

Since there's no server to log in to, engine settings and extra features are managed through AWS:

Parameter group
A named set of engine settings, the RDS equivalent of Oracle's spfile or PostgreSQL's postgresql.conf, attached to one or more instances. The default groups can't be changed, so create your own. Dynamic parameters take effect right away; static ones wait for a reboot, and the instance shows pending-reboot until then.
Option group
Turns on extra features, mainly for Oracle and SQL Server, such as Oracle Transparent Data Encryption (TDE), the Oracle Enterprise Manager agent, or SQL Server native backup and restore to Amazon S3.
# create a custom parameter group and raise open_cursors
$ aws rds create-db-parameter-group --db-parameter-group-name kofi-oracle-se2 \
    --db-parameter-group-family oracle-se2-19 --description "Sales Oracle settings"
$ aws rds modify-db-parameter-group --db-parameter-group-name kofi-oracle-se2 \
    --parameters "ParameterName=open_cursors,ParameterValue=500,ApplyMethod=immediate"

High availability and read replicas

PRIMARY REGION PrimaryStandby Zone aZone b synchronous Automated backups and snapshots stored in Amazon S3; snapshots can be copied to other regions ANOTHER REGION Read replica asynchronous read-only queries, and a disaster recovery option
Multi-AZ DB instance
Keeps a standby in another availability zone, updated synchronously, so no committed data is lost. If the primary fails, RDS fails over automatically, usually within one to two minutes, and points the database's endpoint name at the new primary, so applications just reconnect. The standby can't be queried, and it roughly doubles the cost. For production, it's the default choice.
Multi-AZ DB cluster
For PostgreSQL and MySQL only: a primary plus two readable standbys in different zones, with faster failover, typically under 35 seconds.
Read replicas
Read-only copies, updated asynchronously, in the same region or another one: up to 15 for PostgreSQL, MySQL, and MariaDB, and fewer for the commercial engines. They take reporting queries off the primary, and a replica in another region can be promoted to a standalone database in a regional disaster. On RDS for Oracle, replicas are built with Data Guard and need Enterprise Edition; opening them for queries also needs an Active Data Guard license.

Backups and restores

Automated backups
A daily snapshot of the instance's storage, taken in the backup window you choose, plus transaction logs every few minutes. Together they allow point-in-time restore to any second within the retention period, from 1 to 35 days.
Manual snapshots
Taken whenever you like, such as before an upgrade, and kept until you delete them, even after the instance itself is deleted. They can be copied to other regions and shared with other accounts for disaster recovery. AWS Backup can schedule and keep them centrally.

Maintenance and upgrades

  • Maintenance window: a weekly slot, such as Sunday 03:00 to 03:30 UTC, when AWS applies required patches. With Multi-AZ, the standby is patched first, then a failover keeps downtime short.
  • Minor version upgrades can be applied automatically in the maintenance window. Major version upgrades, such as PostgreSQL 15 to 16, are always started by you, after testing on a copy restored from a snapshot.
  • Blue/green deployments, for PostgreSQL, MySQL, and MariaDB, build an updated copy (green) kept in sync with production (blue). When it's tested, a switchover moves applications to it, usually in under a minute.
  • Applying changes: when you change an instance's class or settings, you choose to apply it immediately or in the next maintenance window. Changes such as a new instance class cause a brief outage either way.

Creating and connecting

With the AWS CLI, creating a production Oracle database for Kofi's sales application looks like this:

# Oracle Standard Edition 2, license included, Multi-AZ, private, encrypted
$ aws rds create-db-instance --db-instance-identifier kofi-ora-01 \
    --engine oracle-se2 --license-model license-included --db-name SALES \
    --db-instance-class db.m6i.large --storage-type gp3 --allocated-storage 100 \
    --multi-az --storage-encrypted --no-publicly-accessible \
    --db-subnet-group-name sales-db-subnets --vpc-security-group-ids sg-0abc1234 \
    --db-parameter-group-name kofi-oracle-se2 --backup-retention-period 14 \
    --master-username admin --manage-master-user-password

--manage-master-user-password has RDS create the master password and keep it in AWS Secrets Manager, so it's never typed or stored in a script. Once the instance is available, find its endpoint and connect with the usual tools:

$ aws rds describe-db-instances --db-instance-identifier kofi-ora-01 \
    --query "DBInstances[0].Endpoint.Address" --output text
kofi-ora-01.c1abcd2efgh3.us-east-1.rds.amazonaws.com

$ sqlplus admin@//kofi-ora-01.c1abcd2efgh3.us-east-1.rds.amazonaws.com:1521/SALES

For a development database, an RDS instance can be stopped to save on compute. Like Azure's Flexible Server, it starts again automatically after seven days, and storage and backups are still billed while it's stopped.

Key takeaways

  • Amazon RDS runs six engines as managed DB instances. AWS handles servers, patches, backups, and failover; you handle design, tuning, security, and cost.
  • There's no operating system or SYSDBA access. The master user and packages such as rdsadmin cover DBA tasks; RDS Custom offers more control for Oracle and SQL Server.
  • For Oracle, choose License Included (Standard Edition 2) or bring your own license.
  • Size with an instance class and gp3 or io2 storage. Storage can grow but never shrink.
  • Manage settings with parameter groups and features with option groups.
  • Use Multi-AZ for high availability, read replicas for reporting and regional recovery, and backups and snapshots for restores, which always create a new instance.