Amazon Relational Database Service User Guide

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 1012

DownloadAmazon Relational Database Service - User Guide
Open PDF In BrowserView PDF
Amazon Relational
Database Service
User Guide
API Version 2014-10-31

Amazon Relational Database Service User Guide

Amazon Relational Database Service: User Guide
Copyright © 2016 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any
manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other
trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to,
or sponsored by Amazon.

Amazon Relational Database Service User Guide

Table of Contents
What Is Amazon RDS? .................................................................................................................. 1
Amazon RDS Components ..................................................................................................... 2
DB Instances ............................................................................................................... 2
Regions and Availability Zones ....................................................................................... 3
Security Groups ............................................................................................................ 3
DB Parameter Groups ................................................................................................... 3
DB Option Groups ........................................................................................................ 3
Available RDS Interfaces ....................................................................................................... 3
Amazon RDS Console ................................................................................................... 4
Command Line Interface ................................................................................................ 4
Programmatic Interfaces ................................................................................................ 4
How You Are Charged for Amazon RDS .................................................................................. 4
Monitoring an Amazon RDS DB Instance ................................................................................. 5
What's Next? ........................................................................................................................ 5
Getting Started ............................................................................................................. 5
Database Engine Specific Topics .................................................................................... 5
Setting Up ................................................................................................................................... 7
Sign Up for AWS .................................................................................................................. 7
Create an IAM User .............................................................................................................. 7
Determine Requirements ........................................................................................................ 9
Provide Access to the DB Instance in the VPC by Creating a Security Group ................................ 10
Getting Started ........................................................................................................................... 12
Creating an Aurora DB Instance on an Aurora Cluster and Connecting to a Database ..................... 12
Create a DB Cluster .................................................................................................... 13
Connect to an Instance in a DB Cluster .......................................................................... 18
Delete the Sample DB Cluster, DB Subnet Group, and VPC .............................................. 19
Creating a MariaDB DB Instance and Connecting to a Database ................................................ 19
Creating a MariaDB Instance ........................................................................................ 20
Connecting to a Database on a DB Instance Running MariaDB .......................................... 25
Deleting a DB Instance ................................................................................................ 25
Creating a Microsoft SQL Server DB Instance and Connecting to a Database ............................... 26
Creating a SQL Server DB Instance ............................................................................... 26
Connecting to a SQL Server DB Instance Using SQL Server Management Studio .................. 34
Troubleshooting Connecting .......................................................................................... 37
Deleting a DB Instance ................................................................................................ 38
Creating a MySQL DB Instance and Connecting to a Database .................................................. 38
Creating a MySQL DB Instance .................................................................................... 38
Connecting to a Database on a DB Instance Running MySQL ............................................ 45
Deleting a DB Instance ................................................................................................ 45
Creating an Oracle DB Instance and Connecting to a Database ................................................. 46
Creating a DB Instance Running Oracle ......................................................................... 46
Connecting to a DB Instance Running Oracle .................................................................. 53
Deleting a DB Instance ................................................................................................ 55
Creating a PostgreSQL DB Instance and Connecting to a Database ............................................ 55
Creating a PostgreSQL DB Instance .............................................................................. 55
Connecting to a PostgreSQL DB Instance ....................................................................... 62
Deleting a DB Instance ................................................................................................ 65
Tutorials ..................................................................................................................................... 66
Restore a DB Instance from a DB Snapshot ........................................................................... 66
Prerequisites for Restoring a DB Instance from a DB Snapshot .......................................... 67
Steps for Restoring a DB Instance from a DB Snapshot .................................................... 68
Create an Amazon VPC for Use with an Amazon RDS DB Instance ............................................ 72
Create a VPC with Private and Public Subnets ................................................................ 73
Create a VPC Security Group for a Public Web Server .................................................... 77
Create a VPC Security Group for a Private Amazon RDS DB Instance ................................ 79
API Version 2014-10-31
iii

Amazon Relational Database Service User Guide

Related Topics ............................................................................................................ 81
Create a Web Server and an Amazon RDS Database .............................................................. 81
Step 1: Create a DB Instance ....................................................................................... 81
Step 2: Create a Web Server ........................................................................................ 85
Best Practices ............................................................................................................................ 98
Amazon RDS Basic Operational Guidelines ............................................................................ 98
DB Instance RAM Recommendations ..................................................................................... 99
Amazon RDS Security Best Practices .................................................................................... 99
Using Enhanced Monitoring to Identify Operating System Issues ................................................ 99
Using Metrics to Identify Performance Issues ......................................................................... 100
Viewing Performance Metrics ...................................................................................... 100
Evaluating Performance Metrics ................................................................................... 101
Tuning Queries ........................................................................................................ 103
Best Practices for Working with MySQL Storage Engines ........................................................ 103
Best Practices for Working with MariaDB Storage Engines ....................................................... 104
Best Practices for Working with PostgreSQL .......................................................................... 105
Loading Data into a PostgreSQL DB Instance ................................................................ 105
Working with the fsync and full_page_writes database parameters .................................... 105
Working with the PostgreSQL Autovacuum Feature ........................................................ 105
Best Practices for Working with SQL Server .......................................................................... 106
Amazon RDS Best Practices Presentation Video .................................................................... 107
DB Instances ............................................................................................................................ 108
DB Instance Class ............................................................................................................. 109
Current Generation .................................................................................................... 109
Previous Generation .................................................................................................. 113
Specifications for All Available DB Instance Classes ....................................................... 114
DB Instance Status ............................................................................................................ 115
Regions and Availability Zones ............................................................................................ 117
Related Topics .......................................................................................................... 118
High Availability (Multi-AZ) .................................................................................................. 118
Failover Process for Amazon RDS ............................................................................... 119
Amazon RDS and Amazon VPC .......................................................................................... 120
DB Instance Backups ......................................................................................................... 121
Automated Backup .................................................................................................... 121
DB Snapshots ........................................................................................................... 124
Related Topics .......................................................................................................... 124
DB Instance Replication ..................................................................................................... 124
DB Instance Lifecycle ................................................................................................................. 125
Maintenance and Upgrades ................................................................................................ 127
Amazon RDS Maintenance ......................................................................................... 127
Updating Operating Systems ....................................................................................... 131
Upgrading Database Engine Versions ........................................................................... 135
Backing Up and Restoring .................................................................................................. 147
Working With Automated Backups ............................................................................... 148
Creating a DB Snapshot ............................................................................................. 152
Restoring From a DB Snapshot ................................................................................... 154
Copying a DB Snapshot ............................................................................................. 158
Sharing a DB Snapshot or DB Cluster Snapshot ............................................................ 166
Restoring a DB Instance to a Specified Time ................................................................. 173
Modifying a DB Instance .................................................................................................... 175
Related Topics .......................................................................................................... 177
Renaming a DB Instance .................................................................................................... 178
Renaming to Replace an Existing DB Instance ............................................................... 178
AWS Management Console ........................................................................................ 179
CLI .......................................................................................................................... 179
API .......................................................................................................................... 179
Related Topics .......................................................................................................... 180
Deleting a DB Instance ...................................................................................................... 181
API Version 2014-10-31
iv

Amazon Relational Database Service User Guide

Deleting a DB Instance with No Final Snapshot .............................................................. 181
Deleting a DB Instance with a Final Snapshot ................................................................ 182
Related Topics .......................................................................................................... 184
Rebooting a DB Instance .................................................................................................... 185
AWS Management Console ........................................................................................ 185
CLI .......................................................................................................................... 185
API .......................................................................................................................... 186
Working with Storage Types ............................................................................................... 187
Modifying a DB Instance to Use a Different Storage Type ................................................ 187
Modifying IOPS and Storage Settings for a DB Instance That Uses Provisioned IOPS ........... 189
Creating a DB Instance That Uses Provisioned IOPS Storage .......................................... 191
Creating a MySQL or MariaDB Read Replica That Uses Provisioned IOPS Storage .............. 193
Working with Read Replicas ............................................................................................... 195
Amazon RDS Read Replica Overview .......................................................................... 195
PostgreSQL Read Replicas (version 9.3.5 and later) ....................................................... 197
MySQL and MariaDB Read Replicas ............................................................................ 198
Creating a Read Replica ............................................................................................ 199
Promoting a Read Replica to Be a DB Instance ............................................................. 201
Replicating a Read Replica Across Regions .................................................................. 203
Monitoring Read Replication ........................................................................................ 208
Troubleshooting a MySQL or MariaDB Read Replica Problem .......................................... 210
Troubleshooting a PostgreSQL Read Replica Problem .................................................... 211
Tagging Amazon RDS Resources ........................................................................................ 213
What You Should Know About Amazon RDS Resource Tags ........................................... 213
AWS Management Console ........................................................................................ 214
CLI .......................................................................................................................... 216
API .......................................................................................................................... 216
Working with Amazon Resource Names (ARNs) in Amazon RDS ...................................... 217
Related Topics .......................................................................................................... 222
Working with Option Groups ............................................................................................... 223
Option Groups Overview ............................................................................................ 223
Creating an Option Group ........................................................................................... 224
Making a Copy of an Option Group .............................................................................. 226
Adding an Option to an Option Group ........................................................................... 228
Listing the Options and Option Settings for an Option Group ............................................ 232
Modifying an Option Setting ........................................................................................ 235
Removing an Option from an Option Group ................................................................... 240
Working with DB Parameter Groups ..................................................................................... 243
Creating a DB Parameter Group .................................................................................. 244
Modifying Parameters in a DB Parameter Group ............................................................ 246
Copying a DB Parameter Group .................................................................................. 249
Listing DB Parameter Groups ...................................................................................... 251
Viewing Parameter Values for a DB Parameter Group ..................................................... 254
DB Parameter Values ................................................................................................ 256
Working with DB Security Groups ........................................................................................ 259
Creating a DB Security Group ..................................................................................... 259
Listing Available DB Security Groups ............................................................................ 263
Viewing a DB security group ....................................................................................... 264
Authorizing Network Access to a DB Security Group from an IP Range .............................. 266
Authorizing Network Access to a DB Instance from an Amazon EC2 Instance ...................... 268
Revoking Network Access to a DB Instance from an IP Range ......................................... 270
Related Topics .......................................................................................................... 272
Working with Reserved DB Instances ................................................................................... 273
Getting Information About Available Reserved DB Instance Offerings ................................. 274
Purchasing a Reserved DB Instance ............................................................................ 279
Getting Information About Your Account's Reserved DB Instances .................................... 281
Cancelling a Reserved Instance ................................................................................... 284
Related Topics .......................................................................................................... 284
API Version 2014-10-31
v

Amazon Relational Database Service User Guide

Monitoring ................................................................................................................................ 285
Monitoring Tools ................................................................................................................ 286
Automated Tools ....................................................................................................... 286
Manual Monitoring Tools ............................................................................................ 287
Monitoring CloudWatch ...................................................................................................... 287
Metrics and Dimensions ............................................................................................. 287
Creating Alarms ........................................................................................................ 290
Viewing DB Instance Metrics ............................................................................................... 291
Viewing Metrics by Using the Console .......................................................................... 291
DB Instance Metrics ................................................................................................... 292
Related Topics .................................................................................................................. 293
Enhanced Monitoring ......................................................................................................... 294
Enhanced Monitoring Availability .................................................................................. 294
Differences Between CloudWatch and Enhanced Monitoring Metrics .................................. 294
Setting Up for and Enabling Enhanced Monitoring .......................................................... 294
Viewing Enhanced Monitoring ...................................................................................... 296
Viewing Enhanced Monitoring by Using CloudWatch Logs ............................................... 297
Related Topics .......................................................................................................... 303
Using Amazon RDS Event Notification .................................................................................. 304
Amazon RDS Event Categories and Event Messages ..................................................... 305
Subscribing to Amazon RDS Event Notification .............................................................. 310
Listing Your Amazon RDS Event Notification Subscriptions .............................................. 314
Modifying an Amazon RDS Event Notification Subscription ............................................... 316
Adding a Source Identifier to an Amazon RDS Event Notification Subscription ..................... 318
Removing a Source identifier from an Amazon RDS Event Notification Subscription .............. 320
Listing the Amazon RDS Event Notification Categories .................................................... 322
Deleting an Amazon RDS Event Notification Subscription ................................................ 324
Viewing Amazon RDS Events ............................................................................................. 326
AWS Management Console ........................................................................................ 326
CLI .......................................................................................................................... 326
API .......................................................................................................................... 326
Related Topics .......................................................................................................... 327
Database Log Files ............................................................................................................ 328
Viewing and Listing Database Log Files ........................................................................ 328
Downloading a Database Log File ................................................................................ 331
Watching a Database Log File .................................................................................... 334
Related Topics .......................................................................................................... 337
MySQL Database Log Files ........................................................................................ 337
Oracle Database Log Files ......................................................................................... 341
SQL Server Database Log Files .................................................................................. 344
PostgreSQL Database Log Files .................................................................................. 346
MariaDB Database Log Files ....................................................................................... 347
Logging Amazon RDS API Calls Using AWS CloudTrail .......................................................... 353
Configuring CloudTrail Event Logging ........................................................................... 353
Amazon RDS Event Entries in CloudTrail Log Files ........................................................ 353
Security .................................................................................................................................... 356
Authentication and Access Control ....................................................................................... 357
Authentication ........................................................................................................... 357
Access Control .......................................................................................................... 358
Overview of Managing Access ..................................................................................... 358
Using Identity-Based Policies (IAM Policies) .................................................................. 362
Amazon RDS API Permissions Reference ..................................................................... 365
Using Conditions ....................................................................................................... 378
Encrypting Amazon RDS Resources .................................................................................... 384
Enabling Amazon RDS Encryption for a DB Instance ...................................................... 384
Availability of Amazon RDS Encrypted Instances ............................................................ 385
Managing Amazon RDS Encryption Keys ...................................................................... 386
Limitations of Amazon RDS Encrypted Instances ............................................................ 386
API Version 2014-10-31
vi

Amazon Relational Database Service User Guide

Using SSL to Encrypt a Connection .....................................................................................
Intermediate certificates ..............................................................................................
Amazon RDS Security Groups ............................................................................................
DB Security Groups ...................................................................................................
VPC Security Groups .................................................................................................
DB Security Groups vs. VPC Security Groups ................................................................
Security Group Scenario .............................................................................................
Delete DB VPC security groups ...................................................................................
Master User Account Privileges ...........................................................................................
Related Topics ..................................................................................................................
Using Amazon RDS with Amazon VPC .........................................................................................
Determining Whether You Are Using the EC2-VPC or EC2-Classic Platform ...............................
Related Topics ..................................................................................................................
Scenarios for Accessing a DB Instance in a VPC ...................................................................
An EC2 Instance in the Same VPC ..............................................................................
An EC2 Instance in a Different VPC .............................................................................
An EC2 Instance Not in a VPC ...................................................................................
A Client Application Through the Internet ......................................................................
An EC2 Instance in a VPC .........................................................................................
An EC2 Instance Not in a VPC ...................................................................................
A Client Application Through the Internet ......................................................................
Working with a DB Instance in a VPC ..................................................................................
Working with a DB Instance in a VPC ..........................................................................
Working with DB Subnet Groups .................................................................................
Hiding a DB Instance in a VPC from the Internet ............................................................
Creating a DB Instance in a VPC ................................................................................
Updating the VPC for a DB Instance ............................................................................
Moving a DB Instance into a VPC. ...............................................................................
Storage ....................................................................................................................................
Storage Types ..................................................................................................................
Performance Metrics ..........................................................................................................
Facts About Amazon RDS Storage ......................................................................................
Other Factors That Impact Storage Performance ............................................................
Adding Storage and Changing Storage Type .................................................................
General Purpose (SSD) Storage ..........................................................................................
I/O Credits and Burst Performance ...............................................................................
Provisioned IOPS Storage ..................................................................................................
Using Provisioned IOPS Storage with Multi-AZ, Read Replicas, Snapshots, VPC, and DB
Instance Classes .......................................................................................................
Provisioned IOPS Storage Costs .................................................................................
Getting the Most out of Amazon RDS Provisioned IOPS ..................................................
Provisioned IOPS Storage Support in the AWS CLI and Amazon RDS API .........................
Factors That Affect Realized IOPS Rates ..............................................................................
Page Size and Channel Bandwidth ..............................................................................
DB Instance Classes for Provisioned IOPS ....................................................................
Database Workload ...................................................................................................
Aurora on Amazon RDS .............................................................................................................
Availability ........................................................................................................................
Aurora Endpoints ...............................................................................................................
Amazon Aurora Storage .....................................................................................................
Amazon Aurora Replication .................................................................................................
Amazon Aurora Reliability ...................................................................................................
Storage Auto-Repair ..................................................................................................
"Survivable" Cache Warming .......................................................................................
Crash Recovery ........................................................................................................
Aurora Performance Enhancements .....................................................................................
Fast Insert ................................................................................................................
Amazon Aurora Security .....................................................................................................
API Version 2014-10-31
vii

387
387
388
388
388
389
389
390
392
393
394
394
396
396
396
398
399
400
400
401
402
403
404
404
405
406
408
409
410
410
411
411
412
413
413
413
415
416
416
417
417
418
418
419
419
421
422
423
424
424
424
425
425
425
425
425
426

Amazon Relational Database Service User Guide

Securing Aurora Data with SSL ................................................................................... 427
Local Time Zone for Amazon Aurora DB Clusters ................................................................... 427
Comparison of Amazon Aurora and Amazon RDS for MySQL .................................................. 430
Creating an Amazon Aurora DB Cluster ................................................................................ 432
DB Cluster Prerequisites ............................................................................................ 432
Using the AWS Management Console to Launch an Aurora DB Cluster and Create an
Aurora Replica .......................................................................................................... 433
Creating a VPC for Aurora .......................................................................................... 443
Connecting to an Amazon Aurora DB Cluster ........................................................................ 449
Connection Utilities .................................................................................................... 450
Connecting with SSL .................................................................................................. 450
Troubleshooting Aurora Connection Failures .................................................................. 451
Viewing an Amazon Aurora DB Cluster ................................................................................. 451
Viewing a DB Cluster in the Console ............................................................................ 452
Viewing a DB Cluster by Using the AWS CLI ................................................................. 453
Viewing a DB Cluster by Using the Amazon RDS API ..................................................... 455
Related Topics .......................................................................................................... 456
Migrating Data to an Amazon Aurora DB Cluster .................................................................... 456
Migrating Data from an External MySQL Database to an Amazon Aurora DB Cluster ............ 457
Migrating Data from a MySQL DB Instance to an Amazon Aurora DB Cluster ...................... 469
Related Topics .......................................................................................................... 476
Replication with Amazon Aurora .......................................................................................... 476
Monitoring Aurora Replication ...................................................................................... 477
Replicating Amazon Aurora DB Clusters Across AWS Regions ......................................... 477
Replication Between Aurora and MySQL or Between Aurora and Another Aurora DB
Cluster ..................................................................................................................... 485
Monitoring an Amazon Aurora DB Cluster ............................................................................. 496
Aurora Metrics .......................................................................................................... 498
Managing an Amazon Aurora DB Cluster .............................................................................. 501
Managing Performance and Scaling for Aurora DB Cluster ............................................... 501
Fault Tolerance for an Aurora DB Cluster ...................................................................... 502
Backing Up and Restoring an Aurora DB Cluster ............................................................ 503
Testing Amazon Aurora Using Fault Injection Queries ..................................................... 504
Best Practices with Amazon Aurora ...................................................................................... 506
Determining Which DB Instance You Are Connected To .................................................. 507
Using Amazon Aurora to Scale Reads for Your MySQL Database ..................................... 507
Using Amazon Aurora for Disaster Recovery with Your MySQL Databases ......................... 510
Migrating from MySQL to Amazon Aurora with Reduced Downtime .................................... 510
DB Cluster and DB Instance Parameters .............................................................................. 510
Cluster-level parameters ............................................................................................. 511
Database Engine Updates .................................................................................................. 512
Amazon Aurora Versions ............................................................................................ 513
Amazon Aurora Database Upgrades (Patching) .............................................................. 513
Aurora Lab Mode ...................................................................................................... 513
Related Topics .......................................................................................................... 514
Database Engine Updates 2016-09-20 .......................................................................... 514
Database Engine Updates 2016-08-30 .......................................................................... 514
Database Engine Updates 2016-06-01 .......................................................................... 515
Database Engine Updates 2016-04-06 .......................................................................... 516
Database Engine Updates 2016-01-11 .......................................................................... 517
Database Engine Updates 2015-12-03 .......................................................................... 518
Database Engine Updates 2015-10-16 .......................................................................... 519
Database Engine Updates 2015-08-24 .......................................................................... 521
MariaDB on Amazon RDS .......................................................................................................... 522
MariaDB Planning Information ............................................................................................. 523
MariaDB Versions ...................................................................................................... 523
Amazon RDS MariaDB Supported Storage Engines ........................................................ 524
Amazon RDS MariaDB Supported Regions ................................................................... 525
API Version 2014-10-31
viii

Amazon Relational Database Service User Guide

Amazon RDS and MariaDB Security ............................................................................ 525
Local Time Zone for MariaDB DB Instances .................................................................. 526
XtraDB Cache Warming ............................................................................................. 528
MariaDB, MySQL, and Amazon Aurora Feature Comparison ............................................ 529
MariaDB Features Not Supported by Amazon RDS ......................................................... 532
Database Parameters for MariaDB ............................................................................... 533
Common DBA Tasks for MariaDB ................................................................................ 533
Creating a DB Instance Running MariaDB ............................................................................. 533
AWS Management Console ........................................................................................ 533
CLI .......................................................................................................................... 540
API .......................................................................................................................... 541
Related Topics .......................................................................................................... 542
Connecting to a DB Instance Running MariaDB ..................................................................... 543
Connecting from the mysql Utility ................................................................................. 543
Connecting with SSL .................................................................................................. 544
Maximum MariaDB Connections .................................................................................. 544
Related Topics .......................................................................................................... 545
Modifying a DB Instance Running MariaDB ........................................................................... 546
AWS Management Console ........................................................................................ 546
CLI .......................................................................................................................... 548
API .......................................................................................................................... 549
Importing Data Into a MariaDB DB Instance .......................................................................... 551
Configuring GTID-Based Replication into an Amazon RDS MariaDB DB instance ................. 551
Appendix: Options for MariaDB ............................................................................................ 555
MariaDB Audit Plugin Support ..................................................................................... 555
Appendix: Parameters for MariaDB ...................................................................................... 558
Appendix: MariaDB on Amazon RDS SQL Reference ............................................................. 563
mysql.rds_set_external_master_gtid ............................................................................. 563
mysql.rds_kill_query_id ............................................................................................... 565
Microsoft SQL Server on Amazon RDS ........................................................................................ 566
Common Management Tasks for Microsoft SQL Server on Amazon RDS ................................... 566
Limits for SQL Server DB Instances ..................................................................................... 568
SQL Server 2014 Support .................................................................................................. 569
Upgrading to SQL Server 2014 on Amazon RDS ............................................................ 570
SQL Server 2012 Support on Amazon RDS .......................................................................... 570
SQL Server 2008 R2 Support on Amazon RDS ..................................................................... 571
Licensing .......................................................................................................................... 572
License Included ....................................................................................................... 572
Bring Your Own License (BYOL) ................................................................................. 573
Restoring License-Terminated DB Instances .................................................................. 573
Multi-AZ Deployments Using SQL Server Mirroring ................................................................. 574
Database Engine Version Management ................................................................................ 574
Upgrading from 2008 R2 to 2012 ................................................................................. 574
Upgrading to SQL Server 2014 on Amazon RDS ............................................................ 575
SQL Server Roles and Permissions ..................................................................................... 575
SSL Support ..................................................................................................................... 576
Using TDE to Encrypt Data at Rest ...................................................................................... 576
Local Time Zone ............................................................................................................... 576
Supported Time Zones ............................................................................................... 577
Creating a DB Instance Running SQL Server ........................................................................ 579
AWS Management Console ........................................................................................ 579
CLI .......................................................................................................................... 588
API .......................................................................................................................... 589
Related Topics .......................................................................................................... 590
Connecting to a DB Instance Running SQL Server ................................................................. 591
Connecting with SQL Server Management Studio ........................................................... 591
Connecting with SQL Workbench/J .............................................................................. 594
Troubleshooting a Connection to a DB Instance Running SQL Server ................................ 596
API Version 2014-10-31
ix

Amazon Relational Database Service User Guide

Related Topics .......................................................................................................... 597
Modifying a DB Instance Running SQL Server ....................................................................... 598
Available Settings ...................................................................................................... 598
AWS Management Console ........................................................................................ 603
CLI .......................................................................................................................... 603
API .......................................................................................................................... 604
Related Topics .......................................................................................................... 605
Importing and Exporting SQL Server Databases ..................................................................... 606
Setting Up ................................................................................................................ 607
Using Native Backup and Restore ................................................................................ 609
Migrating to Amazon RDS by Using Native Backup and Restore ....................................... 612
Troubleshooting ......................................................................................................... 612
Related Topics .......................................................................................................... 613
Importing and Exporting SQL Server Data Using Other Methods ....................................... 614
Multi-AZ Deployments for SQL Server with Database Mirroring ................................................. 623
Adding Multi-AZ to a SQL Server DB Instance ............................................................... 623
Notes and Recommendations ...................................................................................... 623
Determining the Location of the Standby Mirror .............................................................. 625
Related Topics .......................................................................................................... 626
Using SSL with a DB Instance Running SQL Server ............................................................... 627
Advanced Administrative Tasks and Concepts for Microsoft SQL Server ..................................... 628
Using Windows Authentication with a DB Instance Running SQL Server ............................ 630
Options for SQL Server .............................................................................................. 638
Common DBA Tasks for Microsoft SQL Server .............................................................. 643
MySQL on Amazon RDS ............................................................................................................ 650
MySQL Planning Information ............................................................................................... 651
MySQL Versions ....................................................................................................... 651
Amazon RDS Supported Storage Engines ..................................................................... 653
Amazon RDS and MySQL Security .............................................................................. 654
Local Time Zone for MySQL DB Instances .................................................................... 656
InnoDB Cache Warming ............................................................................................. 657
MySQL Features Not Supported By Amazon RDS .......................................................... 658
Known Issues and Limitations ..................................................................................... 658
Creating a DB Instance Running MySQL .............................................................................. 663
AWS Management Console ........................................................................................ 663
CLI .......................................................................................................................... 669
API .......................................................................................................................... 670
Related Topics .......................................................................................................... 671
Connecting to a DB Instance Running MySQL ....................................................................... 672
Connecting from the MySQL Utility ............................................................................... 672
Connecting with SSL .................................................................................................. 673
Maximum MySQL connections ..................................................................................... 674
Related Topics .......................................................................................................... 674
Modifying a DB Instance Running MySQL ............................................................................. 675
AWS Management Console ........................................................................................ 675
CLI .......................................................................................................................... 677
API .......................................................................................................................... 678
Importing and Exporting Data From a MySQL DB Instance ...................................................... 680
Overview .................................................................................................................. 680
Importing Data Considerations ..................................................................................... 681
Importing Data from a MySQL or MariaDB DB to an Amazon RDS MySQL or MariaDB DB
Instance ................................................................................................................... 684
Importing Data to an Amazon RDS MySQL or MariaDB DB Instance with Reduced
Downtime ................................................................................................................. 685
Importing Data From Any Source to a MySQL or MariaDB DB Instance .............................. 698
Replication with a MySQL or MariaDB Instance Running External to Amazon RDS ............... 702
Using Replication to Export MySQL Data ...................................................................... 705
Appendix: Common DBA Tasks for MySQL ........................................................................... 709
API Version 2014-10-31
x

Amazon Relational Database Service User Guide

Killing a Session or Query .......................................................................................... 709
Skipping the Current Replication Error .......................................................................... 709
Working with InnoDB Tablespaces to Improve Crash Recovery Times ................................ 710
Managing the Global Status History ............................................................................. 711
Appendix: Options for MySQL ............................................................................................. 713
MySQL memcached Support ....................................................................................... 713
MariaDB Audit Plugin Support ..................................................................................... 716
Appendix: MySQL on Amazon RDS SQL Reference ............................................................... 719
Overview .................................................................................................................. 719
SQL reference conventions ......................................................................................... 720
mysql.rds_set_external_master .................................................................................... 720
mysql.rds_reset_external_master ................................................................................. 722
mysql.rds_start_replication .......................................................................................... 723
mysql.rds_stop_replication .......................................................................................... 724
mysql.rds_skip_repl_error ........................................................................................... 724
mysql.rds_next_master_log ......................................................................................... 725
mysql.rds_innodb_buffer_pool_dump_now ..................................................................... 727
mysql.rds_innodb_buffer_pool_load_now ....................................................................... 728
mysql.rds_innodb_buffer_pool_load_abort ..................................................................... 728
mysql.rds_set_configuration ......................................................................................... 729
mysql.rds_show_configuration ..................................................................................... 729
mysql.rds_kill ............................................................................................................ 730
mysql.rds_kill_query ................................................................................................... 731
mysql.rds_rotate_general_log ...................................................................................... 732
mysql.rds_rotate_slow_log .......................................................................................... 732
mysql.rds_enable_gsh_collector ................................................................................... 733
mysql.rds_set_gsh_collector ........................................................................................ 733
mysql.rds_disable_gsh_collector .................................................................................. 734
mysql.rds_collect_global_status_history ......................................................................... 734
mysql.rds_enable_gsh_rotation .................................................................................... 734
mysql.rds_set_gsh_rotation ......................................................................................... 735
mysql.rds_disable_gsh_rotation .................................................................................... 735
mysql.rds_rotate_global_status_history .......................................................................... 736
Oracle on Amazon RDS ............................................................................................................. 737
Common Management Tasks for Oracle on Amazon RDS ....................................................... 737
Limits for Oracle DB Instances ............................................................................................ 739
DB Instances Class Restrictions for Oracle Databases .................................................... 739
Oracle 12c with Amazon RDS ............................................................................................. 739
Amazon RDS Parameter Changes for Oracle 12c ........................................................... 740
Amazon RDS System Privileges for Oracle 12c .............................................................. 742
Amazon RDS Options for Oracle 12c ........................................................................... 743
Amazon RDS PL/SQL Packages for Oracle 12c ............................................................. 743
Oracle 12c Features Not Supported ............................................................................. 745
Oracle 11g with Amazon RDS ............................................................................................. 745
Oracle Security ................................................................................................................. 746
Using SSL with an Oracle DB Instance ................................................................................. 747
Oracle Version Management ............................................................................................... 747
Deprecation of Oracle 11.2.0.2 and 11.2.0.3 .................................................................. 748
Deprecation of Oracle 12.1.0.1 .................................................................................... 748
Licensing .......................................................................................................................... 749
License Included ....................................................................................................... 749
Bring Your Own License (BYOL) ................................................................................. 749
Using OEM, APEX, TDE, and other options .......................................................................... 749
Creating a DB Instance Running Oracle ................................................................................ 750
AWS Management Console ........................................................................................ 750
CLI .......................................................................................................................... 757
API .......................................................................................................................... 758
Related Topics .......................................................................................................... 759
API Version 2014-10-31
xi

Amazon Relational Database Service User Guide

Connecting to a DB Instance Running Oracle ........................................................................
Console ...................................................................................................................
CLI ..........................................................................................................................
Related Topics ..........................................................................................................
Modifying a DB Instance Running Oracle ..............................................................................
Available Settings ......................................................................................................
AWS Management Console ........................................................................................
CLI ..........................................................................................................................
API ..........................................................................................................................
Related Topics ..........................................................................................................
Importing Data Into Oracle on Amazon RDS ..........................................................................
Oracle SQL Developer ...............................................................................................
Oracle Data Pump .....................................................................................................
Oracle Export/Import Utilities .......................................................................................
Oracle SQL*Loader ....................................................................................................
Oracle Materialized Views ...........................................................................................
Options for Oracle .............................................................................................................
Application Express (APEX) ........................................................................................
Label Security ...........................................................................................................
Native Network Encryption ..........................................................................................
Oracle Enterprise Manager .........................................................................................
Secure Sockets Layer (SSL) .......................................................................................
Statspack .................................................................................................................
Time Zone ................................................................................................................
Transparent Data Encryption (TDE) ..............................................................................
UTL_MAIL ................................................................................................................
XML DB ...................................................................................................................
Advanced Administrative Tasks and Concepts for Oracle .........................................................
Common DBA Tasks .................................................................................................
Oracle Character Sets ................................................................................................
Tools and Third-Party Software for Oracle .............................................................................
Setting Up ................................................................................................................
Using AWS CloudHSM to Store Amazon RDS Oracle TDE Keys .......................................
Using Oracle GoldenGate with Amazon RDS .................................................................
Using the Oracle Repository Creation Utility ..................................................................
Installing a Siebel Database on Oracle on Amazon RDS ..................................................
Appendix: Oracle Database Engine Release Notes .................................................................
Database Engine: 12.1.0.2 ..........................................................................................
Database Engine: 12.1.0.1 ..........................................................................................
Database Engine: 11.2.0.4 ..........................................................................................
Database Engine: 11.2.0.3 ..........................................................................................
Database Engine: 11.2.0.2 ..........................................................................................
PostgreSQL on Amazon RDS .....................................................................................................
Common Management Tasks for PostgreSQL on Amazon RDS ................................................
Amazon RDS PostgreSQL Planning Information .....................................................................
Using the rds_superuser Role .....................................................................................
Supported PostgreSQL Database Versions ....................................................................
Supported Features and Extensions .............................................................................
Limits for PostgreSQL DB Instances .............................................................................
Database Version Upgrades ........................................................................................
Using SSL with a PostgreSQL DB Instance ...................................................................
Creating a DB Instance Running PostgreSQL ........................................................................
AWS Management Console ........................................................................................
CLI ..........................................................................................................................
API ..........................................................................................................................
Related Topics ..........................................................................................................
Connecting to a DB Instance Running the PostgreSQL Database Engine ...................................
Using pgAdmin to Connect to a PostgreSQL DB Instance ................................................
API Version 2014-10-31
xii

760
760
762
762
763
763
769
769
770
770
771
771
771
774
775
776
777
777
784
786
788
792
796
799
800
802
803
804
805
816
818
818
830
846
861
866
869
870
874
881
888
894
898
898
900
901
901
909
914
915
915
918
918
923
923
924
925
925

Amazon Relational Database Service User Guide

Using psql to Connect to a PostgreSQL DB Instance ...................................................... 927
Troubleshooting Connection Issues .............................................................................. 928
Related Topics .......................................................................................................... 928
Modifying a DB Instance Running PostgreSQL ....................................................................... 929
AWS Management Console ........................................................................................ 929
CLI .......................................................................................................................... 931
API .......................................................................................................................... 932
Importing Data into PostgreSQL on Amazon RDS .................................................................. 934
Importing a PostgreSQL Database from an Amazon EC2 Instance .................................... 934
Using the \copy Command to Import Data to a Table on a PostgreSQL DB Instance ............ 936
Appendix: Common DBA Tasks for PostgreSQL ..................................................................... 938
Creating Roles .......................................................................................................... 938
Managing PostgreSQL Database Access ...................................................................... 938
Working with PostgreSQL Parameters .......................................................................... 939
Working with PostgreSQL Autovacuum ......................................................................... 947
Setting up PostGIS .................................................................................................... 954
Using pgBadger for Log Analysis with PostgreSQL ......................................................... 957
Limits ....................................................................................................................................... 958
Limits in Amazon RDS ....................................................................................................... 958
Naming Constraints in Amazon RDS .................................................................................... 959
File Size Limits in Amazon RDS .......................................................................................... 961
Aurora File Size Limits in Amazon RDS ........................................................................ 961
MySQL File Size Limits in Amazon RDS ....................................................................... 961
MariaDB File Size Limits in Amazon RDS .................................................................... 962
Troubleshooting ......................................................................................................................... 964
Cannot Connect to DB Instance .......................................................................................... 964
Testing the DB Instance Connection ............................................................................. 965
Troubleshooting Connection Authentication .................................................................... 965
Security Issues .................................................................................................................. 965
Resetting the DB Instance Owner Role Password .................................................................. 965
DB Instance Outage or Reboot ............................................................................................ 966
Parameter Changes Not Taking Effect .................................................................................. 966
DB Instance Out of Storage ................................................................................................ 967
MySQL Issues .................................................................................................................. 968
MySQL Version 5.5.40 Asynchronous I/O Is Disabled ...................................................... 968
Index Merge Optimization Returns Wrong Results .......................................................... 969
Replication Fails After Upgrading to MySQL Version 5.6.21 .............................................. 969
Diagnosing and Resolving Lag Between Read Replicas ................................................... 970
Diagnosing and Resolving a MySQL or MariaDB Read Replication Failure .......................... 972
Creating Triggers with Binary Logging Enabled Requires SUPER Privilege .......................... 973
Diagnosing and Resolving Point-In-Time Restore Failures ................................................ 974
Slave Down or Disabled Error ..................................................................................... 975
Read Replica Create Fails or Replication Breaks With Fatal Error 1236 .............................. 975
Aurora Issues ................................................................................................................... 975
No Space Left on Device Error .................................................................................... 975
Oracle GoldenGate Issues .................................................................................................. 976
Using Oracle GoldenGate with Amazon EC2 Instances ................................................... 976
Retaining Logs for Sufficient Time ................................................................................ 976
Cannot Connect to SQL Server DB Instance ......................................................................... 976
Cannot Connect to PostgreSQL DB Instance ......................................................................... 977
Amazon RDS API ...................................................................................................................... 978
Using the Query API .......................................................................................................... 978
Query Parameters ..................................................................................................... 978
Query Request Authentication ..................................................................................... 979
Using the SOAP API .......................................................................................................... 981
WSDL and Schema Definitions .................................................................................... 981
Programming Language Support .................................................................................. 982
Request Authentication ............................................................................................... 982
API Version 2014-10-31
xiii

Amazon Relational Database Service User Guide

Response Structure ...................................................................................................
Web Services References ...........................................................................................
Available Libraries .............................................................................................................
Troubleshooting Applications ...............................................................................................
Retrieving Errors .......................................................................................................
Troubleshooting Tips ..................................................................................................
RDS REST API Reference .................................................................................................
Related Topics ..........................................................................................................
DownloadCompleteDBLogFile ......................................................................................
Resources ................................................................................................................................
Document History ......................................................................................................................

API Version 2014-10-31
xiv

984
984
984
984
985
985
985
985
985
988
989

Amazon Relational Database Service User Guide

What Is Amazon Relational
Database Service (Amazon RDS)?
Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up,
operate, and scale a relational database in the cloud. It provides cost-efficient, resizeable capacity for
an industry-standard relational database and manages common database administration tasks.
Topics
• Amazon RDS Components (p. 2)
• Available RDS Interfaces (p. 3)
• How You Are Charged for Amazon RDS (p. 4)
• Monitoring an Amazon RDS DB Instance (p. 5)
• What's Next? (p. 5)
Why would you want a managed relational database service? Because Amazon RDS takes over many
of the difficult or tedious management tasks of a relational database.
• When you buy a server, you get CPU, memory, storage, and IOPS, all bundled together. With
Amazon RDS, these are split apart so that you can scale them independently. So, for example, if you
need more CPU, less IOPS, or more storage, you can easily allocate them.
• Amazon RDS manages backups, software patching, automatic failure detection, and recovery.
• In order to deliver a managed service experience, Amazon RDS does not provide shell access to
DB instances, and it restricts access to certain system procedures and tables that require advanced
privileges.
• You can have automated backups performed when you need them, or create your own backup
snapshot. These backups can be used to restore a database, and the Amazon RDS restore process
works reliably and efficiently.
• You can get high availability with a primary instance and a synchronous secondary instance that
you can failover to when problems occur. You can also use MySQL, MariaDB, or PostgreSQL Read
Replicas to increase read scaling.
• You can use the database products you are already familiar with: MySQL, MariaDB, PostgreSQL,
Oracle, Microsoft SQL Server, and the new, MySQL-compatible Amazon Aurora DB engine (for
information, see Aurora on Amazon RDS (p. 421)).
• In addition to the security in your database package, you can help control who can access your
RDS databases by using AWS IAM to define users and permissions. You can also help protect your
databases by putting them in a virtual private cloud.
API Version 2014-10-31
1

Amazon Relational Database Service User Guide
Amazon RDS Components

To begin learning more:
• If you are new to RDS but you are familiar with other Amazon Web Services, start with an
introduction to the Amazon RDS Components (p. 2). This section discusses the key components
of Amazon RDS and how they map to those that you currently work with on your local network.
• For an overview of all AWS products, see What is Cloud Computing?
• Amazon Web Services provides a number of database services. For guidance on which service is
best for your environment, see Running Databases on AWS

Amazon RDS Components
Topics
• DB Instances (p. 2)
• Regions and Availability Zones (p. 3)
• Security Groups (p. 3)
• DB Parameter Groups (p. 3)
• DB Option Groups (p. 3)

DB Instances
The basic building block of Amazon RDS is the DB instance. A DB instance is an isolated database
environment in the cloud. A DB instance can contain multiple user-created databases, and you can
access it by using the same tools and applications that you use with a stand-alone database instance.
You can create and modify a DB instance by using the Amazon AWS command line interface, the
Amazon RDS API, or the AWS Management Console.
Each DB instance runs a DB engine. Amazon RDS currently supports the MySQL, MariaDB,
PostgreSQL, Oracle, and Microsoft SQL Server DB engines. Each DB engine has its own supported
features, and each version of a DB engine may include specific features. Additionally, each DB engine
has a set of parameters in a DB parameter group that control the behavior of the databases that it
manages.
The computation and memory capacity of a DB instance is determined by its DB instance class. You
can select the DB instance that best meets your needs. If your needs change over time, you can
change DB instances. For information about DB instance classes, see the DB Instance Class section.
For pricing information on DB instance classes, go to the Pricing section of the Amazon Relational
Database Service (Amazon RDS) product page.
For each DB instance, you can select from 5 GB to 6 TB of associated storage capacity. Each DB
instance class has minimum and maximum storage requirements for the DB instances that are created
from it. It’s important to have sufficient storage so that your databases have room to grow and that
features for the DB engine have room to write content or log entries.
DB instance storage comes in three types: Magnetic, General Purpose (SSD), and Provisioned
IOPS (SSD). They differ in performance characteristics and price, allowing you to tailor your storage
performance and cost to the needs of your database. For a complete discussion of the different volume
types, see the topic Amazon EBS Volume Types.
You can run a DB instance on a virtual private cloud using Amazon's Virtual Private Cloud (VPC)
service. When you use a virtual private cloud, you have control over your virtual networking
environment: you can select your own IP address range, create subnets, and configure routing and
access control lists. The basic functionality of Amazon RDS is the same whether it is running in a VPC
or not; Amazon RDS manages backups, software patching, automatic failure detection, and recovery.
API Version 2014-10-31
2

Amazon Relational Database Service User Guide
Regions and Availability Zones

There is no additional cost to run your DB instance in a VPC. For more information on VPC and RDS,
see Virtual Private Clouds (VPCs) and Amazon RDS (p. 394).

Regions and Availability Zones
Amazon cloud computing resources are housed in highly available data center facilities in different
areas of the world (for example, North America, Europe, or Asia). Each data center location is called a
region.
Each region contains multiple distinct locations called Availability Zones, or AZs. Each Availability Zone
is engineered to be isolated from failures in other Availability Zones, and to provide inexpensive, lowlatency network connectivity to other Availability Zones in the same region. By launching instances in
separate Availability Zones, you can protect your applications from the failure of a single location. For a
list of regions and Availability Zones, see Regions and Availability Zones (p. 117).
You can run your DB instance in several Availability Zones, an option called a Multi-AZ deployment.
When you select this option, Amazon automatically provisions and maintains a synchronous standby
replica of your DB instance in a different Availability Zone. The primary DB instance is synchronously
replicated across Availability Zones to the standby replica to provide data redundancy, failover support,
eliminate I/O freezes, and minimize latency spikes during system backups.

Security Groups
A security group controls the access to a DB instance. It does so by allowing access to IP address
ranges or Amazon EC2 instances that you specify.
Amazon RDS uses DB security groups, VPC security groups, and EC2 security groups. In simple
terms, a DB security group controls access to a DB instance that is not in a VPC, a VPC security group
controls access to a DB instance inside a VPC, and an Amazon EC2 security group controls access to
an EC2 instance and can be used with a DB instance. For more information about security groups, see
Amazon RDS Security Groups (p. 388).

DB Parameter Groups
You manage the configuration of a DB engine by using a DB parameter group. A DB parameter group
contains engine configuration values that can be applied to one or more DB instances of the same
instance type. Amazon RDS applies a default DB parameter group if you don’t specify a DB parameter
group when you create a DB instance. The default group contains defaults for the specific database
engine and instance class of the DB instance.

DB Option Groups
Some DB engines offer tools that simplify managing your databases and making the best use of
your data. Amazon RDS makes such tools available through option groups. Examples of available
options are Oracle Application Express (APEX), SQL Server Transparent Data Encryption, and
MySQL memcached support. For more information on option groups, see Working with Option
Groups (p. 223).

Available RDS Interfaces
Topics
• Amazon RDS Console (p. 4)
• Command Line Interface (p. 4)
• Programmatic Interfaces (p. 4)
API Version 2014-10-31
3

Amazon Relational Database Service User Guide
Amazon RDS Console

There are several ways that you can interact with Amazon RDS.

Amazon RDS Console
The Amazon RDS console is a simple web-based user interface. From the console, you can perform
almost all tasks you need to do from the RDS console with no programming required. To access the
Amazon RDS console, sign in to the AWS Management Console and open the Amazon RDS console
at https://console.aws.amazon.com/rds/.

Command Line Interface
Amazon AWS provides a command line interface that gives you access to much of the functionality
that is available in the Amazon RDS API. For more information, see the AWS Command Line Interface
Documentation and AWS Command Line Reference for Amazon RDS.

Programmatic Interfaces
The following table lists the resources that you can use to access Amazon RDS programmatically.
Resource

Description

AWS SDKs

The AWS SDKs include sample code, libraries, tools, documentation, and
templates. To download the AWS SDKs, go to AWS Software Development
Kits (SDKs).

Libraries

AWS provides libraries, sample code, tutorials, and other resources for
software developers who prefer to build applications using languagespecific APIs instead of Amazon Relational Database Service's SOAP
and Query APIs. These libraries provide basic functions (not included in
Amazon Relational Database Service's SOAP and Query APIs), such as
request authentication, request retries, and error handling so you can get
started more easily. Libraries and resources are available for the following
languages:
• Java
• PHP
• Python
• Ruby
• Windows and .NET
For libraries and sample code in all languages, see Sample Code &
Libraries.

Amazon RDS API

If you prefer, you can code directly to the Amazon RDS API. For more
information, see Amazon RDS Application Programming Interface
(API) (p. 978), and see the Amazon Relational Database Service API
Reference.

How You Are Charged for Amazon RDS
When you use Amazon RDS, you pay only for what you use, and there are no minimum or setup fees.
You are billed according to the following criteria.
API Version 2014-10-31
4

Amazon Relational Database Service User Guide
Monitoring an Amazon RDS DB Instance

• Instance class – Pricing is based on the class (e.g., micro, small, large, xlarge) of the DB instance
consumed.
• Running time – You are billed by the instance-hour, which is equivalent to a single instance running
for an hour. For example, both a single instance running for two hours and two instances running for
one hour consume 2 instance-hours. If a DB instance runs for only part of an hour, you are charged
for a full instance-hour.
• Storage – The storage capacity that you have provisioned to your DB instance is billed per GB per
month. If you scale your provisioned storage capacity within the month, your bill will be pro-rated.
• I/O requests per month – Total number of storage I/O requests that you have made in a billing cycle.
• Backup storage – Backup storage is the storage that is associated with automated database
backups and any active database snapshots that you have taken. Increasing your backup retention
period or taking additional database snapshots increases the backup storage consumed by your
database. Amazon RDS provides backup storage up to 100% of your provisioned database storage
at no additional charge. For example, if you have 10 GB-months of provisioned database storage,
we will provide up to 10 GB-months of backup storage at no additional charge. Most databases
require less raw storage for a backup than for the primary dataset, so if you don’t keep multiple
backups, you will never pay for backup storage. Backup storage is free only for active DB instances.
• Data transfer –Internet data transfer in and out of your DB instance.
In addition to regular RDS pricing, you can purchase reserved DB instances. Reserved DB instances
let you make a one-time up-front payment for a DB instance and reserve the DB instance for a oneor three-year term at significantly lower rates. For more information on reserved DB instances, see
Working with Reserved DB Instances (p. 273)
For Amazon RDS pricing information, see the Amazon RDS product page.

Monitoring an Amazon RDS DB Instance
There are several ways that you can track the performance and health of a DB instance. You can
use the free Amazon CloudWatch service to monitor the performance and health of a DB instance;
performance charts are shown in the Amazon RDS console. You can subscribe to Amazon RDS
events to be notified when changes occur with a DB instance, DB Snapshot, DB parameter group,
or DB security group. For more information about Amazon CloudWatch, see Viewing DB Instance
Metrics (p. 291). For more information on Amazon RDS event notification, see Using Amazon RDS
Event Notification (p. 304)

What's Next?
This section introduced you to the basic infrastructure components that RDS offers. What should you
do next?

Getting Started
Create a DB instance using instructions in the Getting Started with Amazon RDS (p. 12) section.

Database Engine Specific Topics
You can review information specific to a particular DB engine in the following sections:
• Oracle on Amazon RDS (p. 737)
• MySQL on Amazon RDS (p. 650)
API Version 2014-10-31
5

Amazon Relational Database Service User Guide
Database Engine Specific Topics

• Microsoft SQL Server on Amazon RDS (p. 566)
• PostgreSQL on Amazon RDS (p. 898)
• Aurora on Amazon RDS (p. 421)
• MariaDB on Amazon RDS (p. 522)

API Version 2014-10-31
6

Amazon Relational Database Service User Guide
Sign Up for AWS

Setting Up for Amazon RDS
Before you use Amazon RDS for the first time, complete the following tasks:
1. Sign Up for AWS (p. 7)
2. Create an IAM User (p. 7)
3. Determine Requirements (p. 9)
4. Provide Access to the DB Instance in the VPC by Creating a Security Group (p. 10)

Sign Up for AWS
When you sign up for Amazon Web Services (AWS), your AWS account is automatically signed up for
all services in AWS, including Amazon RDS. You are charged only for the services that you use.
With Amazon RDS, you pay only for the resources you use. The Amazon RDS DB instance that you
create will be live (not running in a sandbox). You will incur the standard Amazon RDS usage fees
for the instance until you terminate it. For more information about Amazon RDS usage rates, see the
Amazon RDS product page. If you are a new AWS customer, you can get started with Amazon RDS
for free; for more information, see AWS Free Usage Tier.
If you have an AWS account already, skip to the next task. If you don't have an AWS account, use the
following procedure to create one.

To create an AWS account
1.
2.

Open http://aws.amazon.com/, and then choose Create an AWS Account.
Follow the online instructions.
Part of the sign-up procedure involves receiving a phone call and entering a PIN using the phone
keypad.

Note your AWS account number, because you'll need it for the next task.

Create an IAM User
Services in AWS, such as Amazon RDS, require that you provide credentials when you access them,
so that the service can determine whether you have permission to access its resources. The console
API Version 2014-10-31
7

Amazon Relational Database Service User Guide
Create an IAM User

requires your password. You can create access keys for your AWS account to access the command
line interface or API. However, we don't recommend that you access AWS using the credentials for
your AWS account; we recommend that you use AWS Identity and Access Management (IAM) instead.
Create an IAM user, and then add the user to an IAM group with administrative permissions or and
grant this user administrative permissions. You can then access AWS using a special URL and the
credentials for the IAM user.
If you signed up for AWS but have not created an IAM user for yourself, you can create one using the
IAM console.

To create a group for administrators
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Groups, and then choose Create New Group.

3.

For Group Name, type a name for your group, such as Administrators, and then choose Next
Step.

4.

In the list of policies, select the check box next to the AdministratorAccess policy. You can use
the Filter menu and the Search box to filter the list of policies.

5.

Choose Next Step, and then choose Create Group.

Your new group is listed under Group Name.

To create an IAM user for yourself, add the user to the administrators group, and create
a password for the user
1.

In the navigation pane, choose Users, and then choose Create New Users.

2.

In box 1, type a user name.

3.

Clear the check box next to Generate an access key for each user.

4.

Choose Create.

5.

In the list of users, choose the name (not the check box) of the user you just created. You can use
the Search box to search for the user name.

6.

Choose the Groups tab and then choose Add User to Groups.

7.

Select the check box next to the administrators group. Then choose Add to Groups.

8.

Choose the Security Credentials tab. Under Sign-In Credentials, choose Manage Password.

9.

Select Assign a custom password. Then type a password in the Password and Confirm
Password boxes. When you are finished, choose Apply.

To sign in as this new IAM user, sign out of the AWS console, then use the following URL, where
your_aws_account_id is your AWS account number without the hyphens (for example, if your AWS
account number is 1234-5678-9012, your AWS account ID is 123456789012):
https://your_aws_account_id.signin.aws.amazon.com/console/

Enter the IAM user name and password that you just created. When you're signed in, the navigation
bar displays "your_user_name @ your_aws_account_id".
If you don't want the URL for your sign-in page to contain your AWS account ID, you can create an
account alias. From the IAM dashboard, click Customize and enter an alias, such as your company
name. To sign in after you create an account alias, use the following URL:
https://your_account_alias.signin.aws.amazon.com/console/

API Version 2014-10-31
8

Amazon Relational Database Service User Guide
Determine Requirements

To verify the sign-in link for IAM users for your account, open the IAM console and check under AWS
Account Alias on the dashboard.

Determine Requirements
The basic building block of Amazon RDS is the DB instance. The DB instance is where you create your
databases. A DB instance provides a network address called the Endpoint. Your applications connect
to the endpoint exposed by the DB instance whenever they need to access the databases created in
that DB instance. The information you specify when you create the DB instance controls configuration
elements such as storage, memory, database engine and version, network configuration, security, and
maintenance periods.
You must know your DB instance and network needs before you create a security group and before
you create a DB instance. For example, you must know the following:
• What are the memory and processor requirements for your application or service? You will use these
settings when you determine what DB instance class you will use when you create your DB instance.
For specifications about DB instance classes, see DB Instance Class (p. 109).
• Your DB instance is most likely in a virtual private cloud (VPC); some legacy instances are not in a
VPC, but if you are a new RDS user (two years or less) or accessing a new region, you are most
likely creating an DB instance inside a VPC. The security group rules you need to connect to a
DB instance depend on whether your DB instance is in a default VPC, in a user-defined VPC, or
outside of a VPC. For information on determining if your account has a default VPC in a region, see
Determining Whether You Are Using the EC2-VPC or EC2-Classic Platform (p. 394). The follow list
describes the rules for each VPC option:
• Default VPC — If your AWS account has a default VPC in the region, that VPC is configured to
support DB instances. If you specify the default VPC when you create the DB instance:
• You must create a VPC security group that authorizes connections from the application or
service to the Amazon RDS DB instance with the database. Note that you must use the Amazon
EC2 API or the Security Group option on the VPC Console to create VPC security groups. For
information, see Step 4: Create a VPC Security Group (p. 407).
• You must specify the default DB subnet group. If this is the first DB instance you have created
in the region, Amazon RDS will create the default DB subnet group when it creates the DB
instance.
• User-defined VPC — If you want to specify a user-defined VPC when you create a DB instance:
• You must create a VPC security group that authorizes connections from the application or
service to the Amazon RDS DB instance with the database. Note that you must use the Amazon
EC2 API or the Security Group option on the VPC Console to create VPC security groups. For
information, see Step 4: Create a VPC Security Group (p. 407)..
• The VPC must meet certain requirements in order to host DB instances, such as having at
least two subnets, each in a separate availability zone. For information, see Amazon RDS and
Amazon Virtual Private Cloud (VPC) (p. 120).
• You must specify a DB subnet group that defines which subnets in that VPC can be used by the
DB instance. For information, see the DB Subnet Group section in Working with a DB Instance
in a VPC (p. 404).
• No VPC — if your AWS account does not have a default VPC, and you do not specify a userdefined VPC:
• You must create a DB security group that authorizes connections from the devices and
Amazon RDS instances running the applications or utilities that will access the databases in the
DB instance. For more information, see Working with DB Security Groups (p. 259).
• Do you need failover support? On Amazon RDS, a standby replica of your DB instance that can be
used in the event of a failover is called a Multi-AZ deployment. If you have production workloads, you
should use a Multi-AZ deployment. For test purposes, you can usually get by with a single instance,
non-Multi-AZ deployment.
API Version 2014-10-31
9

Amazon Relational Database Service User Guide
Provide Access to the DB Instance in
the VPC by Creating a Security Group

• Does your AWS account have policies that grant the permissions needed to perform Amazon RDS
operations? If you are connecting to AWS using IAM credentials, your IAM account must have
IAM policies that grant the permissions required to perform Amazon RDS operations. For more
information, see Authentication and Access Control for Amazon RDS (p. 357).
• What TCP/IP port will your database be listening on? The firewall at some companies may block
connections to the default port for your database engine. If your company firewall blocks the default
port, choose another port for the new DB instance. Note that once you create a DB instance that
listens on a port you specify, you can change the port by modifying the DB instance.
• What region do you want your database in? Having the database close in proximity to the application
or web service could reduce network latency.
• What are your storage requirements? Do you need to use Provisioned IOPS? Amazon RDS
provides three storage types: magnetic, General Purpose (SSD), and Provisioned IOPS (input/output
operations per second) . Magnetic storage, also called standard storage, offers cost-effective storage
that is ideal for applications with light or burst I/O requirements. General purpose, SSD-backed
storage, also called gp2, can provide faster access than disk-based storage. Provisioned IOPS
storage is designed to meet the needs of I/O-intensive workloads, particularly database workloads,
that are sensitive to storage performance and consistency in random access I/O throughput. For
more information on Amazon RDS storage, see Storage for Amazon RDS (p. 410).
Once you have the information you need to create the security group and the DB instance, continue to
the next step.

Provide Access to the DB Instance in the VPC by
Creating a Security Group
Your DB instance will most likely be created in a VPC. Security groups provide access to the DB
instance in the VPC. They act as a firewall for the associated DB instance, controlling both inbound
and outbound traffic at the instance level. DB instances are created by default with a firewall and a
default security group that prevents access to the DB instance. You must therefore add rules to a
security group that enable you to connect to your DB instance. Use the network and configuration
information you determined in the previous step to create rules to allow access to your DB instance.
The security group you need to create will be a VPC security group, unless you have a legacy DB
instance not in a VPC that requires a DB security group. If you created your AWS account after March
2013, chances are very good that you have a default VPC, and your DB instance will be created in that
VPC. DB instances in a VPC require that you add rules to a VPC security group to allow access to the
instance.
For example, if you have an application that will access a database on your DB instance in a VPC, you
must add a Custom TCP rule that specifies the port range and IP addresses that application will use to
access the database. If you have an application on an Amazon EC2 instance, you can use the VPC or
EC2 security group you set up for the EC2 instance.

To create a VPC security group
1.

Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc.

2.

In the top right corner of the AWS Management Console, select the region in which you want to
create the VPC security group and the DB instance. In the list of Amazon VPC resources for that
region, it should show that you have at least one VPC and several Subnets. If it does not, you do
not have a default VPC in that region.

3.

In the navigation pane, click Security Groups.

4.

Click Create Security Group.
API Version 2014-10-31
10

Amazon Relational Database Service User Guide
Provide Access to the DB Instance in
the VPC by Creating a Security Group

5.

6.

7.

8.

In the Create Security Group window, type the Name tag, Group name, and Description
of your security group. Select the VPC that you want to create your DB instance in. Click Yes,
Create.
The VPC security group you created should still be selected. The details pane at the bottom of the
console window displays the details for the security group, and tabs for working with inbound and
outbound rules. Click the Inbound Rules tab.
On the Inbound Rules tab, click Edit. Select Custom TCP Rule from the Type list. Type the port
value you will use for your DB instance in the PortRange text box, and then type the IP address
range (CIDR value) from where you will be accessing the instance, or select a security group
name in the Source text box.
If you need to add more IP addresses or different port ranges, click Add another rule.

9. If you need to, you can use the Outbound Rules tab to add rules for outbound traffic.
10. When you have finished, click Save.
You will use the VPC security group you just created as the security group for your DB instance
when you create it. If your DB instance is not going to be in a VPC, then see the topic Working
with DB Security Groups (p. 259) to create a DB security group that you will use when you
create your DB instance.
Finally, a quick note about VPC subnets: If you use a default VPC, a default subnet group
spanning all of the VPC's subnets has already been created for you. When you use the Launch a
DB Instance wizard to create a DB instance, you can select the default VPC and use default for
the DB Subnet Group.
Once you have completed the setup requirements, you can use your requirements and the
security group you created to launch a DB instance. For information on creating a DB instance,
see the relevant documentation in the following table:
Database Engine

Relevant Documentation

Amazon Aurora

Creating a DB Cluster and Connecting to a Database on an Amazon
Aurora DB Instance (p. 12)

MariaDB

Creating a MariaDB DB Instance and Connecting to a Database on a
MariaDB DB Instance (p. 19)

Microsoft SQL Server

Creating a Microsoft SQL Server DB Instance and Connecting to a
Database on a Microsoft SQL Server DB Instance (p. 26)

MySQL

Creating a MySQL DB Instance and Connecting to a Database on a
MySQL DB Instance (p. 38)

Oracle

Creating an Oracle DB Instance and Connecting to a Database on an
Oracle DB Instance (p. 46)

PostgreSQL

Creating a PostgreSQL DB Instance and Connecting to a Database on
a PostgreSQL DB Instance (p. 55)

API Version 2014-10-31
11

Amazon Relational Database Service User Guide
Creating an Aurora DB Instance on an
Aurora Cluster and Connecting to a Database

Getting Started with Amazon RDS

This section shows you how to create and connect to a DB instance using Amazon RDS. You can
create, or launch, a DB instance that uses MySQL, Oracle, PostgreSQL, Microsoft SQL Server,
Amazon Aurora, or MariaDB.

Important
You must complete the tasks in the Setting Up for Amazon RDS (p. 7) section before you can
create or connect to a DB instance.
Creating a DB instance and connecting to a database on a DB instance is slightly different for each of
the DB engines; choose the DB engine below that you want to use for detailed information on creating
and connecting to the DB instance.
• Creating a MySQL DB Instance and Connecting to a Database on a MySQL DB Instance (p. 38)
• Creating an Oracle DB Instance and Connecting to a Database on an Oracle DB Instance (p. 46)
• Creating a Microsoft SQL Server DB Instance and Connecting to a Database on a Microsoft SQL
Server DB Instance (p. 26)
• Creating a PostgreSQL DB Instance and Connecting to a Database on a PostgreSQL DB
Instance (p. 55)
• Creating a DB Cluster and Connecting to a Database on an Amazon Aurora DB Instance (p. 12)
• Creating a MariaDB DB Instance and Connecting to a Database on a MariaDB DB
Instance (p. 19)
Once you have created and connected to your DB instance, instructions are provided to help you
delete the DB instance.

Creating a DB Cluster and Connecting to a
Database on an Amazon Aurora DB Instance
The easiest way to create an Amazon Aurora DB cluster is to use the Amazon RDS console. Once
you have created the DB cluster, you can use standard MySQL utilities such as MySQL Workbench to
connect to a database on the DB cluster.
API Version 2014-10-31
12

Amazon Relational Database Service User Guide
Create a DB Cluster

Important
You must complete the tasks in the Setting Up for Amazon RDS (p. 7) section before you can
create or connect to a DB cluster.
Topics
• Create a DB Cluster (p. 13)
• Connect to an Instance in a DB Cluster (p. 18)
• Delete the Sample DB Cluster, DB Subnet Group, and VPC (p. 19)

Create a DB Cluster
Before you create a DB cluster, you must first have an Amazon Virtual Private Cloud (VPC) and an
Amazon RDS DB subnet group. Your VPC must have at least two subnets in at least two Availability
Zones. You can use the default VPC for your AWS account, or you can create your own VPC. The
Amazon RDS console makes it easy for you to create your own VPC for use with Amazon Aurora or
use an existing VPC with your Aurora DB cluster.
If you want to create a VPC and DB subnet group for use with your Amazon Aurora DB cluster
yourself, rather than having Amazon RDS create the VPC and DB subnet group for you, then follow
the instructions in How to Create a VPC for Use with Amazon Aurora (p. 443). Otherwise, follow the
instructions in this topic to create your DB cluster and have Amazon RDS create a VPC and DB subnet
group for you.

Note
All VPC and Amazon EC2 resources that you use with your Amazon Aurora DB cluster must
and must reside in the US East (N. Virginia), US West (Oregon), or EU (Ireland) regions.
To launch an Aurora DB cluster
1. Open the Amazon Aurora console at https://console.aws.amazon.com/rds.
2. In the top-right corner of the AWS Management Console, choose the region that you want to create
your DB cluster in. This example uses the US East (N. Virginia) region. Amazon Aurora is only
available in the US East (N. Virginia) (us-east-1), US West (Oregon) (us-west-2), EU (Ireland) (euwest-1), Asia Pacific (Tokyo) (ap-northeast-1), Asia Pacific (Mumbai) (ap-south-1), Asia Pacific
(Sydney) (ap-southeast-2), or Asia Pacific (Seoul) (ap-northeast-2) regions.
3. In the left navigation pane, choose Instances.
4. Choose Launch DB Instance to start the Launch DB Instance Wizard. The wizard opens on the
Select Engine page.
5. On the Select Engine page, choose the Select button for the Aurora DB engine.

API Version 2014-10-31
13

Amazon Relational Database Service User Guide
Create a DB Cluster

6. Set the following values on the Specify DB Details page:
• DB Instance Class: db.r3.large
• DB Instance Identifier: gs-db-instance1
• Master Username: Using alphanumeric characters, type a master user name, used to log on to
your DB instances in the DB cluster.
• Master Password and Confirm Password: Type a password in the Master Password box
that contains from 8 to 41 printable ASCII characters (excluding /,", and @) for your master
user password, used to log on to your database. Then type the password again in the Confirm
Password box.

API Version 2014-10-31
14

Amazon Relational Database Service User Guide
Create a DB Cluster

7. Choose Next and set the following values on the Configure Advanced Settings page:
• VPC ID: If you have an existing VPC, then you can use that VPC with your Amazon Aurora DB
cluster by choosing your VPC identifier, for example vpc-a464d1c1. For information on using an
existing VPC, see How to Create a VPC for Use with Amazon Aurora (p. 443).
Otherwise, you can choose to have Amazon RDS create a VPC for you by choosing Create a
new VPC. This example uses the Create a new VPC option.
• Subnet Group: If you have an existing subnet group, then you can use that subnet group with
your Amazon Aurora DB cluster by choosing your subnet group identifier, for example, gssubnet-group1.
Otherwise, you can choose to have Amazon RDS create a subnet group for you by choosing
Create a new subnet group. This example uses the Create a new subnet group option.
• Publicly Accessible: Yes

Note
Your production DB cluster might not need to be in a public subnet, because only your
application servers will require access to your DB cluster. If your DB cluster doesn't need
to be in a public subnet, set Publicly Accessible to No.
• Availability Zone: No Preference
• VPC Security Group(s): If you have one or more existing VPC security groups, then you can use
one or more of those VPC security groups with your Amazon Aurora DB cluster by choosing your
VPC security group identifiers, for example, gs-security-group1.

API Version 2014-10-31
15

Amazon Relational Database Service User Guide
Create a DB Cluster

Otherwise, you can choose to have Amazon RDS create a VPC security group for you by
choosing Create a new Security group. This example uses the Create a new Security group
option.
• DB Cluster Identifier: gs-db-cluster1
• Database Name: sampledb
• Database Port: 3306

Note
You might be behind a corporate firewall that does not allow access to default ports such
as the MySQL default port, 3306. In this case, provide a port value that your corporate
firewall allows. Remember that port value later when you connect to the Aurora DB
cluster.

API Version 2014-10-31
16

Amazon Relational Database Service User Guide
Create a DB Cluster

API Version 2014-10-31
17

Amazon Relational Database Service User Guide
Connect to an Instance in a DB Cluster

8. Leave the rest of the values as their defaults, and choose Launch DB Instance to create the DB
cluster and primary instance.

Connect to an Instance in a DB Cluster
Once Amazon RDS provisions your DB cluster and creates the primary instance, you can use any
standard SQL client application to connect to a database on the DB cluster. In this example, you
connect to a database on the DB cluster using MySQL monitor commands. One GUI-based application
that you can use to connect is MySQL Workbench. For more information, go to the Download MySQL
Workbench page.
To connect to a database on a DB cluster using the MySQL monitor
1. Open the Amazon Aurora console at https://console.aws.amazon.com/rds.
2. Choose Clusters and choose the DB cluster from the list to show the DB cluster details. On the
details page, copy the value for the endpoint. This endpoint is the cluster endpoint.

3. Type the following command at a command prompt on a client computer to connect to a database
on a DB cluster using the MySQL monitor. Use the cluster endpoint to connect to the primary
instance, and the master user name that you created previously (you will be prompted for a
password). If you supplied a port value other than 3306, use that for the -P parameter instead.
PROMPT> mysql -h  -P 3306 -u  -p

You will see output similar to the following.
API Version 2014-10-31
18

Amazon Relational Database Service User Guide
Delete the Sample DB Cluster,
DB Subnet Group, and VPC
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 350
Server version: 5.1.32-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

Delete the Sample DB Cluster, DB Subnet Group,
and VPC
Once you have connected to the sample DB cluster that you created, you can delete the DB cluster,
DB subnet group, and VPC (if you created a VPC).
To delete a DB cluster
1. Open the Amazon Aurora console at https://console.aws.amazon.com/rds.
2. Choose Instances and then choose the gs-db-instance1 DB instance.
3. Choose Instance Actions, and then choose Delete on the dropdown menu.
4. Choose Yes, Delete.
To delete a DB subnet group
1. Open the Amazon Aurora console at https://console.aws.amazon.com/rds.
2. Choose Subnet Groups and then choose the gs-subnet-group1 DB subnet group.
3. Choose Delete.
4. Choose Yes, Delete.
To delete a VPC
1. Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc/.
2. Choose Your VPCs and then choose the VPC that was created for this procedure.
3. Choose Delete.
4. Choose Yes, Delete.

Creating a MariaDB DB Instance and Connecting
to a Database on a MariaDB DB Instance
The easiest way to create a MariaDB DB instance is to use the Amazon RDS console. Once you have
created the DB instance, you can use command line tools such as mysql or standard graphical tools
such as HeidiSQL to connect to a database on the DB instance.

Important
You must complete the tasks in the Setting Up for Amazon RDS (p. 7) section before you can
create or connect to a DB instance.
Topics
• Creating a MariaDB Instance (p. 20)

API Version 2014-10-31
19

Amazon Relational Database Service User Guide
Creating a MariaDB Instance

• Connecting to a Database on a DB Instance Running the MariaDB Database Engine (p. 25)
• Deleting a DB Instance (p. 25)

Creating a MariaDB Instance
The basic building block of Amazon RDS is the DB instance. This environment is where you will run
your MariaDB databases.
In this example, you create a DB instance running the MariaDB database engine called east1-mariadbinstance1, with a db.t2.small DB instance class, 5 GB of storage, and automated backups enabled with
a retention period of one day.

To create a MariaDB DB instance
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the top right corner of the Amazon RDS console, choose the region in which you want to create
the DB instance.

3.

In the navigation pane, choose Instances.

4.

Choose Launch DB Instance. The Launch DB Instance Wizard opens on the Select Engine
page.

5.

On the Select Engine page, choose the MariaDB icon, and then choose Select for the MariaDB
engine.
API Version 2014-10-31
20

Amazon Relational Database Service User Guide
Creating a MariaDB Instance

6.

Next, the Production? page asks if you plan to use the DB instance you are creating for
production. Because this is an example instance, choose No. When you are finished, choose
Next.

Note
If you create a production instance, you typically choose Yes on this page to enable the
failover option Multi-AZ and the Provisioned IOPS storage option.
7.

On the Specify DB Details page, specify your DB instance information. The following table shows
settings for an example DB instance. When the settings are as you want them, choose Next.
For This Parameter

Do This

License Model

Choose the default, general-public-license, to use the
GNU General Public License, version 2 for MariaDB.
MariaDB has only one license model.

DB Engine Version

Choose the version of MariaDB that you want to use.

DB Instance Class

Choose db.t2.small for a configuration that equates to
2 GB memory, 1 ECU (1 virtual core with 1 ECU), 64-bit
platform, and moderate I/O capacity.

Multi-AZ Deployment

Choose Yes to have a standby replica of your DB
instance created in another Availability Zone for failover
support. We recommend Multi-AZ for production
workloads to maintain high availability. For development
and testing, you can choose No.
For more information, see High Availability (MultiAZ) (p. 118).

Storage Type

Choose the storage type Magnetic. For more
information about storage, see Storage for Amazon
RDS (p. 410).

Allocated Storage

Type 5 to allocate 5 GB of storage for your database.
In some cases, allocating a higher amount of storage
for your DB instance than the size of your database can
improve I/O performance. For more information about
storage allocation, see Amazon Relational Database
Service Features.

DB Instance Identifier

Type a name for the DB instance that is unique for
your account in the region you chose. You can add
some intelligence to the name, such as including the
region and DB engine you chose, for example east1mariadb-instance1.

Master Username

Type a name using 1-16 alphanumeric characters that
you will use as the master user name to log on to your
DB instance. You'll use this user name to log on to your
database on the DB instance for the first time.

Master Password and Confirm
Password

Type a password that contains from 8 to 41 printable
ASCII characters (excluding /,", and @) for your master
user password. You'll use this password with the user
name when you log on to your database. Type the
password again in the Confirm Password box.

API Version 2014-10-31
21

Amazon Relational Database Service User Guide
Creating a MariaDB Instance

8.

On the Configure Advanced Settings page, provide additional information that RDS needs to
launch the MariaDB DB instance. The table shows settings for an example DB instance. Specify
your DB instance information, then choose Launch DB Instance.
For This Parameter

Do This

VPC

Choose the name of the Amazon Virtual Private Cloud
(Amazon VPC) that will host your MariaDB DB instance.
For more information about using VPC, see Amazon
RDS and Amazon Virtual Private Cloud (VPC) (p. 120).

Availability Zone

Determine if you want to specify a particular Availability
Zone. For more information about Availability Zones, see
Regions and Availability Zones (p. 117).

VPC Security Groups

Choose the VPC security group you want to use with this
DB instance. For more information about VPC security

API Version 2014-10-31
22

Amazon Relational Database Service User Guide
Creating a MariaDB Instance

For This Parameter

Do This
groups, go to Security Groups for Your VPC in the
Amazon Virtual Private Cloud User Guide.

Database Name

Type a database name that is 1 to 64 alphanumeric
characters. If you don't provide a name, Amazon
RDS won't automatically create a database on the DB
instance you are creating.

Database Port

Leave the default value of 3306 unless you have a
specific port you want to access the database through.
MariaDB installations default to port 3306.

DB Parameter Group

Accept the default value of default.mariadb10.0 unless
you created your own DB parameter group. For more
information about parameter groups, see Working with
DB Parameter Groups (p. 243).

Option Group

Accept the default value of default.mariadb-10-0.

Copy Tags To Snapshots

Choose this option to have any DB instance tags
copied to a DB snapshot when you create a snapshot.
For more information, see Tagging Amazon RDS
Resources (p. 213).

Enable Encryption

Choose No.

Note
You usually choose Yes for production
instances to enable encryption at rest for
this DB instance. For more information, see
Encrypting Amazon RDS Resources (p. 384).
Backup Retention Period

Set the number of days you want automatic backups of
your database to be retained. For testing purposes, you
can set this value to 1.

Backup Window

Unless you have a specific time that you want to
have your database back up, use the default of No
Preference.

Enable Enhanced Monitoring

Unless you want to enable gathering metrics in real time
for the operating system that your DB instance runs on,
use the default of No.

Auto Minor Version Upgrade

Choose Yes to enable your DB instance to receive minor
DB engine version upgrades automatically when they
become available.

Maintenance Window

Choose the 30 minute window in which pending
modifications to your DB instance are applied. If the time
period doesn't matter, choose No Preference.

API Version 2014-10-31
23

Amazon Relational Database Service User Guide
Creating a MariaDB Instance

9.

On the RDS console, the new DB instance appears in the list of DB instances. The DB instance
will have a status of creating until the DB instance is created and ready for use. When the state
changes to available, you can connect to a database on the DB instance. Depending on the DB
instance class and store allocated, it can take several minutes for the new DB instance to become
available.

API Version 2014-10-31
24

Amazon Relational Database Service User Guide
Connecting to a Database on a
DB Instance Running MariaDB

Connecting to a Database on a DB Instance
Running the MariaDB Database Engine
Once Amazon RDS provisions your DB instance, you can use any standard SQL client application to
connect to a database on the DB instance. In this example, you connect to a database on a MariaDB
DB instance using the mysql command-line tool. One GUI-based application you can use to connect
is HeidiSQL; for more information, go to the Download HeidiSQL page. For more information on using
MariaDB, go to the MariaDB documentation.
To connect to a database on a DB instance using the mysql command-line tool
Type the following command at a command prompt on a client computer to connect to a database
on a MariaDB DB instance. Substitute the DNS name for your DB instance for , the
master user name you used for , and provide the master password you used when
prompted for a password.
PROMPT> mysql -h  -P 3306 -u  -p 

You will see output similar to the following.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 272
Server version: 5.5.5-10.0.17-MariaDB-log MariaDB Server
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
mysql >

Deleting a DB Instance
Once you have connected to the sample DB instance that you created, you should delete the DB
instance so you are no longer charged for it.

API Version 2014-10-31
25

Amazon Relational Database Service User Guide
Creating a Microsoft SQL Server DB
Instance and Connecting to a Database

To delete a DB instance with no final DB snapshot
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

For Instances, choose the DB instance you want to delete.

3.

For Instance Actions, choose Delete.

4.

For Create final Snapshot?, choose No.

5.

Choose Yes, Delete.

Creating a Microsoft SQL Server DB Instance and
Connecting to a Database on a Microsoft SQL
Server DB Instance
The basic building block of Amazon RDS is the DB instance. This environment is where you will run
your Microsoft SQL Server databases.

Important
You must complete the tasks in the Setting Up for Amazon RDS (p. 7) section before you can
create or connect to a DB instance.
Topics
• Creating a SQL Server DB Instance (p. 26)
• Connecting to a SQL Server DB Instance Using SQL Server Management Studio (p. 34)
• Troubleshooting a Connection to a DB Instance Running SQL Server (p. 37)
• Deleting a DB Instance (p. 38)

Creating a SQL Server DB Instance
The easiest way to create a DB instance is to use the AWS Management Console. Once you have
created the DB instance, you can use standard SQL Server utilities to connect to the DB instance such
as the Microsoft SQL Server Management Studio utility.

To create a DB instance running the Microsoft SQL Server DB engine
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the top right corner of the Amazon RDS console, choose the region in which you want to create
the DB instance.

3.

In the navigation pane, choose Instances.

4.

Choose Launch DB Instance to start the Launch DB Instance Wizard.
The wizard opens on the Select Engine page.

API Version 2014-10-31
26

Amazon Relational Database Service User Guide
Creating a SQL Server DB Instance

5.

In the Launch DB Instance Wizard window, choose the SQL Server icon, then choose Select for
the SQL Server version you want to use.

API Version 2014-10-31
27

Amazon Relational Database Service User Guide
Creating a SQL Server DB Instance

6.

The Production? page asks if you are planning to use the DB instance you are creating for
production. If you are, choose Yes. If you choose Yes, the failover option Multi-AZ and the
Provisioned IOPS storage option are preselected in the following step.

7.

Choose Next to continue. The Specify DB Details page appears.

API Version 2014-10-31
28

Amazon Relational Database Service User Guide
Creating a SQL Server DB Instance

8.

On the Specify DB Details page, specify your DB instance information. The following table shows
settings for an example DB instance using SQL Server Standard Edition.
For This Parameter

Do This

License Model

Choose license-included to use the general license
agreement for Microsoft SQL Server.
For more information about license models, see
Microsoft SQL Server Licensing (p. 572).

DB Engine Version

Choose the default version of SQL Server.

DB Instance Class

Choose db.m1.small for a configuration that equates to
1.7 GB memory, 1 ECU (1 virtual core with 1 ECU), 64bit platform, and moderate I/O capacity.
For more information, see DB Instance Class (p. 109).

Time Zone

Choose a time zone for your DB instance. If you don't
choose a time zone, your DB instance uses the default
time zone.
For more information, see Local Time Zone for Microsoft
SQL Server DB Instances (p. 576).

Multi-AZ Deployment

Choose Yes to have a standby mirror of your DB
instance created in another Availability Zone for failover
support. We recommend Multi-AZ for production
workloads to maintain high availability. For development
and testing, you can choose No.
For more information, see Multi-AZ Deployments for
Microsoft SQL Server with Database Mirroring (p. 623).

Storage Type

Choose the storage type Magnetic.
For more information, see Amazon RDS Storage
Types (p. 410).

Allocated Storage

Type 200 to allocate 200 GB of storage for your
database. In some cases, allocating a higher amount
of storage for your DB instance than the size of your
database can improve I/O performance.
For more information, see Storage for Amazon
RDS (p. 410).

DB Instance Identifier

Type a name for the DB instance of 15 alphanumeric
characters or less that is unique for your account in the
region you chose. You can add some intelligence to the
name, such as including the region and DB Engine you
chose, such as sqlsv-instance1.

Master Username

Type a name that you will use as the master
user name to log on to your DB Instance with all
database privileges. The master user name is a SQL
Server Authentication login that is a member of the
processadmin, public, and setupadmin fixed server roles.

API Version 2014-10-31
29

Amazon Relational Database Service User Guide
Creating a SQL Server DB Instance

9.

For This Parameter

Do This

Master Password and Confirm
Password

Type a password that contains from 8 to 128 printable
ASCII characters (excluding /,", and @) for your master
user password, and then type it again in the Confirm
Password box.

Choose Next to continue. The Configure Advanced Settings page appears.

API Version 2014-10-31
30

Amazon Relational Database Service User Guide
Creating a SQL Server DB Instance

API Version 2014-10-31
31

Amazon Relational Database Service User Guide
Creating a SQL Server DB Instance

10. On the Configure Advanced Settings page, provide additional information that Amazon RDS
needs to launch the SQL Server DB instance. The table following shows settings for an example
DB instance.
For This Parameter

Do This

VPC

This setting depends on the platform you are on. If you
are a new customer to AWS, choose the default VPC
shown. If you are creating a DB instance on the previous
E2-Classic platform that does not use a VPC, choose
Not in VPC.
For more information, see Amazon RDS and Amazon
Virtual Private Cloud (VPC) (p. 120).

Subnet Group

This setting depends on the platform you are on. If you
are a new customer to AWS, choose default, which
will be the default DB subnet group that was created
for your account. If you are creating a DB instance on
the previous E2-Classic platform and you want your DB
instance in a specific VPC, choose the DB subnet group
you created for that VPC.

Publicly Accessible

Choose Yes to give the DB instance a public IP address,
meaning that it will be accessible outside the VPC;
otherwise, choose No, so the DB instance will only be
accessible from inside the VPC.
For more information, see Hiding a DB Instance in a
VPC from the Internet (p. 405).

Availability Zone

Use the default value of No Preference unless you want
to specify an Availability Zone.
For more information, see Regions and Availability
Zones (p. 117).

VPC Security Group

If you are a new customer to AWS, choose the default
VPC. Otherwise, choose the VPC security group you
previously created.
For more information, see Working with DB Security
Groups (p. 259).

Database Port

Leave the default value of 1433 unless you have a
specific port you want to access the database through.
SQL Server installations default to port 1433, but in
some cases a firewall might block this port. If in doubt,
ask your network administrator what port you should
use.

DB Parameter Group

Use the default value unless you have created your own
parameter group.
For more information, see Working with DB Parameter
Groups (p. 243).

API Version 2014-10-31
32

Amazon Relational Database Service User Guide
Creating a SQL Server DB Instance

For This Parameter

Do This

Option Group

Use the default value unless you have created your own
option group.
For more information, see Working with Option
Groups (p. 223).

Copy Tags To Snapshots

Select this option to have any DB instance tags copied to
a DB snapshot when you create a snapshot.
For more information, see Tagging Amazon RDS
Resources (p. 213).

Enable Encryption

Choose Yes to enable encryption at rest for this DB
instance.
For more information, see Encrypting Amazon RDS
Resources (p. 384).

Backup Retention Period

Set the number of days you want automatic backups of
your database to be retained. For testing purposes, you
can set this value to 1.
For more information, see Working With Automated
Backups (p. 148).

Backup Window

Unless you have a specific time that you want to
have your database backup, use the default of No
Preference.
For more information, see Working With Automated
Backups (p. 148).

Enable Enhanced Monitoring

Choose Yes to enable gathering metrics in real time for
the operating system that your DB instance runs on.
For more information, see Enhanced
Monitoring (p. 294).

Auto Minor Version Upgrade

Choose Yes to enable your DB instance to receive minor
DB engine version upgrades automatically when they
become available.

Maintenance Window

Choose the 30 minute window in which pending
modifications to your DB instance are applied. If you the
time period doesn't matter, choose No Preference.
For more information, see Amazon RDS Maintenance
Window (p. 128).

11. Choose Launch DB Instance.
12. On the final page of the wizard, choose Close.
13. On the RDS console, the new DB instance appears in the list of DB instances. The DB instance
will have a status of creating until the DB instance is created and ready for use. When the state
changes to available, you can connect to the DB instance. Depending on the DB instance class
and store allocated, it could take several minutes for the new instance to be available.

API Version 2014-10-31
33

Amazon Relational Database Service User Guide
Connecting to a SQL Server DB Instance
Using SQL Server Management Studio

Connecting to a SQL Server DB Instance Using
SQL Server Management Studio
This example uses the Microsoft SQL Server Management Studio utility. This utility is part of the
Microsoft SQL Server software distribution. To download a stand-alone version of this utility, go to the
Microsoft Download Center - Microsoft SQL Server Management Studio Express.

To connect to a DB Instance using Microsoft SQL Server Management Studio
1.

Find the DNS name and port for your DB Instance.
a.

Open the RDS console, then choose Instances in the left column to display a list of your DB
instances.

b.

Choose the row for your SQL Server DB instance to display the summary information for the
instance.

c.

The Endpoint field has two parts separated by a colon (:). The part before the colon is the
DNS name for the instance, the part following the colon is the port.

API Version 2014-10-31
34

Amazon Relational Database Service User Guide
Connecting to a SQL Server DB Instance
Using SQL Server Management Studio

2.

Run Microsoft SQL Server Management Studio.

3.

The Connect to Server dialog box appears.

API Version 2014-10-31
35

Amazon Relational Database Service User Guide
Connecting to a SQL Server DB Instance
Using SQL Server Management Studio

4.

In the Server type: drop-down list box, choose Database Engine.

5.

In the Server name: field, enter or paste the DNS name of the DB Instance running the Microsoft
SQL Server database engine, followed by a comma and then the port number of the DB
Instance. For example, the Server name could be: sqlsv-instance1.cg034hpkmmjt.useast-1.rds.amazonaws.com,1433.

6.

From the Authentication drop-down list box, choose SQL Server Authentication.

7.

Enter the master user name for the DB Instance in the Login: box.

8.

Enter the password for the master user in the Password: box.

9.

Choose the Connect button.
After a few moments, Microsoft SQL Server Management Studio should be connected to your DB
Instance.

10. Choose the New Query button at the top left of the SQL Server Management Studio window.
A new SQL Query window opens.

11. Type the following SQL query:
select @@VERSION

12. Choose the ! Execute button on the SQL Enterprise Manager toolbar to run the query.
You should see a version string returned from your Microsoft SQL Server DB Instance displayed in
the output window.
API Version 2014-10-31
36

Amazon Relational Database Service User Guide
Troubleshooting Connecting

Troubleshooting a Connection to a DB Instance
Running SQL Server
There are several common causes for problems when trying to connect to a DB instance using SQL
Server Management Studio:
• The access rules enforced by your local firewall and the IP addresses you authorized to access
your DB instance in the instance's security group are not in sync. If you used Microsoft SQL
Server Management Studio and you followed the settings specified in the steps above and you are
unable to connect, the problem is most likely the egress or ingress rules on your firewall. For more
information about security groups, see Amazon RDS Security Groups (p. 388).
• If you cannot send out or receive communications over the port you specified when you created
the DB instance, you will not be able to connect to the DB instance. Check with your network
administrator to determine if the port you specified for your DB instance is allowed to be used for
inbound and outbound communication.
• For newly created DB instances, you must wait for the DB instance status to be "Available" before
you can connect to the instance. Depending on the size of your DB instance, it can take up to 20
minutes before the instance is available.
Here are a few things to check if you know that you can send and receive communications through
your firewall for the port you specified when you created the DB instance.
• Could not open a connection to SQL Server - Microsoft SQL Server, Error: 53 - You must
include the port number when you specify the Server Name when using Microsoft SQL Server
Management Studio. For example, the server name for a DB instance (including the port number)
could be: sqlsvr-pdz.c6c8mdfntzgv0.region.rds.amazonaws.com,1433.

API Version 2014-10-31
37

Amazon Relational Database Service User Guide
Deleting a DB Instance

• No connection could be made because the target machine actively refused it - Microsoft SQL
Server, Error: 10061 - You were able to reach the DB instance but the connection was refused. This
is often caused by the user name or password being incorrect.

Deleting a DB Instance
Once you have connected to the sample DB instance that you created, you should delete the DB
instance so you are no longer charged for it.

To delete a DB instance with no final DB snapshot
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the Instances list, choose the DB instance you wish to delete.

3.

Choose Instance Actions, and then choose Delete from the dropdown menu.

4.

Choose No in the Create final Snapshot? drop-down list box.

5.

Choose Yes, Delete.

Creating a MySQL DB Instance and Connecting
to a Database on a MySQL DB Instance
The easiest way to create a DB instance is to use the AWS Management Console. Once you have
created the DB instance, you can use standard MySQL utilities such as MySQL Workbench to connect
to a database on the DB instance.

Important
You must complete the tasks in the Setting Up for Amazon RDS (p. 7) section before you can
create or connect to a DB instance.
Topics
• Creating a MySQL DB Instance (p. 38)
• Connecting to a Database on a DB Instance Running the MySQL Database Engine (p. 45)
• Deleting a DB Instance (p. 45)

Creating a MySQL DB Instance
The basic building block of Amazon RDS is the DB instance. This is the environment in which you will
run your MySQL databases.
In this example, you create a DB instance running the MySQL database engine called west2-mysqlinstance1, with a db.m1.small DB instance class, 5 GB of storage, and automated backups enabled
with a retention period of one day.

To create a MySQL DB instance
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the top right corner of the Amazon RDS console, choose the region in which you want to create
the DB instance.
API Version 2014-10-31
38

Amazon Relational Database Service User Guide
Creating a MySQL DB Instance

3.

In the navigation pane, choose Instances.

4.

Choose Launch DB Instance. The Launch DB Instance Wizard opens on the Select Engine
page.

5.

On the Select Engine page, choose the MySQL icon and then choose Select for the MySQL DB
engine.

6.

On the Specify DB Details page, specify your DB instance information. The following table shows
settings for an example DB instance. When the settings are as you want them, choose Next.
For This Parameter

Do This

License Model

Choose the default, general-public-license, to use
the general license agreement for MySQL. MySQL has
only one license model.

DB Engine Version

Choose the default version of MySQL. Note that Amazon
RDS supports multiple versions of MySQL in some
regions.

DB Instance Class

Choose db.m1.small for a configuration that equates
to 1.7 GB memory, 1 ECU (1 virtual core with 1 ECU),
64-bit platform, and moderate I/O capacity.

Multi-AZ Deployment

Choose Yes to have a standby replica of your DB
instance created in another Availability Zone for failover
support. We recommend Multi-AZ for production
workloads to maintain high availability. For development
and testing, you can choose No.

API Version 2014-10-31
39

Amazon Relational Database Service User Guide
Creating a MySQL DB Instance

For This Parameter

Do This
For more information, see High Availability (MultiAZ) (p. 118).

Allocated Storage

Type 5 to allocate 5 GB of storage for your database.
In some cases, allocating a higher amount of storage
for your DB instance than the size of your database can
improve I/O performance. For more information about
storage allocation, see Amazon Relational Database
Service Features.

Storage Type

Choose the storage type Magnetic. For more
information about storage, see Storage for Amazon
RDS (p. 410).

DB Instance Identifier

Type a name for the DB instance that is unique for your
account in the region you chose. You can add some
intelligence to the name, such as including the region
and DB engine you chose, for example west2-mysqlinstance1.

Master Username

Type a name using alphanumeric characters that you
will use as the master user name to log on to your DB
instance. This will be the user name you use to log on to
your database on the DB instance for the first time.

Master Password and Confirm
Password

Type a password that contains from 8 to 41 printable
ASCII characters (excluding /,", and @) for your master
user password. This will be the password you will use
when you use the user name to log on to your database.
Then type the password again in the Confirm Password
box.

API Version 2014-10-31
40

Amazon Relational Database Service User Guide
Creating a MySQL DB Instance

7.

On the Configure Advanced Settings page, provide additional information that RDS needs to
launch the MySQL DB instance. The table shows settings for an example DB instance. Specify
your DB instance information, then choose Launch DB Instance.

API Version 2014-10-31
41

Amazon Relational Database Service User Guide
Creating a MySQL DB Instance

For This Parameter

Do This

VPC

Choose the name of the Virtual Private Cloud (VPC) that
will host your MySQL DB instance. If your DB instance
will not be hosted in a VPC, choose Not in VPC. For
more information about VPC, see Amazon RDS and
Amazon Virtual Private Cloud (VPC) (p. 120).

Availability Zone

Determine if you want to specify a particular Availability
Zone. If you chose Yes for the Multi-AZ Deployment
parameter on the previous page, you will not have any
options here. For more information about Availability
Zones, see Regions and Availability Zones (p. 117).

DB Security Groups

Choose the security group you want to use with this DB
instance. For more information about security groups,
see Working with DB Security Groups (p. 259).

Database Name

Type a database name that is 1 to 64 alpha-numeric
characters. If you do not provide a name, Amazon RDS
will not automatically create a database on the DB
instance you are creating.

Database Port

Leave the default value of 3306 unless you have a
specific port you want to access the database through.
MySQL installations default to port 3306.

DB Parameter Group

Leave the default value unless you created your own
DB parameter group. For more information about
parameter groups, see Working with DB Parameter
Groups (p. 243).

Option Group

Choose the default value because this option group is
used with the MySQL version you chose on the previous
page.

Copy Tags To Snapshots

Choose this option to have any DB instance tags
copied to a DB snapshot when you create a snapshot.
For more information, see Tagging Amazon RDS
Resources (p. 213).

Enable Encryption

Choose Yes to enable encryption at rest for this DB
instance. For more information, see Encrypting Amazon
RDS Resources (p. 384).

Backup Retention Period

Set the number of days you want automatic backups of
your database to be retained. For testing purposes, you
can set this value to 1.

Backup Window

Unless you have a specific time that you want to
have your database backup, use the default of No
Preference.

Enable Enhanced Monitoring

Unless you want to enable gathering metrics in real time
for the operating system that your DB instance runs on,
use the default of No.

API Version 2014-10-31
42

Amazon Relational Database Service User Guide
Creating a MySQL DB Instance

For This Parameter

Do This

Auto Minor Version Upgrade

Choose Yes to enable your DB instance to receive minor
DB engine version upgrades automatically when they
become available.

Maintenance Window

Choose the 30 minute window in which pending
modifications to your DB instance are applied. If you the
time period doesn't matter, choose No Preference.

API Version 2014-10-31
43

Amazon Relational Database Service User Guide
Creating a MySQL DB Instance

API Version 2014-10-31
44

Amazon Relational Database Service User Guide
Connecting to a Database on a
DB Instance Running MySQL

8.

On the RDS console, the new DB instance appears in the list of DB instances. The DB instance
will have a status of creating until the DB instance is created and ready for use. When the state
changes to available, you can connect to a database on the DB instance. Depending on the
DB instance class and store allocated, it could take several minutes for the new DB instance to
become available.

Connecting to a Database on a DB Instance
Running the MySQL Database Engine
Once Amazon RDS provisions your DB instance, you can use any standard SQL client application to
connect to a database on the DB instance. In this example, you connect to a database on a MySQL
DB instance using MySQL monitor commands. One GUI-based application you can use to connect is
MySQL Workbench; for more information, go to the Download MySQL Workbench page. For more
information on using MySQL, go to the MySQL documentation.
To connect to a database on a DB instance using MySQL monitor
•

Type the following command at a command prompt on a client computer to connect to a database
on a MySQL DB instance using the MySQL monitor. Substitute the DNS name for your DB
instance for , the master user name you used for , and the master
password you used for .
PROMPT> mysql -h  -P 3306 -u  -p

You will see output similar to the following.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 350
Server version: 5.1.32-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

Deleting a DB Instance
Once you have connected to the sample DB instance that you created, you should delete the DB
instance so you are no longer charged for it.
API Version 2014-10-31
45

Amazon Relational Database Service User Guide
Creating an Oracle DB Instance
and Connecting to a Database

To delete a DB instance with no final DB snapshot
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the Instances list, choose the DB instance you wish to delete.

3.

Choose Instance Actions, and then choose Delete from the dropdown menu.

4.

Choose No in the Create final Snapshot? drop-down list box.

5.

Choose Yes, Delete.

Creating an Oracle DB Instance and Connecting
to a Database on an Oracle DB Instance
The basic building block of Amazon RDS is the DB instance. This environment is where you will run
your Microsoft SQL Server databases.

Important
You must complete the tasks in the Setting Up for Amazon RDS (p. 7) section before you can
create or connect to a DB instance.
Topics
• Creating a DB Instance Running the Oracle Database Engine (p. 46)
• Connecting to a DB Instance Running the Oracle Database Engine (p. 53)
• Deleting a DB Instance (p. 55)

Creating a DB Instance Running the Oracle
Database Engine
The easiest way to create an Oracle DB instance is to use the RDS console. Once you have created
the DB instance, you can use standard Oracle client utilities such as SQL Developer to connect to the
instance.
In the following procedure, you create a DB instance running the Oracle database engine called west2oracle1, with a db.m1.small DB instance class, 10 GB of storage, and automated backups enabled with
a retention period of one day.

To launch an Oracle DB instance
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the top right corner of the Amazon RDS console, choose the region in which you want to create
the DB instance.

3.

In the navigation pane, choose Instances.

4.

Choose Launch DB Instance to start the Launch DB Instance Wizard.
The wizard opens on the Select Engine page.

API Version 2014-10-31
46

Amazon Relational Database Service User Guide
Creating a DB Instance Running Oracle

5.

In the Launch DB Instance Wizard window, choose the Oracle icon, and then choose Select for
the Oracle version you want to use.

API Version 2014-10-31
47

Amazon Relational Database Service User Guide
Creating a DB Instance Running Oracle

6.

The Production? page asks if you are planning to use the DB instance you are creating for
production. If you are, choose Yes. If you choose Yes, the failover option Multi-AZ and the
Provisioned IOPS storage option are preselected in the following step.

7.

Choose Next to continue. The Specify DB Details page appears.

8.

On the Specify DB Details page, specify your DB instance information. The following table shows
settings for an example DB instance.
For This Parameter

Do This

License Model

Choose license-included to use the general license
agreement for Oracle. Choose bring-your-own-license
to use your existing Oracle license.
For more information, see Oracle Licensing (p. 749).

DB Engine Version

Choose the default version of Oracle.

DB Instance Class

Choose db.m3.medium for a configuration that equates
to 1.7 GB memory, 1 ECU (1 virtual core with 1 ECU),
64-bit platform, and moderate I/O capacity.
API Version 2014-10-31
48

Amazon Relational Database Service User Guide
Creating a DB Instance Running Oracle

For This Parameter

Do This
For more information, see DB Instance Class (p. 109).

Multi-AZ Deployment

Choose Yes to have a standby replica of your DB
instance created in another Availability Zone for failover
support. We recommend Multi-AZ for production
workloads to maintain high availability. For development
and testing, you can choose No.
For more information, see High Availability (MultiAZ) (p. 118).

Allocated Storage

Type 10 to allocate 10 GB of storage for your database.
In some cases, allocating a higher amount of storage
for your DB instance than the size of your database can
improve I/O performance.
For more information, see Storage for Amazon
RDS (p. 410).

Storage Type

Choose the storage type Magnetic.
For more information, see Amazon RDS Storage
Types (p. 410).

9.

DB Instance Identifier

Type a name for the DB Instance that is unique for
your account in the region you chose. You can add
some intelligence to the name, such as including the
region and DB engine you chose, for example oracleinstance1.

Master User Name

Type a name that you will use as the master user
name to log on to your DB instance with all database
privileges. This user account is used to log into the DB
instance and is granted the "DBA" role.

Master User Password and
Confirm Password

Type a password that contains from 8 to 30 printable
ASCII characters (excluding /,", and @) for your master
user password, and then type the password again in the
Confirm Password box.

Choose Next to continue. The Configure Advanced Settings page appears.

API Version 2014-10-31
49

Amazon Relational Database Service User Guide
Creating a DB Instance Running Oracle

API Version 2014-10-31
50

Amazon Relational Database Service User Guide
Creating a DB Instance Running Oracle

10. On the Configure Advanced Settings page, provide additional information that RDS needs to
launch the Oracle DB instance. The table following shows settings for an example DB instance.
For This Parameter

Do This

VPC

This setting depends on the platform you are on. If you
are a new customer to AWS, choose the default VPC.
If you are creating a DB instance on the previous E2Classic platform, choose Not in VPC.
For more information, see Amazon RDS and Amazon
Virtual Private Cloud (VPC) (p. 120).

DB Subnet Group

This setting depends on the platform you are on. If you
are a new customer to AWS, choose default, which
will be the default DB subnet group that was created
for your account. If you are creating a DB instance on
the previous E2-Classic platform and you want your DB
instance in a specific VPC, choose the DB subnet group
you created for that VPC.

Publicly Accessible

Choose Yes to give the DB instance a public IP address,
meaning that it will be accessible outside the VPC;
otherwise, choose No, so the DB instance will only be
accessible from inside the VPC.
For more information, see Hiding a DB Instance in a
VPC from the Internet (p. 405).

Availability Zone

Use the default of No Preference.
For more information, see Regions and Availability
Zones (p. 117).

VPC Security Group

If you are a new customer to AWS, choose the default
VPC. If you have created your own VPC security group,
choose the VPC security group you previously created.
For more information, see Working with DB Security
Groups (p. 259).

Database Name

Type a name for your database that begins with a letter
and contains up to 8 alpha-numeric characters. If you
do not provide a name, Amazon RDS will not create
a database on the DB instance you are creating. The
default database name is ORCL.

Database Port

Use the default value of 1521 unless you have a specific
port you want to access the database through. Oracle
installations default to port 1521, but some firewalls
block this port by default. If you are unsure, ask your
system administrator what port you should use.

Parameter Group

Use the default value of default.oracle-ee-11.2.
For more information, see Working with DB Parameter
Groups (p. 243).

API Version 2014-10-31
51

Amazon Relational Database Service User Guide
Creating a DB Instance Running Oracle

For This Parameter

Do This

Option Group

Choose the default value of default:oracle-ee-11-2.
For more information, see Working with Option
Groups (p. 223).

Copy Tags To Snapshots

Choose this option to have any DB instance tags copied
to a DB snapshot when you create a snapshot.
For more information, see Tagging Amazon RDS
Resources (p. 213).

Character Set Name

Choose the default value of AL32UTF8 for the Unicode
5.0 UTF-8 Universal character set. Note that you cannot
change the character set after the DB instance is
created.

Enable Encryption

Select Yes to enable encryption at rest for this DB
instance.
For more information, see Encrypting Amazon RDS
Resources (p. 384).

Backup Retention Period

Set the number of days you want automatic backups of
your database to be retained. For testing purposes, you
can set this value to 1.
For more information, see Working With Automated
Backups (p. 148).

Backup Window

Unless you have a specific time that you want to
have your database backup, use the default of No
Preference.
For more information, see Working With Automated
Backups (p. 148).

Enable Enhanced Monitoring

Choose Yes to enable gathering metrics in real time for
the operating system that your DB instance runs on.
For more information, see Enhanced
Monitoring (p. 294).

Auto Minor Version Upgrade

Amazon RDS does not support automatic minor version
upgrades for DB instances running Oracle. You must
modify the DB instance manually to perform a minor
version upgrade.

Maintenance Window

Choose the 30 minute window in which pending
modifications to your DB instance are applied. If you the
time period doesn't matter, choose No Preference.
For more information, see Amazon RDS Maintenance
Window (p. 128).

11. Choose Launch DB Instance.
12. On the final page of the wizard, choose Close.
13. On the RDS console, the new DB instance appears in the list of DB instances. The DB instance
will have a status of creating until the DB instance is created and ready for use. When the state
API Version 2014-10-31
52

Amazon Relational Database Service User Guide
Connecting to a DB Instance Running Oracle

changes to available, you can connect to the DB instance. Depending on the DB instance class
and store allocated, it could take several minutes for the new instance to be available.

Connecting to a DB Instance Running the Oracle
Database Engine
Once Amazon RDS provisions your DB instance, you can use any standard SQL client application to
connect to the instance. In this example, you connect to a DB instance running the Oracle database
engine using the Oracle command line tools. For more information on using Oracle, go to the Oracle
website.
This example uses the Oracle sqlplus command line utility. This utility is part of the Oracle software
distribution. To download a stand-alone version of this utility, go to the SQL*Plus User's Guide and
Reference.
1.

Open the RDS console, then choose Instances in the left column to display a list of your DB
instances.

2.

Choose the row for your Oracle DB instance to display the summary information for the instance.

3.

The Endpoint field contains part of the connection information for your DB instance. The
Endpoint field has two parts separated by a colon (:). The part before the colon is the DNS name
for the instance, the part following the colon is the port.

API Version 2014-10-31
53

Amazon Relational Database Service User Guide
Connecting to a DB Instance Running Oracle

4.

Type the following command on one line at a command prompt to connect to a DB instance using
the sqlplus utility. The value for Host will be the DNS name for your DB instance, the value for
Port will be the port you assigned the DB instance, and the value for the Oracle SID will be the
name of the DB instance's database that you specified when you created the DB instance, not the
name of the DB instance.
PROMPT>sqlplus 'mydbusr@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=)
(PORT=))(CONNECT_DATA=(SID=)))'

You will see output similar to the following.
SQL*Plus: Release 11.1.0.7.0 - Production on Wed May 25 15:13:59 2011
SQL>

API Version 2014-10-31
54

Amazon Relational Database Service User Guide
Deleting a DB Instance

Deleting a DB Instance
Once you have connected to the sample DB instance that you created, you should delete the DB
instance so you are no longer charged for it.

To delete a DB instance with no final DB snapshot
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the Instances list, choose the DB instance you wish to delete.

3.

Choose Instance Actions, and then choose Delete from the dropdown menu.

4.

Choose No in the Create final Snapshot? drop-down list box.

5.

Choose Yes, Delete.

Creating a PostgreSQL DB Instance and
Connecting to a Database on a PostgreSQL DB
Instance
The easiest way to create a DB instance is to use the RDS console. Once you have created the DB
instance, you can use standard SQL client utilities to connect to the DB instance such as the pgAdmin
utility. In this example, you create a DB instance running the PostgreSQL database engine called
west2-postgres1, with a db.m1.small DB instance class, 10 GB of storage, and automated backups
enabled with a retention period of one day.

Important
You must complete the tasks in the Setting Up for Amazon RDS (p. 7) section before you can
create or connect to a DB instance.
Topics
• Creating a PostgreSQL DB Instance (p. 55)
• Connecting to a PostgreSQL DB Instance (p. 62)
• Deleting a DB Instance (p. 65)

Creating a PostgreSQL DB Instance
To create a DB Instance Running the PostgreSQL DB Engine
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the top right corner of the AWS Management Console, choose the region in which you want to
create the DB instance.

3.

In the navigation pane, choose Instances.

4.

Choose Launch DB Instance to start the Launch DB Instance Wizard.
The wizard opens on the Select Engine page.

API Version 2014-10-31
55

Amazon Relational Database Service User Guide
Creating a PostgreSQL DB Instance

5.

On the Select Engine page, choose the PostgreSQL icon, and then choose Select.

6.

Next, the Production? page asks if you are planning to use the DB instance you are creating
for production. If you are, choose Yes. If you choose Yes, the failover option Multi-AZ and the
Provisioned IOPS storage option will be preselected in the following step. Choose Next when you
are finished.

7.

On the Specify DB Details page, specify your DB instance information. Choose Next when you
are finished.
For This Parameter

Do This

License Model

PostgreSQL has only one license model. Choose
postgresql-license to use the general license
agreement for PostgreSQL.

DB Engine Version

Choose the version of PostgreSQL you want to use.

DB Instance Class

Choose db.m1.small for a configuration that equates
to 1.7 GB memory, 1 ECU (1 virtual core with 1 ECU),
64-bit platform, and moderate I/O capacity. For more
information about all the DB instance class options, see
DB Instance Class (p. 109).

Multi-AZ Deployment

Choose Yes to have a standby replica of your DB
instance created in another Availability Zone for failover

API Version 2014-10-31
56

Amazon Relational Database Service User Guide
Creating a PostgreSQL DB Instance

For This Parameter

Do This
support. We recommend Multi-AZ for production
workloads to maintain high availability. For development
and testing, you can choose No.
For more information, see High Availability (MultiAZ) (p. 118).

Allocated Storage

Type 5 to allocate 5 GB of storage for your database.
In some cases, allocating a higher amount of storage
for your DB instance than the size of your database can
improve I/O performance. For more information about
storage allocation, see Amazon Relational Database
Service Features.

Storage Type

Choose the storage type Magnetic. For more
information about storage, see Storage for Amazon
RDS (p. 410).

DB Instance Identifier

Type a name for the DB instance that is unique for your
account in the region you chose. You can add some
intelligence to the name, such as including the region
and DB engine you chose, for example postgreSQLtest.

Master Username

Type a name using alphanumeric characters that you
will use as the master user name to log on to your
DB instance. For information on the default privileges
granted to the master user name, see Amazon RDS
PostgreSQL Planning Information (p. 900)

Master Password and Confirm
Password

Type a password that contains from 8 to 128 printable
ASCII characters (excluding /,", and @) for your master
password, then type the password again in the Confirm
Password box.

Enable Encryption

Choose Yes to enable encryption at rest for this DB
instance. For more information, see Encrypting Amazon
RDS Resources (p. 384).

API Version 2014-10-31
57

Amazon Relational Database Service User Guide
Creating a PostgreSQL DB Instance

8.

On the Configure Advanced Settings page, provide additional information that RDS needs
to launch the PostgreSQL DB instance. The table shows settings for an example DB instance.
Specify your DB instance information, then choose Launch DB Instance.
For This Parameter

Do This

VPC

This setting depends on the platform you are on. If
you are a new customer to AWS, choose the default
VPC shown. If you are creating a DB instance on the

API Version 2014-10-31
58

Amazon Relational Database Service User Guide
Creating a PostgreSQL DB Instance

For This Parameter

Do This
previous E2-Classic platform that does not use a VPC,
choose Not in VPC. For more information about VPC,
see Amazon RDS and Amazon Virtual Private Cloud
(VPC) (p. 120).

DB Subnet Group

This setting depends on the platform you are on. If you
are a new customer to AWS, choose default, which
will be the default DB subnet group that was created
for your account. If you are creating a DB instance on
the previous E2-Classic platform and you want your DB
instance in a specific VPC, choose the DB subnet group
you created for that VPC. For more information about
VPC, see Amazon RDS and Amazon Virtual Private
Cloud (VPC) (p. 120).

Publicly Accessible

Choose Yes to give the DB instance a public IP
address, meaning that it will be accessible outside
the VPC; otherwise, choose No, so the DB instance
will only be accessible from inside the VPC. For more
information about hiding DB instances from public
access, see Hiding a DB Instance in a VPC from the
Internet (p. 405).

Availability Zone

Use the default value of No Preference unless you
want to specify an Availability Zone.

VPC Security Group

If you are a new customer to AWS, choose the default
VPC. If you created a VPC security group, choose the
VPC security group you previously created.

Database Name

Type a name for your database of up to 63 alphanumeric characters. If you do not provide a name, the
default "postgres" database is created.

Database Port

Specify a port you want to use to access the database.
PostgreSQL installations default to port 5432.

Parameter Group

Use the default value unless you have created your own
parameter group.

Option Group

Use the default value unless you have created your own
option group.

Copy Tags To Snapshots

Choose this option to have any DB instance tags
copied to a DB snapshot when you create a snapshot.
For more information, see Tagging Amazon RDS
Resources (p. 213).

Backup Retention Period

Set the number of days you want automatic backups of
your database to be retained. For testing purposes, you
can set this value to 1.

Backup Window

Unless you have a specific time that you want to
have your database backup, use the default of No
Preference.

API Version 2014-10-31
59

Amazon Relational Database Service User Guide
Creating a PostgreSQL DB Instance

For This Parameter

Do This

Auto Minor Version Upgrade

Choose Yes to enable your DB instance to receive minor
DB engine version upgrades automatically when they
become available.

Maintenance Window

Choose the 30 minute window in which pending
modifications to your DB instance are applied. If you the
time period doesn't matter, choose No Preference.

API Version 2014-10-31
60

Amazon Relational Database Service User Guide
Creating a PostgreSQL DB Instance

API Version 2014-10-31
61

Amazon Relational Database Service User Guide
Connecting to a PostgreSQL DB Instance

9.

On the final page of the wizard, choose Close.

10. On the Amazon RDS console, the new DB instance appears in the list of DB instances. The
DB instance will have a status of creating until the DB instance is created and ready for use.
When the state changes to available, you can connect to the DB instance. Depending on the
DB instance class and store allocated, it could take several minutes for the new instance to be
available.

Connecting to a PostgreSQL DB Instance
After Amazon RDS provisions your DB instance, you can use any standard SQL client application to
connect to the instance. It is important to note that the security group you assigned to the DB instance
when you created it must allow access to the DB instance. If you have difficulty connecting to the DB
instance, the problem is most often with the access rules you set up in the security group you assigned
to the DB instance.
This section shows two ways to connect to a PostgreSQL DB instance. The first example uses
pgAdmin, a popular Open Source administration and development tool for PostgreSQL. You can
download and use pgAdmin without having a local instance of PostgreSQL on your client computer.
The second example uses psql, a command line utility that is part of a PostgreSQL installation. To use
psql, you must have a PostgreSQL installed on your client computer or have installed the psql client on
your machine.
In this example, you connect to a PostgreSQL DB instance using pgAdmin.

Using pgAdmin to Connect to a PostgreSQL DB Instance
To connect to a PostgreSQL DB instance using pgAdmin
1.

Launch the pgAdmin application on your client computer. You can install pgAdmin from http://
www.pgadmin.org/.

2.

Choose Add Server from the File menu.

3.

In the New Server Registration dialog box, enter the DB instance endpoint (for example,
mypostgresql.c6c8dntfzzhgv0.us-west-2.rds.amazonaws.com) in the Host box. Do not include the
colon or port number as shown on the Amazon RDS console (mypostgresql.c6c8dntfzzhgv0.uswest-2.rds.amazonaws.com:5432).
Enter the port you assigned to the DB instance into the Port box. Enter the user name and user
password you entered when you created the DB instance into the Username and Password
boxes, respectively.

API Version 2014-10-31
62

Amazon Relational Database Service User Guide
Connecting to a PostgreSQL DB Instance

4.

Choose OK.

5.

In the Object browser, expand the Server Groups. Choose the Server (the DB instance) you
created, and then choose the database name.

API Version 2014-10-31
63

Amazon Relational Database Service User Guide
Connecting to a PostgreSQL DB Instance

6.

Choose the plugin icon and choose PSQL Console. The psql command window opens for the
default database you created.

7.

Use the command window to enter SQL or psql commands. Type \q to close the window.

API Version 2014-10-31
64

Amazon Relational Database Service User Guide
Deleting a DB Instance

Using psql to Connect to a PostgreSQL DB Instance
If your client computer has PostgreSQL installed, you can use a local instance of psql to connect to a
PostgreSQL DB instance. To connect to your PostgreSQL DB instance using psql, you need to provide
host information and access credentials.
The following format is used to connect to a PostgreSQL DB instance on Amazon RDS:
psql --host= --port= --username= --password --dbname=

For example, the following command connects to a database called mypgdb on a PostgreSQL DB
instance called mypostgresql using fictitious credentials:
psql --host=mypostgresql.c6c8mwvfdgv0.us-west-2.rds.amazonaws.com --port=5432
--username=awsuser --password --dbname=mypgdb

Troubleshooting Connection Issues
By far the most common problem that occurs when attempting to connect to a database on a DB
instance is the access rules in the security group assigned to the DB instance. If you used the default
DB security group when you created the DB instance, chances are good that the security group did
not have the rules that will allow you to access the instance. For more information about Amazon RDS
security groups, see Amazon RDS Security Groups (p. 388)
The most common error is could not connect to server: Connection timed out. If you receive this error,
check that the host name is the DB instance endpoint and that the port number is correct. Check that
the security group assigned to the DB instance has the necessary rules to allow access through any
firewall your connection may be going through.

Deleting a DB Instance
Once you have connected to the sample DB instance that you created, you should delete the DB
instance so you are no longer charged for it.

To delete a DB instance with no final DB snapshot
1.
2.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.
In the Instances list, choose the DB instance you wish to delete.

3.
4.

Choose Instance Actions, and then choose Delete from the dropdown menu.
Choose No in the Create final Snapshot? drop-down list box.

5.

Choose Yes, Delete.

API Version 2014-10-31
65

Amazon Relational Database Service User Guide
Restore a DB Instance from a DB Snapshot

Tutorials

The following tutorials show you how to perform common tasks that use Amazon RDS.
Topics
• Tutorial: Restore a DB Instance from a DB Snapshot (p. 66)
• Tutorial: Create an Amazon VPC for Use with an Amazon RDS DB Instance (p. 72)
• Tutorial: Create a Web Server and an Amazon RDS Database (p. 81)
For videos, see AWS Instructional Videos and Labs.

Tutorial: Restore a DB Instance from a DB
Snapshot
A common scenario when working with Amazon RDS is to have a DB instance that you work with
occasionally but that you don't need full time. For example, you might have a quarterly customer
survey that uses an Amazon Elastic Compute Cloud (Amazon EC2) instance to host a customer survey
website and a DB instance that is used to store the survey results. One way to save money on such
a scenario is to take a DB snapshot of the DB instance after the survey is completed, delete the DB
instance, and then restore the DB instance when you need to conduct the survey again.
In the following illustration, you can see a possible scenario where an EC2 instance hosting a customer
survey website is in the same Amazon Virtual Private Cloud (Amazon VPC) as a DB instance that
retains the customer survey data. Note that each instance has its own security group; the EC2 instance
security group allows access from the Internet while the DB instance security group allows access only
to and from the EC2 instance. When the survey is done, the EC2 instance can be stopped and the
DB instance can be deleted after a final DB snapshot is created. When you need to conduct another
survey, you can restart the EC2 instance and restore the DB instance from the DB snapshot.

API Version 2014-10-31
66

Amazon Relational Database Service User Guide
Prerequisites for Restoring a DB
Instance from a DB Snapshot

For information about how to set up the needed VPC security groups for this scenario that allows the
EC2 instance to connect with the DB instance, see A DB Instance in a VPC Accessed by an EC2
Instance in the Same VPC (p. 396).
You must create a DB snapshot before you can restore a DB instance from one. When you restore the
DB instance, you provide the name of the DB snapshot to restore from, and then provide a name for
the new DB instance that is created from the restore operation. You cannot restore from a DB snapshot
to an existing DB instance; a new DB instance is created when you restore.

Prerequisites for Restoring a DB Instance from a DB
Snapshot
Some settings on the restored DB instance are reset when the instance is restored, so you must retain
the original resources to be able to restore the DB instance to its previous settings. For example, when
you restore a DB instance from a DB snapshot, the default DB parameter and a default security group
are associated with the restored instance. That association means that the default security group does
not allow access to the DB instance, and no custom parameter settings are available in the default
parameter group. You need to retain the DB parameter group and security group associated with the
DB instance that was used to create the DB snapshot.
The following are required before you can restore a DB instance from a DB snapshot:
• You must have created a DB snapshot of a DB instance before you can restore a DB instance
from that DB snapshot. For more information about creating a DB snapshot, see Creating a DB
Snapshot (p. 152).
• You must retain the parameter group and security group associated with the DB instance you
created the DB snapshot from.
• You must retain the VPC where the DB instance you made the DB snapshot from was located.
• You need to determine the correct option group for the restored DB instance:
• The option group associated with the DB snapshot that you restore from is associated with the
restored DB instance once it is created. For example, if the DB snapshot you restore from uses
Oracle Transparent Data Encryption (TDE), the restored DB instance uses the same option group,
which had the TDE option.
• You cannot use the option group associated with the original DB instance if you attempt to restore
that instance into a different VPC or into a different platform. This restriction occurs because
API Version 2014-10-31
67

Amazon Relational Database Service User Guide
Steps for Restoring a DB Instance from a DB Snapshot

when an option group is assigned to a DB instance, it is also linked to the platform that the DB
instance is on, either VPC or EC2-Classic (non-VPC). If a DB instance is in a VPC, the option
group associated with the instance is linked to that VPC.
• If you restore a DB instance into a different VPC or onto a different platform, you must either
assign the default option group to the instance, assign an option group that is linked to that VPC or
platform, or create a new option group and assign it to the DB instance. Note that with persistent
or permanent options, such as Oracle TDE, you must create a new option group that includes
the persistent or permanent option when restoring a DB instance into a different VPC. For more
information about working with option groups, see Working with Option Groups (p. 223).

Steps for Restoring a DB Instance from a DB
Snapshot
When you restore from a DB snapshot, you must first create the new DB instance as described
following.
You can restore to a different edition of the DB engine when restoring from a DB snapshot, but only if
the DB snapshot has the required storage allocated for the new edition. For example, to change from
Microsoft SQL Server Web Edition to SQL Server Standard Edition, the DB snapshot must have been
created from a SQL Server DB instance that had at least 200 GB of allocated storage, which is the
minimum allocated storage for SQL Server Standard edition.
After restoring the DB instance, you need to modify the new DB instance to use the parameter and
security group that were associated with the DB instance that the DB snapshot was created from. This
functionality is because when you restore a DB instance, only the default DB parameter and default
security groups are associated with the restored instance. The default security group does not allow
any access to your DB instance, and the default parameter group does not have any custom parameter
settings. To provide access and add custom parameter settings, you must modify the restored instance
as described in Modifying a Restored DB Instance (p. 69).
You can use the procedure following to restore from a snapshot in the AWS Management Console.

AWS Management Console
To restore a DB instance from a DB snapshot
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the navigation pane, choose Snapshots.

3.

Choose the DB snapshot that you want to restore from.

API Version 2014-10-31
68

Amazon Relational Database Service User Guide
Steps for Restoring a DB Instance from a DB Snapshot

4.

5.

6.

Choose Restore Snapshot.
The Restore DB Instance window appears.
For DB Instance Identifier, type the name you want to use for the restored DB instance. If you
are restoring from a DB instance that you deleted after you made the DB snapshot, you can use
the name of that DB instance.
Choose Restore DB Instance.

Modifying a Restored DB Instance
As soon as the restore operation is complete, you should associate the custom security group used by
the instance you restored from with any applicable custom DB parameter group that you might have.
Only the default DB parameter and security groups are associated with the restored instance. If you
want to restore the functionality of the DB instance to that of the DB instance that the snapshot was
created from, you must modify the DB instance to use the security group and parameter group used by
the previous DB instance.
You must apply any changes explicitly using the RDS console's Modify command, the
ModifyDBInstance API, or the aws rds modify-db-instance command line tool, once the DB
instance is available. We recommend that you retain parameter groups for any DB snapshots you have
so that you can associate a restored instance with the correct parameter file.
You can modify other settings on the restored DB instance. For example, you can use a different
storage type than the source DB snapshot. In this case the restoration process is slower because of
the additional work required to migrate the data to the new storage type. In the case of restoring to or
from Magnetic (Standard) storage, the migration process is the slowest, because Magnetic storage
does not have the IOPS capability of Provisioned IOPS or General Purpose (SSD) storage.
The next steps assume that your DB instance is in a VPC. If your DB instance is not in a VPC, use the
AWS Management Console to locate the DB security group you need for the DB instance.

To modify a restored DB instance to have the settings of the original DB instance
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

API Version 2014-10-31
69

Amazon Relational Database Service User Guide
Steps for Restoring a DB Instance from a DB Snapshot

2.

In the navigation pane, choose Instances.

3.

Select the DB instance created when you restored from the DB snapshot. There are two things
to notice here: The security group assigned to the DB instance is the default security group that
allows no access, and the warning message shows that there are currently no permissions that
allow inbound access.

4.

Choose Instance Actions, and then choose Modify.

5.

Select the security group that you want to use for your DB instance. If you need to add rules to
create a new security group to use with an EC2 instance, see A DB Instance in a VPC Accessed
by an EC2 Instance in the Same VPC (p. 396) for more information.

API Version 2014-10-31
70

Amazon Relational Database Service User Guide
Steps for Restoring a DB Instance from a DB Snapshot

6.

Choose Apply Immediately (at the bottom of the page).

7.

Choose Continue, and then choose Modify DB Instance.
Notice that the new security group has been applied, and that the DB instance is now authorized
for access.

API Version 2014-10-31
71

Amazon Relational Database Service User Guide
Create an Amazon VPC for Use
with an Amazon RDS DB Instance

Tutorial: Create an Amazon VPC for Use with an
Amazon RDS DB Instance
A common scenario includes an Amazon RDS DB instance in an Amazon VPC, that shares data with a
Web server that is running in the same VPC. In this tutorial you create the VPC for this scenario.
The following diagram shows this scenario. For information about other scenarios, see Scenarios for
Accessing a DB Instance in a VPC (p. 396).

API Version 2014-10-31
72

Amazon Relational Database Service User Guide
Create a VPC with Private and Public Subnets

Because your Amazon RDS DB instance only needs to be available to your web server, and not to
the public Internet, you create a VPC with both public and private subnets. The web server is hosted
in the public subnet, so that it can reach the public Internet. The Amazon RDS DB instance is hosted
in a private subnet. The web server is able to connect to the Amazon RDS DB instance because it is
hosted within the same VPC, but the Amazon RDS DB instance is not available to the public Internet,
providing greater security.
Use the following procedures to create a VPC with both public and private subnets, and corresponding
security groups.

Create a VPC with Private and Public Subnets
To create a VPC and subnets
1.

Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc/.

2.

In the top-right corner of the AWS Management Console, choose the region to create your VPC in.
This example uses the US West (Oregon) region.

3.

In the upper-left corner, choose VPC Dashboard. To begin creating a VPC, choose Start VPC
Wizard.

4.

On the Step 1: Select a VPC Configuration page, choose VPC with Public and Private
Subnets, and then choose Select.

5.

On the Step 2: VPC with Public and Private Subnets page, shown following, set these values:
• IP CIDR block: 10.0.0.0/16
• VPC name: tutorial-vpc
• Public subnet: 10.0.0.0/24
• Availability Zone (public subnet): us-west-2a
• Public subnet name: Tutorial public
• Private subnet: 10.0.1.0/24
• Availability Zone (private subnet): us-west-2a
• Private subnet name: Tutorial Private 1
API Version 2014-10-31
73

Amazon Relational Database Service User Guide
Create a VPC with Private and Public Subnets

Note
We will add a second private subnet later, Tutorial Private 2.
• Instance type: t2.micro

Note
If you do not see the Instance type box in the console, choose Use a NAT instance
instead.
• Key pair name: No key pair
• Subnet: None
• Enable DNS hostnames: Yes
• Hardware tenancy: Default

API Version 2014-10-31
74

Amazon Relational Database Service User Guide
Create a VPC with Private and Public Subnets

6.

When you're finished, choose Create VPC.

To create an additional subnet
You must have either two private subnets or two public subnets available to create an Amazon RDS
DB subnet group for an RDS DB instance to use in a VPC. Because the RDS DB instance for this
tutorial is private, add a second private subnet to the VPC before creating a subnet group.
1.

Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc/.

API Version 2014-10-31
75

Amazon Relational Database Service User Guide
Create a VPC with Private and Public Subnets

2.

To add the second private subnet to your VPC, choose VPC Dashboard, choose Subnets, and
then choose Create Subnet.

3.

On the Create Subnet page, shown following, set these values:
• Name tag: Tutorial private 2
• VPC: Choose the VPC that you created in the previous step, for example: vpc-f1b76594
(10.0.0.0/16) | tutorial-vpc
• Availability Zone: us-west-2b

Note
Choose an Availability Zone different from the one that you chose for the first private
subnet.
• CIDR block: 10.0.2.0/24

4.

When you're finished, choose Yes, Create.

5.

To ensure that the second private subnet that you created uses the same route table as the first
private subnet, choose VPC Dashboard, choose Subnets, and then choose the first private
subnet that was created for the VPC, Tutorial private 1.

6.

Below the list of subnets, choose the Route Table tab, shown following, and note the Current
Route Table value, for example: rtb-98b613fd.

API Version 2014-10-31
76

Amazon Relational Database Service User Guide
Create a VPC Security Group for a Public Web Server

7.

In the list of subnets, choose the second private subnet Tutorial private 2, and choose the
Route Table tab, shown following.

8.

If the current route table is not the same as the route table for the first private subnet, then choose
Edit. For Change to, choose the route table that you noted in a previous step, for example:
rtb-98b613fd.

9.

To save your selection, choose Save.

Create a VPC Security Group for a Public Web
Server
Next you create a security group for public access. To connect to public instances in your VPC, you
add inbound rules to your VPC security group that allow traffic to connect from the internet.

API Version 2014-10-31
77

Amazon Relational Database Service User Guide
Create a VPC Security Group for a Public Web Server

To create a VPC security group
1.

Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc/.

2.

Choose VPC Dashboard, choose Security Groups, and then choose Create Security Group.

3.

On the Create Security Group page, shown following, set these values:
• Name tag: tutorial-securitygroup
• Group name: tutorial-securitygroup
• Description: Tutorial Security Group
• VPC: Choose the VPC that you created earlier, for example: vpc-f1b76594 (10.0.0.0/16)
| tutorial-vpc

4.

To create the security group, choose Yes, Create.

To add inbound rules to the security group
1.

Determine the IP address that you will use to connect to instances in your VPC. To determine your
public IP address, you can use the service at http://checkip.amazonaws.com. If you are connecting
through an Internet service provider (ISP) or from behind your firewall without a static IP address,
you need to find out the range of IP addresses used by client computers.

Caution
If you use 0.0.0.0/0, you enable all IP addresses to access your public instances.
This approach is acceptable for a short time in a test environment, but it's unsafe for
production environments. In production, you'll authorize only a specific IP address or
range of addresses to access your instances.
2.

Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc/.

3.

Choose VPC Dashboard, choose Security Groups, and then choose the tutorialsecuritygroup security group that you created in the previous procedure.

4.

Choose the Inbound Rules tab, and then choose Edit.

5.

Set the following values for your new inbound rule to allow Secure Shell (SSH) access to your EC2
instance. If you do this, you can connect to your EC2 instance to install the web server and other
utilities, and to upload content for your web server.
API Version 2014-10-31
78

Amazon Relational Database Service User Guide
Create a VPC Security Group for a
Private Amazon RDS DB Instance

• Type: SSH (22)
• Source: The IP address or range from the prior step, for example: 203.0.113.25/32.
6.

Choose Add another rule.

7.

Set the following values for your new inbound rule to allow HTTP access to your web server, as
shown in the following illustration.
• Type: HTTP (80)
• Source: 0.0.0.0/0.

8.

To save your settings, choose Save.

Create a VPC Security Group for a Private Amazon
RDS DB Instance
To keep your Amazon RDS DB instance private, create a second security group for private access. To
connect to private instances in your VPC, you add inbound rules to your VPC security group that allow
traffic from your web server only.

To create a VPC security group
1.

Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc/.

2.

Choose VPC Dashboard, choose Security Groups, and then choose Create Security Group.

3.

On the Create Security Group page, shown following, set these values:
• Name tag: tutorial-db-securitygroup
• Group name: tutorial-db-securitygroup
• Description: Tutorial DB Instance Security Group
• VPC: Choose the VPC that you created earlier, for example: vpc-f1b76594 (10.0.0.0/16)
| tutorial-vpc

API Version 2014-10-31
79

Amazon Relational Database Service User Guide
Create a VPC Security Group for a
Private Amazon RDS DB Instance

4.

To create the security group, choose Yes, Create.

To add inbound rules to the security group
1.

Sign in to the AWS Management Console and open the Amazon VPC console at https://
console.aws.amazon.com/vpc/.

2.

Choose VPC Dashboard, choose Security Groups, and then choose the tutorial-dbsecuritygroup security group that you created in the previous procedure.

3.

Choose the Inbound Rules tab, and then choose Edit.

4.

Set the following values for your new inbound rule to allow MySQL traffic on port 3306 from your
EC2 instance. If you do this, you can connect from your web server to your DB instance to store
and retrieve data from your web application to your database.
• Type: MySQL/Aurora (3306)
• Source: The identifier of the tutorial-securitygroup security group that you created
previously in this tutorial, for example: sg-9edd5cfb.

5.

To save your settings, choose Save.

API Version 2014-10-31
80

Amazon Relational Database Service User Guide
Related Topics

Related Topics
• Virtual Private Clouds (VPCs) and Amazon RDS (p. 394)
• Tutorial: Create a Web Server and an Amazon RDS Database (p. 81)
• Tutorials (p. 66)

Tutorial: Create a Web Server and an Amazon
RDS Database
This tutorial helps you install an Apache web server with PHP, and create a MySQL database. The
web server runs on an Amazon EC2 instance using Amazon Linux, and the MySQL database is an
Amazon RDS MySQL DB instance. Both the Amazon EC2 instance and the Amazon RDS DB instance
run in a VPC based in Amazon Virtual Private Cloud service (Amazon VPC).

Note
This tutorial works with Amazon Linux and might not work for other versions of Linux such as
Ubuntu.
Before you begin this tutorial, you must have a VPC with both public and private subnets, and
corresponding security groups. If you don't have these, complete the following tutorial:
• Tutorial: Create an Amazon VPC for Use with an Amazon RDS DB Instance (p. 72)
In this tutorial, you perform the following procedures:
• Step 1: Create an RDS DB Instance (p. 81)
• Step 2: Create an EC2 Instance and Install a Web Server (p. 85)

Step 1: Create an RDS DB Instance
In this step you create an Amazon RDS MySQL DB instance that maintains the data used by a web
application.

Note
Before you begin this step, you must have a VPC with both public and private subnets, and
corresponding security groups. If you don't have these, see Tutorial: Create an Amazon VPC
for Use with an Amazon RDS DB Instance (p. 72).

To launch a MySQL DB instance
1.

Sign in to the AWS Management Console and open the Amazon RDS console at https://
console.aws.amazon.com/rds/.

2.

In the top-right corner of the AWS Management Console, choose the region in which you want to
create the DB instance. This example uses the US West (Oregon) region.

3.

Choose Instances.

4.

Choose Launch DB Instance.

5.

On the Select Engine page, shown following, choose the MySQL DB engine, and then choose
Select.

API Version 2014-10-31
81

Amazon Relational Database Service User Guide
Step 1: Create a DB Instance

6.

On the Production page, below Dev/Test, choose MySQL This instance is intended for use
outside of production, and then choose Next Step.

7.

On the Specify DB Details page, shown following, set these values:
• DB Engine Version: Use the default value.
• DB Instance Class: db.t2.micro
• Multi-AZ Deployment: No
• Storage Type: Magnetic
• Allocated Storage: 50 GB
• DB Instance Identifier: tutorial-db-instance
• Master Username: tutorial_user
• Master Password: Choose a password.
• Confirm Password: Retype the password.

API Version 2014-10-31
82

Amazon Relational Database Service User Guide
Step 1: Create a DB Instance

8.

Choose Next Step and set the following values in the Configure Advanced Settings page,
shown following:
• VPC: Choose an existing VPC, for example tutorial-vpc (vpc-f1b76594)
• Subnet group: Create a new DB Subnet Group
• Publicly Accessible: No
• Availability Zone: No Preference
• VPC Security Group(s): Choose an existing security group, for example tutorial-dbsecuritygroup
• Database Name: sample

API Version 2014-10-31
83

Amazon Relational Database Service User Guide
Step 1: Create a DB Instance

9.

To create your Amazon RDS MySQL DB instance, choose Launch DB Instance.

10. On the next page, choose View Your DB Instances to view your RDS MySQL DB instance.
11. Wait for the status of your new DB instance to show as available. Then choose the selection
box to the left of your DB instance to display the DB instance details, shown following.

API Version 2014-10-31
84

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

Make note of the endpoint for your DB instance. This endpoint shows the server name and port
that you use to connect your web server to your RDS DB instance.
To make sure your RDS MySQL DB instance is as secure as possible, verify that sources outside of
the VPC cannot connect to your RDS MySQL DB instance.

Next Step
Step 2: Create an EC2 Instance and Install a Web Server (p. 85)

Related Topics
• Tutorial: Create a Web Server and an Amazon RDS Database (p. 81)
• Tutorials (p. 66)

Step 2: Create an EC2 Instance and Install a Web
Server
In this step you create a web server to connect to the Amazon RDS DB instance that you created in
Step 1: Create an RDS DB Instance (p. 81).

Launch an EC2 Instance
First you create an Amazon EC2 instance in the public subnet of your VPC.

To launch an EC2 instance
1.

Sign in to the AWS Management Console and open the Amazon EC2 console at https://
console.aws.amazon.com/ec2/.

2.

Choose EC2 Dashboard, and then choose Launch Instance, as shown following.

API Version 2014-10-31
85

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

3.

Choose the Amazon Linux Amazon Machine Image (AMI), as shown following.

4.

Choose the t2.micro instance type, as shown following, and then choose Next: Configure
Instance Details.

API Version 2014-10-31
86

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

5.

On the Configure Instance Details page, shown following, set these values and leave the other
values as their defaults:
• Network: Choose an existing VPC, for example: vpc-f1b76594 (10.0.0.0/16) |
tutorial-vpc
• Subnet: Choose an existing public subnet, for example: subnet-fe2adba7(10.0.0.0/24)|
Tutorial-public | us-west-2a
• Auto-assign Public IP: Enable

API Version 2014-10-31
87

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

6.

Choose Next: Add Storage.

7.

On the Add Storage page, leave the default values and choose Next: Tag Instance.

8.

On the Tag Instance page, shown following, set Value for the Name tag to tutorial-webserver, and then choose Next: Configure Security Group.

API Version 2014-10-31
88

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

9.

On the Configure Security Group page, shown following, choose Select an existing security
group, and then choose an existing security group, for example: tutorial-securitygroup.
The security group must include inbound rules for SSH and HTTP access.

10. Choose Review and Launch.

API Version 2014-10-31
89

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

11. On the Review Instance Launch page, shown following, verify your settings and then choose
Launch.

12. On the Select an existing key pair or create a new key pair page, shown following, choose
Create a new key pair and set Key pair name to tutorial-key-pair. Choose Download
Key Pair, and then save the key pair file on your local machine. You use this key pair file to
connect to your EC2 instance.

API Version 2014-10-31
90

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

13. To launch your EC2 instance, choose Launch Instances. On the Launch Status page, shown
following, note the identifier for your new EC2 instance, for example: i-7abfcfb8.

API Version 2014-10-31
91

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

14. To find your instance, choose View Instances.
15. Wait until Instance Status for your instance reads as running before continuing.

Install an Apache web server with PHP
Next you connect to your EC2 instance and install the web server.

To connect to your EC2 instance and install the Apache web server with PHP
1.

To connect to the EC2 instance that you created earlier, follow the steps in Connect to Your
Instance.

2.

To get the latest bug fixes and security updates, update the software on your EC2 instance by
using the following command:

Note
The -y option installs the updates without asking for confirmation. To examine updates
before installing, omit this option.
[ec2-user ~]$ sudo yum update –y

3.

After the updates complete, install the Apache web server with the PHP software package using
the yum install command, which installs multiple software packages and related dependencies at
the same time:

API Version 2014-10-31
92

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

[ec2-user ~]$ sudo yum install -y httpd24 php56 php56-mysqlnd

4.

Start the web server with the command shown following:
[ec2-user ~]$ sudo service httpd start

You can test that your web server is properly installed and started by entering the public
DNS name of your EC2 instance in the address bar of a web browser, for example: http://
ec2-42-8-168-21.us-west-1.compute.amazonaws.com. If your web server is running, then
you see the Apache test page. If you don't see the Apache test page, then verify that your inbound
rules for the VPC security group that you created in Tutorial: Create an Amazon VPC for Use with
an Amazon RDS DB Instance (p. 72) include a rule allowing HTTP (port 80) access for the IP
address you use to connect to the web server.

Note
The Apache test page appears only when there is no content in the document root
directory, /var/www/html. After you add content to the document root directory, your
content appears at the public DNS address of your EC2 instance instead of the Apache
test page.
5.

Configure the web server to start with each system boot using the chkconfig command:
[ec2-user ~]$ sudo chkconfig httpd on

To allow ec2-user to manage files in the default root directory for your Apache web server, you need
to modify the ownership and permissions of the /var/www directory. In this tutorial, you add a group
named www to your EC2 instance, and then you give that group ownership of the /var/www directory
and add write permissions for the group. Any members of that group can then add, delete, and modify
files for the web server.

To set file permissions for the Apache web server
1.

Add the www group to your EC2 instance with the following command:
[ec2-user ~]$ sudo groupadd www

2.

Add the ec2-user user to the www group:
[ec2-user ~]$ sudo usermod -a -G www ec2-user

3.

To refresh your permissions and include the new www group, log out:
[ec2-user ~]$ exit

4.

Log back in again and verify that the www group exists with the groups command:
[ec2-user ~]$ groups
ec2-user wheel www
API Version 2014-10-31
93

Amazon Relational Database Service User Guide
Step 2: Create a Web Server

5.

Change the group ownership of the /var/www directory and its contents to the www group:
[ec2-user ~]$ sudo chown -R root:www /var/www

6.

Change the directory permissions of /var/www and its subdirectories to add group write
permissions and set the group ID on subdirectories created in the future:
[ec2-user ~]$ sudo chmod 2775 /var/www
[ec2-user ~]$ find /var/www -type d -exec sudo chmod 2775 {} +

7.

Recursively change the permissions for files in the /var/www directory and its subdirectories to
add group write permissions:
[ec2-user ~]$ find /var/www -type f -exec sudo chmod 0664 {} +

Connect your Apache web server to your RDS DB instance
Next, you add content to your Apache web server that connects to your Amazon RDS DB instance.

To add content to the Apache web server that connects to your RDS DB instance
1.

While still connected to your EC2 instance, change the directory to /var/www and create a new
subdirectory named inc:
[ec2-user ~]$ cd /var/www
[ec2-user ~]$ mkdir inc
[ec2-user ~]$ cd inc

2.

Create a new file in the inc directory named dbinfo.inc, and then edit the file by calling nano
(or the editor of your choice).
[ec2-user ~]$ >dbinfo.inc
[ec2-user ~]$ nano dbinfo.inc

3.

Add the following contents to the dbinfo.inc file, where endpoint is the endpoint of your RDS
MySQL DB instance, without the port, and master password is the master password for your
RDS MySQL DB instance.

Note
Placing the user name and password information in a folder that is not part of the
document root for your web server reduces the possibility of your security information
being exposed.


4.

Save and close the dbinfo.inc file.

5.

Change the directory to /var/www/html:
[ec2-user ~]$ cd /var/www/html

6.

Create a new file in the html directory named SamplePage.php, and then edit the file by calling
nano (or the editor of your choice).
[ec2-user ~]$ >SamplePage.php
[ec2-user ~]$ nano SamplePage.php

7.

Add the following contents to the SamplePage.php file:

Note
Placing the user name and password information in a folder that is not part of the
document root for your web server reduces the possibility of your security information
being exposed.



Sample page

API Version 2014-10-31 95 Amazon Relational Database Service User Guide Step 2: Create a Web Server
Name Address
"; echo "", "", ""; echo ""; } ?>
ID Name Address
",$query_data[0], "",$query_data[1], "",$query_data[2], "
Error adding employee data.

"); } /* Check whether the table exists and, if not, create it. */ function VerifyEmployeesTable($connection, $dbName) { if(!TableExists("Employees", $connection, $dbName)) { $query = "CREATE TABLE `Employees` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(45) DEFAULT NULL, `Address` varchar(90) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1"; if(!mysqli_query($connection, $query)) echo("

Error creating table.

"); } } /* Check for the existence of a table. */ function TableExists($tableName, $connection, $dbName) { $t = mysqli_real_escape_string($connection, $tableName); $d = mysqli_real_escape_string($connection, $dbName); $checktable = mysqli_query($connection, "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME = '$t' AND TABLE_SCHEMA = '$d'"); if(mysqli_num_rows($checktable) > 0) return true; return false; } ?> 8. Save and close the SamplePage.php file. 9. Verify that your web server successfully connects to your RDS MySQL DB instance by opening a web browser and browsing to http://EC2 instance endpoint/SamplePage.php, for example: http://ec2-55-122-41-31.us-west-2.compute.amazonaws.com/ SamplePage.php. You can use SamplePage.php to add data to your RDS MySQL DB instance. The data that you add is then displayed on the page. To make sure your RDS MySQL DB instance is as secure as possible, verify that sources outside of the VPC cannot connect to your RDS MySQL DB instance. Related Topics • Tutorial: Create a Web Server and an Amazon RDS Database (p. 81) • Tutorials (p. 66) API Version 2014-10-31 97 Amazon Relational Database Service User Guide Amazon RDS Basic Operational Guidelines Best Practices for Amazon RDS This section summarizes best practices for working with Amazon RDS. As new best practices are identified, we will keep this section up to date. Topics • Amazon RDS Basic Operational Guidelines (p. 98) • DB Instance RAM Recommendations (p. 99) • Amazon RDS Security Best Practices (p. 99) • Using Enhanced Monitoring to Identify Operating System Issues (p. 99) • Using Metrics to Identify Performance Issues (p. 100) • Best Practices for Working with MySQL Storage Engines (p. 103) • Best Practices for Working with MariaDB Storage Engines (p. 104) • Best Practices for Working with PostgreSQL (p. 105) • Best Practices for Working with SQL Server (p. 106) • Amazon RDS Best Practices Presentation Video (p. 107) Amazon RDS Basic Operational Guidelines The following are basic operational guidelines that everyone should follow when working with Amazon RDS. Note that the Amazon RDS Service Level Agreement requires that you follow these guidelines: • Monitor your memory, CPU, and storage usage. Amazon CloudWatch can be setup to notify you when usage patterns change or when you approach the capacity of your deployment, so that you can maintain system performance and availability. • Scale up your DB instance when you are approaching storage capacity limits. You should have some buffer in storage and memory to accommodate unforeseen increases in demand from your applications. • Enable automatic backups and set the backup window to occur during the daily low in write IOPS. • If your database workload requires more I/O than you have provisioned, recovery after a failover or database failure will be slow. To increase the I/O capacity of a DB instance, do any or all of the following: • Migrate to a DB instance class with High I/O capacity. • Convert from standard storage to either General Purpose or Provisioned IOPS storage, depending on how much of an increase you need. For information on available storage types, see Amazon RDS Storage Types (p. 410). API Version 2014-10-31 98 Amazon Relational Database Service User Guide DB Instance RAM Recommendations If you convert to Provisioned IOPS storage, make sure you also use a DB instance class that is optimized for Provisioned IOPS. For information on Provisioned IOPS, see Amazon RDS Provisioned IOPS Storage to Improve Performance (p. 415). • If you are already using Provisioned IOPS storage, provision additional throughput capacity. • If your client application is caching the Domain Name Service (DNS) data of your DB instances, set a time-to-live (TTL) value of less than 30 seconds. Because the underlying IP address of a DB instance can change after a failover, caching the DNS data for an extended time can lead to connection failures if your application tries to connect to an IP address that no longer is in service. • Test failover for your DB instance to understand how long the process takes for your use case and to ensure that the application that accesses your DB instance can automatically connect to the new DB instance after failover. DB Instance RAM Recommendations An Amazon RDS performance best practice is to allocate enough RAM so that your working set resides almost completely in memory. To tell if your working set is almost all in memory, check the ReadIOPS metric (using AWS CloudWatch) while the DB instance is under load. The value of ReadIOPS should be small and stable. If scaling up the DB instance class---to a class with more RAM---results in a dramatic drop in ReadIOPS, your working set was not almost completely in memory. Continue to scale up until ReadIOPS no longer drops dramatically after a scaling operation, or ReadIOPS is reduced to a very small amount. For information on monitoring a DB instance's metrics, see Viewing DB Instance Metrics (p. 291). Amazon RDS Security Best Practices Use AWS IAM accounts to control access to Amazon RDS API actions, especially actions that create, modify, or delete RDS resources such as DB instances, security groups, option groups, or parameter groups, and actions that perform common administrative actions such as backing up and restoring DB instances, or configuring Provisioned IOPS storage. • Assign an individual IAM account to each person who manages RDS resources. Do not use AWS root credentials to manage Amazon RDS resources; you should create an IAM user for everyone, including yourself. • Grant each user the minimum set of permissions required to perform his or her duties. • Use IAM groups to effectively manage permissions for multiple users. • Rotate your IAM credentials regularly. For more information about IAM, go to AWS Identity and Access Management. For information on IAM best practices, go to IAM Best Practices. Using Enhanced Monitoring to Identify Operating System Issues Amazon RDS provides metrics in real time for the operating system (OS) that your DB instance runs on. You can view the metrics for your DB instance using the console, or consume the Enhanced Monitoring JSON output from CloudWatch Logs in a monitoring system of your choice. For more information about Enhanced Monitoring, see Enhanced Monitoring (p. 294) API Version 2014-10-31 99 Amazon Relational Database Service User Guide Using Metrics to Identify Performance Issues Enhanced Monitoring is available for the following database engines: • Amazon Aurora • MariaDB • Microsoft SQL Server • MySQL version 5.5 or later • Oracle • PostgreSQL Enhanced monitoring is available for all DB instance classes except for db.t1.micro and db.m1.small. Enhanced Monitoring is available in all regions except for AWS GovCloud (US). Using Metrics to Identify Performance Issues To identify performance issues caused by insufficient resources and other common bottlenecks, you can monitor the metrics available for your Amazon RDS DB instance. Viewing Performance Metrics You should monitor performance metrics on a regular basis to see the average, maximum, and minimum values for a variety of time ranges. If you do so, you can identify when performance is degraded. You can also set Amazon CloudWatch alarms for particular metric thresholds so you are alerted if they are reached. In order to troubleshoot performance issues, it’s important to understand the baseline performance of the system. When you set up a new DB instance and get it running with a typical workload, you should capture the average, maximum, and minimum values of all of the performance metrics at a number of different intervals (for example, one hour, 24 hours, one week, two weeks) to get an idea of what is normal. It helps to get comparisons for both peak and off-peak hours of operation. You can then use this information to identify when performance is dropping below standard levels. To view performance metrics 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the left navigation pane, select Instances, and then select a DB instance. 3. Select Show Monitoring. The first eight performance metrics display. The metrics default to showing information for the current day. 4. Use the numbered buttons at top right to page through the additional metrics, or select Show All to see all metrics. 5. Select a performance metric to adjust the time range in order to see data for other than the current day. You can change the Statistic, Time Range, and Period values to adjust the information displayed. For example, to see the peak values for a metric for each day of the last two weeks, set Statistic to Maximum, Time Range to Last 2 Weeks, and Period to Day. Note Changing the Statistic, Time Range, and Period values changes them for all metrics. The updated values persist for the remainder of your session or until you change them again. You can also view performance metrics using the CLI or API. For more information, see Viewing DB Instance Metrics (p. 291). API Version 2014-10-31 100 Amazon Relational Database Service User Guide Evaluating Performance Metrics To set a CloudWatch alarm 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the left navigation pane, select Instances, and then select a DB instance. 3. Select Show Monitoring, and then select a performance metric to bring up the expanded view. 4. Select Create Alarm. 5. On the Create Alarm page, identify what email address should receive the alert by selecting a value in the Send a notification to box. Select create topic to the right of that box to create a new alarm recipient if necessary. 6. In the Whenever list, select the alarm statistic to set. 7. In the of box, select the alarm metric. 8. In the Is box and the unlabeled box to the right of it, set the alarm threshold, as shown following: 9. In the For at least box, enter the number of times that the specified threshold must be reached in order to trigger the alarm. 10. In the consecutive period(s) of box, select the period during which the threshold must have been reached in order to trigger the alarm. 11. In the Name of alarm box, enter a name for the alarm. 12. Select Create Alarm. The performance metrics page appears, and you can see the new alarm in the CloudWatch Alarms status bar. If you don't see the status bar, refresh your page. Evaluating Performance Metrics A DB instance has a number of different categories of metrics, and how to determine acceptable values depends on the metric. Categories of Metrics CPU • CPU Utilization – Percentage of computer processing capacity used. API Version 2014-10-31 101 Amazon Relational Database Service User Guide Evaluating Performance Metrics Memory • Freeable Memory – How much RAM is available on the DB instance, in megabytes. • Swap Usage – How much swap space is used by the DB instance, in megabytes. Disk space • Free Storage Space – How much disk space is not currently being used by the DB instance, in megabytes. Input/output operations • Read IOPS, Write IOPS – The average number of disk read or write operations per second. • Read Latency, Write Latency – The average time for a read or write operation in milliseconds. • Read Throughput, Write Throughput – The average number of megabytes read from or written to disk per second. • Queue Depth – The number of I/O operations that are waiting to be written to or read from disk. Network traffic • Network Receive Throughput, Network Transmit Throughput – The rate of network traffic to and from the DB instance in megabytes per second. Database connections • DB Connections – The number of client sessions that are connected to the DB instance. For more detailed individual descriptions of the performance metrics available, see Amazon RDS Dimensions and Metrics. For an idea of the acceptable values for metrics, see Acceptable Values for Metrics. Acceptable Values for Metrics Generally speaking, acceptable values for performance metrics depend on what your baseline looks like and what your application is doing. Investigate consistent or trending variances from your baseline. Advice about specific types of metrics follows: • High CPU or RAM consumption – High values for CPU or RAM consumption might be appropriate, provided that they are in keeping with your goals for your application (like throughput or concurrency) and are expected. • Disk space consumption – Investigate disk space consumption if space used is consistently at or above 85 percent of the total disk space. See if it is possible to delete data from the instance or archive data to a different system to free up space. • Network traffic – For network traffic, talk with your system administrator to understand what expected throughput is for your domain network and Internet connection. Investigate network traffic if throughput is consistently lower than expected. • Database connections – Consider constraining database connections if you see high numbers of user connections in conjunction with decreases in instance performance and response time. The best number of user connections for your DB instance will vary based on your instance class and the complexity of the operations being performed. You can determine the number of database connections by associating your DB instance with a parameter group where the User Connections parameter is set to other than 0 (unlimited). You can either use an existing parameter group or create a new one. For more information, see Working with DB Parameter Groups (p. 243). API Version 2014-10-31 102 Amazon Relational Database Service User Guide Tuning Queries • IOPS metrics – The expected values for IOPS metrics depend on disk specification and server configuration, so use your baseline to know what is typical. Investigate if values are consistently different than your baseline. For best IOPS performance, make sure your typical working set will fit into memory to minimize read and write operations. For issues with any performance metrics, one of the first things you can do to improve performance is tune the most used and most expensive queries to see if that lowers the pressure on system resources. For more information, see Tuning Queries (p. 103) If your queries are tuned and an issue persists, consider upgrading your Amazon RDS DB Instance Class (p. 109) to one with more of the resource (CPU, RAM, disk space, network bandwidth, I/O capacity) that is related to the issue you are experiencing. Tuning Queries One of the best ways to improve DB instance performance is to tune your most commonly used and most resource-intensive queries to make them less expensive to run. MySQL Query Tuning Go to Optimizing SELECT Statements in the MySQL documentation for more information on writing queries for better performance. You can also go to MySQL Performance Tuning and Optimization Resources for additional query tuning resources. Oracle Query Tuning Go to the Database SQL Tuning Guide in the Oracle documentation for more information on writing and analyzing queries for better performance. SQL Server Query Tuning Go to Analyzing a Query in the SQL Server documentation to improve queries for SQL Server DB instances. You can also use the execution-, index- and I/O-related data management views (DMVs) described in the Dynamic Management Views and Functions documentation to troubleshoot SQL Server query issues. A common aspect of query tuning is creating effective indexes. You can use the Database Engine Tuning Advisor to get potential index improvements for your DB instance. For more information, see Analyzing Your Database Workload on a DB Instance Using SQL Server Tuning Advisor (p. 644). PostgreSQL Query Tuning Go to Using EXPLAIN in the PostgreSQL documentation to learn how to analyze a query plan. You can use this information to modify a query or underlying tables in order to improve query performance. You can also go to Controlling the Planner with Explicit JOIN Clauses to get tips about how to specify joins in your query for the best performance. MariaDB Query Tuning Go to Query Optimizations in the MariaDB documentation for more information on writing queries for better performance. Best Practices for Working with MySQL Storage Engines On a MySQL DB instance, observe the following table creation limits: API Version 2014-10-31 103 Amazon Relational Database Service User Guide Best Practices for Working with MariaDB Storage Engines • You're limited to 10,000 tables if you are either using Provisioned IOPS storage, or using General Purpose storage and the instance is 200 GB or larger in size. • You’re limited to 1000 tables if you are either using standard storage, or using General Purpose storage and the instance is less than 200 GB in size. We recommend these limits because having large numbers of tables significantly increases database recovery time after a failover or database crash. If you need to create more tables than recommended, set the innodb_file_per_table parameter to 0. For more information, see Working with InnoDB Tablespaces to Improve Crash Recovery Times (p. 710) and Working with DB Parameter Groups (p. 243). For MySQL DB instances that use version 5.7.10 or greater, you can exceed these table creation limits due to improvements in InnoDB crash recovery. However, we still recommend that you take caution due to the potential performance impact of creating very large numbers of tables. On a MySQL DB instance, avoid tables in your database growing too large. Provisioned storage limits restrict the maximum size of a MySQL table file to 6 TB. Instead, partition your large tables so that file sizes are well under the 6 TB limit. This approach can also improve performance and recovery time. For more information, see MySQL File Size Limits (p. 662). The Point-In-Time Restore and snapshot restore features of Amazon RDS for MySQL require a crashrecoverable storage engine and are supported for the InnoDB storage engine only. Although MySQL supports multiple storage engines with varying capabilities, not all of them are optimized for crash recovery and data durability. For example, the MyISAM storage engine does not support reliable crash recovery and might prevent a Point-In-Time Restore or snapshot restore from working as intended. This might result in lost or corrupt data when MySQL is restarted after a crash. InnoDB is the recommended and supported storage engine for MySQL DB instances on Amazon RDS. InnoDB instances can also be migrated to Aurora, while MyISAM instances can't be migrated. However, MyISAM performs better than InnoDB if you require intense, full-text search capability. If you still choose to use MyISAM with Amazon RDS, following the steps outlined in Automated Backups with Unsupported MySQL Storage Engines (p. 123) can be helpful in certain scenarios for snapshot restore functionality. If you want to convert existing MyISAM tables to InnoDB tables, you can use the process outlined in the MySQL documentation. MyISAM and InnoDB have different strengths and weaknesses, so you should fully evaluate the impact of making this switch on your applications before doing so. In addition, Federated Storage Engine is currently not supported by Amazon RDS for MySQL. Best Practices for Working with MariaDB Storage Engines The Point-In-Time Restore and snapshot restore features of Amazon RDS for MariaDB require a crash-recoverable storage engine and are supported for the XtraDB storage engine only. Although MariaDB supports multiple storage engines with varying capabilities, not all of them are optimized for crash recovery and data durability. For example, although Aria is a crash-safe replacement for MyISAM, it might still prevent a Point-In-Time Restore or snapshot restore from working as intended. This might result in lost or corrupt data when MariaDB is restarted after a crash. XtraDB is the recommended and supported storage engine for MariaDB DB instances on Amazon RDS. If you still choose to use Aria with Amazon RDS, following the steps outlined in Automated Backups with Unsupported MariaDB Storage Engines (p. 123) can be helpful in certain scenarios for snapshot restore functionality. API Version 2014-10-31 104 Amazon Relational Database Service User Guide Best Practices for Working with PostgreSQL Best Practices for Working with PostgreSQL Two important areas where you can improve performance with PostgreSQL on Amazon RDS are when loading data into a DB instance and when using the PostgreSQL autovacuum feature. The following sections cover some of the practices we recommend for these areas. Loading Data into a PostgreSQL DB Instance When loading data into an Amazon RDS PostgreSQL DB instance, you should modify your DB instance settings and your DB parameter group values to allow for the most efficient importing of data into your DB instance. Modify your DB instance settings to the following: • Disable DB instance backups (set backup_retention to 0) • Disable Multi-AZ Modify your DB parameter group to include the following settings. You should test the parameter settings to find the most efficient settings for your DB instance: • Increase the value of the maintenance_work_mem parameter. For more information about PostgreSQL resource consumption parameters, see the PostgreSQL documentation. • Increase the value of the checkpoint_segments and checkpoint_timeout parameters to reduce the number of writes to the wal log. • Disable the synchronous_commit parameter (do not turn off FSYNC). • Disable the PostgreSQL autovacuum parameter. Use the pg_dump -Fc (compressed) or pg_restore -j (parallel) commands with these settings. Working with the fsync and full_page_writes database parameters In PostgreSQL 9.4.1 on Amazon RDS, the fsync and full_page_writes database parameters are not modifiable. Disabling the fsync and full_page_writes database parameters can lead to data corruption, so we have enabled them for you. We recommend that customers with other 9.3 DB engine versions of PostgreSQL not disable the fsync and full_page_writes parameters. Working with the PostgreSQL Autovacuum Feature The autovacuum feature for PostgreSQL databases is a feature that we strongly recommend you use to maintain the health of your PostgreSQL DB instance. Autovacuum automates the execution of the VACUUM and ANALYZE command; using autovacuum is required by PostgreSQL, not imposed by Amazon RDS, and its use is critical to good performance. The feature is enabled by default for all new Amazon RDS PostgreSQL DB instances, and the related configuration parameters are appropriately set by default. Your database administrator needs to know and understand this maintenance operation. For the PostgreSQL documentation on autovacuum, see http://www.postgresql.org/docs/current/static/routinevacuuming.html#AUTOVACUUM. Autovacuum is not a “resource free” operation, but it works in the background and yields to user operations as much as possible. When enabled, autovacuum checks for tables that have had a large API Version 2014-10-31 105 Amazon Relational Database Service User Guide Best Practices for Working with SQL Server number of updated or deleted tuples. It also protects against loss of very old data due to transaction ID wraparound. Autovacuum should not be thought of as a high-overhead operation that can be reduced to gain better performance. On the contrary, tables that have a high velocity of updates and deletes will quickly deteriorate over time if autovacuum is not run. Important Not running autovacuum can result in an eventual required outage to perform a much more intrusive vacuum operation. When an Amazon RDS PostgreSQL DB instance becomes unavailable because of an over conservative use of autovacuum, the PostgreSQL database will shut down to protect itself. At that point, Amazon RDS must perform a single-user–mode full vacuum directly on the DB instance , which can result in a multi-hour outage. Thus, we strongly recommend that you do not turn off autovacuum, which is enabled by default. The autovacuum parameters determine when and how hard autovacuum works. The autovacuum_vacuum_threshold and autovacuum_vacuum_scale_factor parameters determine when autovacuum is run. The autovacuum_max_workers, autovacuum_nap_time, autovacuum_cost_limit, and autovacuum_cost_delay parameters determine how hard autovacuum works. For more information about autovacuum, when it runs, and what parameters are required, see the PostgreSQL documentation. The following query shows the number of "dead" tuples in a table named table1 : PROMPT> select relname, n_dead_tup, last_vacuum, last_autovacuum from pg_catalog.pg_stat_all_tables where n_dead_tup > 0 and relname = ’table1' order by n_dead_tup desc; The results of the query will resemble the following: relname | n_dead_tup | last_vacuum | last_autovacuum ---------+------------+-------------+----------------tasks | 81430522 | | (1 row) Best Practices for Working with SQL Server Best practices for a Multi-AZ deployment with a SQL Server DB instance include the following: • Use Amazon RDS DB events to monitor failovers. For example, you can be notified by text message or email when a DB instance fails over. For more information about Amazon RDS events, see Using Amazon RDS Event Notification (p. 304). • If your application caches DNS values, set time to live (TTL) to less than 30 seconds. Setting TTL as so is a good practice in case there is a failover, where the IP address might change and the cached value might no longer be in service. • We recommend that you do not enable the following modes because they turn off transaction logging, which is required for Multi-AZ: • Simple recover mode • Offline mode • Read-only mode • Test to determine how long it takes for your DB instance to failover. Failover time can vary due to the type of database, the instance class, and the storage type you use. You should also test your application's ability to continue working if a failover occurs. • To shorten failover time, you should do the following: API Version 2014-10-31 106 Amazon Relational Database Service User Guide Amazon RDS Best Practices Presentation Video • Ensure that you have sufficient Provisioned IOPS allocated for your workload. Inadequate I/O can lengthen failover times. Database recovery requires I/O. • Use smaller transactions. Database recovery relies on transactions, so if you can break up large transactions into multiple smaller transactions, your failover time should be shorter. • Take into consideration that during a failover, there will be elevated latencies. As part of the failover process, Amazon RDS automatically replicates your data to a new standby instance. This replication means that new data is being committed to two different DB instances, so there might be some latency until the standby DB instance has caught up to the new primary DB instance. • Deploy your applications in all Availability Zones. If an Availability Zone does go down, your applications in the other Availability Zones will still be available. When working with a Multi-AZ deployment of SQL Server, remember that Amazon RDS mirrors all SQL Server databases on your instance. If you don't want particular databases to be mirrored, set up a separate DB instance that doesn't use Multi-AZ for those databases. Amazon RDS Best Practices Presentation Video The 2016 AWS Summit conference in Chicago included a presentation on best practices for creating and configuring a secure, highly available database instance using Amazon RDS. A video of the presentation is available here. API Version 2014-10-31 107 Amazon Relational Database Service User Guide Amazon RDS DB Instances A DB instance is an isolated database environment running in the cloud. It is the basic building block of Amazon RDS. A DB instance can contain multiple user-created databases, and can be accessed using the same client tools and applications you might use to access a stand-alone database instance. DB instances are simple to create and modify with the Amazon AWS command line tools, Amazon RDS APIs, or the AWS Management RDS Console. Note Amazon RDS supports access to databases using any standard SQL client application. Amazon RDS does not allow direct host access. You can have up to 40 Amazon RDS DB instances. Of these 40, up to 10 can be Oracle or SQL Server DB instances under the "License Included" model. All 40 DB instances can be used for MySQL, MariaDB, or PostgreSQL. You can also have 40 DB instances for SQL Server or Oracle under the "BYOL" licensing model. If your application requires more DB instances, you can request additional DB instances using the form at https://console.aws.amazon.com/support/home#/case/create? issueType=service-limit-increase&limitType=service-code-rds-instances. Each DB instance has a DB instance identifier. This customer-supplied name uniquely identifies the DB instance when interacting with the Amazon RDS API and AWS CLI commands. The DB instance identifier must be unique for that customer in an AWS region. Each DB instance supports a database engine. Amazon RDS currently supports MySQL, MariaDB, PostgreSQL, Oracle, Microsoft SQL Server, and Amazon Aurora database engines. When creating a DB instance, some database engines require that a database name be specified. A DB instance can host multiple databases, or a single Oracle database with multiple schemas. The database name value depends on the database engine: • For the MySQL and MariaDB database engines, the database name is the name of a database hosted in your DB instance. Databases hosted by the same DB instance must have a unique name within that instance. • For the Oracle database engine, database name is used to set the value of ORACLE_SID, which must be supplied when connecting to the Oracle RDS instance. • For the Microsoft SQL Server database engine, database name is not a supported parameter. • For the PostgreSQL database engine, the database name is the name of a database hosted in your DB instance. A database name is not required when creating a DB instance. Databases hosted by the same DB instance must have a unique name within that instance. API Version 2014-10-31 108 Amazon Relational Database Service User Guide DB Instance Class Amazon RDS creates a master user account for your DB instance as part of the creation process. This master user has permissions to create databases and to perform create, delete, select, update and insert operations on tables the master user creates. You must set the master user password when you create a DB instance, but you can change it at any time using the Amazon AWS command line tools, Amazon RDS APIs, or the AWS Management Console. You can also change the master user password and manage users using standard SQL commands. Topics • DB Instance Class (p. 109) • DB Instance Status (p. 115) • Regions and Availability Zones (p. 117) • High Availability (Multi-AZ) (p. 118) • Amazon RDS and Amazon Virtual Private Cloud (VPC) (p. 120) • DB Instance Backups (p. 121) • DB Instance Replication (p. 124) DB Instance Class The computation and memory capacity of a DB instance is determined by its DB instance class. You can change the CPU and memory available to a DB instance by changing its DB instance class; to change the DB instance class, you must modify the DB instance. For pricing information on DB instance classes, see Amazon RDS Pricing. The DB instance class you need depends on your processing power and memory requirements. There are DB instance classes that support both "bursty" database access and sustained access. For best practices suggestions on determining your memory needs, see DB Instance RAM Recommendations (p. 99). For more information about storage choices, see Storage for Amazon RDS (p. 410). Topics • Current Generation DB Instance Classes (p. 109) • Previous Generation DB Instance Classes (p. 113) • Specifications for All Available DB Instance Classes (p. 114) Current Generation DB Instance Classes Current generation DB instance classes include the following: Instance Type Current Generation DB Instance Classes Standard Current Generation (db.m4) (p. 110) db.m4.large | db.m4.xlarge | db.m4.2xlarge | db.m4.4xlarge | db.m4.10xlarge Memory Optimized Current Generation (db.r3) (p. 111) db.r3.large | db.r3.xlarge | db.r3.2xlarge | db.r3.4xlarge | db.r3.8xlarge Burst Capable Current db.t2.micro | db.t2.small | db.t2.medium | db.t2.large API Version 2014-10-31 109 Amazon Relational Database Service User Guide Current Generation Instance Type Current Generation DB Instance Classes Generation (db.t2) (p. 112) Standard Current Generation (db.m4) Standard Latest Generation (db.m4) instances are third generation instances that provide more computing capacity than the second generation db.m3 instance classes at a lower price. This DB instance class requires that the DB instance be in a VPC. Note The db.m4 instance classes are not available for the South America (São Paulo) or China (Beijing) regions. Current generation instance classes are available for the following DB engines: DB Engine Availability Amazon Aurora Aurora is not supported. MariaDB All versions are supported. Microsoft SQL Server Edition support is as follows: • Enterprise Edition: Not supported. • Standard Edition: Supported for db.m4.large and larger instance classes, up to db.m4.4xlarge. • Web Edition: Supported for db.m4.large and larger instance classes, up to db.m4.4xlarge. • Express Edition: Not supported. For information about Microsoft SQL Server licensing for Amazon RDS see, see Microsoft SQL Server Licensing (p. 572). MySQL MySQL version 5.5, 5.6, and 5.7 are supported. Oracle Version support is as follows: • Oracle 11g: Versions 11.2.0.4 and later are supported. • Oracle 12c: Versions 12.1.0.2 and later are supported. Edition support is as follows: • Enterprise Edition: Supported for all db.m4 instance classes including the db.m4.10xlarge instance class. • Standard Edition: Supported for db.m4.large and larger instance classes, up to db.m4.4xlarge. • Standard Edition One: Supported for db.m4.large and larger instance classes, up to db.m4.4xlarge. • Standard Edition Two: Supported for db.m4.large and larger instance classes, up to db.m4.4xlarge. For information about Oracle licensing for Amazon RDS see, see Oracle Licensing (p. 749). API Version 2014-10-31 110 Amazon Relational Database Service User Guide Current Generation DB Engine Availability PostgreSQL All versions are supported. Memory Optimized Current Generation (db.r3) Memory Optimized Current Generation (db.r3) instances are second generation instances that provide memory optimization and more computing capacity than the first generation db.m2 instance classes, at a lower price. The db.r3 DB instances classes are not available in the South America (São Paulo) region. Memory optimized instances (db.r3) are available for the following DB engines: DB Engine Availability Amazon Aurora All versions are supported. MariaDB All versions are supported. Microsoft SQL Server Edition support is as follows: • Enterprise Edition: Not supported. • Standard Edition (Bring Your Own License only): Supported for db.r3.2xlarge and smaller DB instance classes, because of the memory and CPU limitations of Standard Edition. • Web Edition: Supported for db.r3.2xlarge and smaller DB instance classes, because of the memory and CPU limitations of Web Edition. • Express Edition: Not supported. For information about Microsoft SQL Server licensing for Amazon RDS see, see Microsoft SQL Server Licensing (p. 572). MySQL MySQL version 5.5, 5.6, and 5.7 are supported. Oracle Version support is as follows: • Oracle 11g: Versions 11.2.0.4 and later are supported. • Oracle 12c: Versions 12.1.0.2 and later are supported. Edition support is as follows: • Enterprise Edition: Supported for db.r3.large and larger instance classes, up to db.r3.8xlarge. • Standard Edition: Supported for db.r3.large and larger instance classes, up to db.r3.8xlarge. • Standard Edition One: Supported for db.r3.large and larger instance classes, up to db.r3.4xlarge. • Standard Edition Two: Supported for db.r3.large and larger instance classes, up to db.r3.4xlarge. For information about Oracle licensing for Amazon RDS see, see Oracle Licensing (p. 749). PostgreSQL All versions are supported. API Version 2014-10-31 111 Amazon Relational Database Service User Guide Current Generation MySQL DB instances created after April 23, 2014, can switch to the db.r3 instance classes by modifying the DB instance just as with any other modification. MySQL DB instances running MySQL versions 5.1 or 5.5 and created before April 23, 2014, must first upgrade to MySQL version 5.6. For information on upgrading a MySQL DB instance, see Upgrading the Database Engine Version for a DB Instance (p. 135). For more information, see R3 Instances in the Amazon EC2 documentation. Oracle DB instances (Version's 11.2.0.4 and 12.1.0.2 and above) created after August 06, 2015, can switch to the db.r3 instance classes by modifying the DB instance just as with any other modification. To migrate an existing instance launched before this date, first upgrade your instance to Oracle database version 11.2.0.4 or 12.1.0.2, and then create and restore a snapshot of that database instance to a new R3 or T2 instance. Burst Capable Current Generation (db.t2) Burst Capable Current Generation (db.t2) instances are instances that provide baseline performance level with the ability to burst to full CPU usage. This DB instance class requires that the DB instance be in a VPC. If you have an existing DB instance that you want to move to the db.t2 DB instance class, note that the db.t2 DB instance class requires a VPC; if your current DB instance is not in a VPC, see Moving a DB Instance Not in a VPC into a VPC (p. 409) to find out how to move a DB instance not in a VPC into a VPC. For more information about T2 instances used with the db.t2 DB instance class, see T2 Instances in the Amazon EC2 documentation. DB Engine Availability Amazon Aurora Aurora is not supported. MariaDB All versions are supported. Microsoft SQL Server Edition support is as follows: • Enterprise Edition: Supported for Bring Your Own License only. • Standard Edition: Supported for Bring Your Own License only. • Web Edition: Supported. • Express Edition: Supported. For information about Microsoft SQL Server licensing for Amazon RDS see, see Microsoft SQL Server Licensing (p. 572). MySQL MySQL version 5.5, 5.6, and 5.7 are supported. Oracle Version support is as follows: • Oracle 11g: Versions 11.2.0.4 and later are supported. • Oracle 12c: Versions 12.1.0.2 and later are supported. Edition support is as follows: • Enterprise Edition: Supported for Bring Your Own License only. • Standard Edition: Supported for Bring Your Own License only. • Standard Edition One: Supported. • Standard Edition Two: Supported. For information about Oracle licensing for Amazon RDS see, see Oracle Licensing (p. 749). API Version 2014-10-31 112 Amazon Relational Database Service User Guide Previous Generation DB Engine Availability PostgreSQL All versions are supported. Previous Generation DB Instance Classes Previous generation DB instance classes include the following: Instance Type Previous Generation DB Instance Classes Standard Previous Generation (db.m3) (p. 113) db.m3.medium | db.m3.large | db.m3.xlarge | db.m3.2xlarge Standard Previous Generation (db.m1) (p. 113) db.m1.small | db.m1.medium | db.m1.large | db.m1.xlarge Memory Optimized Previous Generation (db.m2) (p. 113) db.m2.xlarge | db.m2.2xlarge | db.m2.4xlarge | db.cr1.8xlarge Micro Instances db.t1.micro (db.t1.micro) (p. 113) Standard Previous Generation (db.m3) Standard Previous Generation (db.m3) instances are second generation instances that provide a balance of compute, memory, and network resources, and are a good choice for many applications. Standard Previous Generation (db.m1) Standard Previous Generation (db.m1) instances are previous generation general-purpose instances. For more information, see Instance Type in the Amazon EC2 documentation. Note that PostgreSQL version 9.5.2 does not support previous generation instance classes. Memory Optimized Previous Generation (db.m2) Memory Optimized Previous Generation (db.m2) instances are first generation memory-optimized instances. For more information, see Instance Type in the Amazon EC2 documentation. PostgreSQL version 9.5.2 does not support this instance class. Micro Instances (db.t1.micro) Micro Instances (db.t1.micro) are instances sufficient for testing that should not be used for production applications. Using a db.t1.micro instance with Oracle is a limited test configuration. If you want to use a micro DB instance class, the db.t1.micro DB instance class only supports Oracle versions 11.2.0.2, 11.2.0.3, and 12.1.0.1. PostgreSQL version 9.5.2 does not support this instance class. We recommend that you use db.t1.micro instances with Oracle to test setup and connectivity only; the system resources for a db.t1.micro instance do not meet the recommended configuration for Oracle. API Version 2014-10-31 113 Amazon Relational Database Service User Guide Specifications for All Available DB Instance Classes No Oracle options are supported on a db.t1.micro instance. For more information, see the Micro Instances topic in the Amazon EC2 documentation. Specifications for All Available DB Instance Classes The following table provides details of the Amazon RDS DB instance classes. Instance Class vCPU ECU Memory (GB) EBS Optimized Network Performance db.t1.micro 1 1 .615 No Very Low db.m1.small 1 1 1.7 No Very Low Micro Instances Standard - Current Generation (VPC only) db.m4.large 2 6.5 8 450 Mbps Moderate db.m4.xlarge 4 13 16 750 Mbps High db.m4.2xlarge 8 25.5 32 1000 Mbps High db.m4.4xlarge 16 53.5 64 2000 Mbps High db.m4.10xlarge 40 124.5 160 4000 Mbps 10 GBps Memory Optimized - Current Generation db.r3.large 2 6.5 15 No Moderate db.r3.xlarge 4 13 30.5 500 Mbps Moderate db.r3.2xlarge 8 26 61 1000 Mbps High db.r3.4xlarge 16 52 122 2000 Mbps High db.r3.8xlarge 32 104 244 No 10 Gbps Burst Capable - Current Generation (VPC only) db.t2.micro 1 1 1 No Low db.t2.small 1 1 2 No Low db.t2.medium 2 2 4 No Moderate db.t2.large 2 2 8 No Moderate Standard - Previous Generation db.m3.medium 1 3 3.75 No Moderate db.m3.large 2 6.5 7.5 No Moderate db.m3.xlarge 4 13 15 500 Mbps High db.m3.2xlarge 8 26 30 1000 Mbps High 17.1 No Memory Optimized - Previous Generation db.m2.xlarge 2 6.5 API Version 2014-10-31 114 Moderate Amazon Relational Database Service User Guide DB Instance Status Instance Class vCPU ECU Memory (GB) EBS Optimized Network Performance db.m2.2xlarge 4 13 34.2 500 Mbps Moderate db.m2.4xlarge 8 26 68.4 1000 Mbps High db.cr1.8xlarge 32 88 244 No 10 Gbps Note The table column information includes: • vCPU – A virtual CPU, or virtual central processing unit, is a unit of capacity that you can use to compare DB instance classes. Instead of purchasing or leasing a particular processor to use for several months or years, you are renting capacity by the hour. Our goal is to provide a consistent amount of CPU capacity no matter what the actual underlying hardware. • ECU – The EC2 Compute Unit provides the relative measure of the integer processing power of an Amazon EC2 instance. In order to make it easy for developers to compare CPU capacity between different instance classes, we have defined an Amazon EC2 Compute Unit. The amount of CPU that is allocated to a particular instance is expressed in terms of these EC2 Compute Units. One ECU currently provides CPU capacity equivalent to a 1.0-1.2 GHz 2007 Opteron or 2007 Xeon processor. • Memory (GB) – Specifies the RAM memory, in gigabytes, allocated to the DB instance. Note that there is often a consistent ratio between memory and vCPU. For example, the db.m1 DB instance class has the same memory to vCPU ratio as the db.m3 DB instance class, but db.m3 instance classes provide better, more consistent performance that db.m1 instances for most use cases. db.m3 instance classes are also less expensive than db.m1 instances. • EBS-optimized – DB instance uses an optimized configuration stack and provides additional, dedicated capacity for Amazon Elastic Block Store (Amazon EBS) I/O. This optimization provides the best performance for your Amazon EBS volumes by minimizing contention between Amazon EBS I/O and other traffic from your instance. For more information about Amazon EBS–optimized instances, see Amazon EBS–Optimized Instances in the Amazon EC2 documentation. • Network Performance – The network speed relative to other DB instance classes. DB Instance Status The status of a DB instance indicates the health of the instance. You can view the status of a DB instance by using the RDS console, the AWS CLI command describe-db-instances, or the API action DescribeDBInstances. Note Amazon RDS also uses another status called maintenance status, which is shown in the Maintenance column of the Amazon RDS console. This value indicates the status of any maintenance patches that need to be applied to a DB instance. Maintenance status is independent of DB instance status. For more information on maintenance status, see Updating the Operating System for a DB Instance (p. 131). DB Instance Status Description available The instance is healthy and available. backing-up The instance is currently being backed up. API Version 2014-10-31 115 Amazon Relational Database Service User Guide DB Instance Status DB Instance Status Description creating The instance is being created. The instance is inaccessible while it is being created. deleting The instance is being deleted. failed The instance has failed and Amazon RDS was unable to recover it. Perform a point-in-time restore to the latest restorable time of the instance to recover the data. inaccessible-encryptioncredentials The KMS key used to encrypt or decrypt the DB instance could not be accessed. incompatible-credentials The supplied CloudHSM username or password is incorrect. Please update the CloudHSM credentials for the DB instance. incompatible-network Amazon RDS is attempting to perform a recovery action on an instance but is unable to do so because the VPC is in a state that is preventing the action from being completed. This status can occur if, for example, all available IP addresses in a subnet were in use and Amazon RDS was unable to get an IP address for the DB instance. incompatible-option-group Amazon RDS attempted to apply an option group change but was unable to do so, and Amazon RDS was unable to roll back to the previous option group state. Consult the Recent Events list for the DB instance for more information. This status can occur if, for example, the option group contains an option such as TDE and the DB instance does not contain encrypted information. incompatible-parameters Amazon RDS was unable to start up the DB instance because the parameters specified in the instance's DB parameter group were not compatible. Revert the parameter changes or make them compatible with the instance to regain access to your instance. Consult the Recent Events list for the DB instance for more information about the incompatible parameters. incompatible-restore Amazon RDS is unable to do a point-in-time restore. Common causes for this status include using temp tables, using MyISAM tables with MySQL, or using Aria tables with MariaDB. maintenance Amazon RDS is applying a maintenance update to the DB instance. This status is used for instance-level maintenance that RDS schedules well in advance. We're evaluating ways to expose additional maintenance actions to customers through this status. modifying The instance is being modified because of a customer request to modify the instance. rebooting The instance is being rebooted because of a customer request or an Amazon RDS process that requires the rebooting of the instance. renaming The instance is being renamed because of a customer request to rename it. resetting-master-credentials The master credentials for the instance are being reset because of a customer request to reset them. API Version 2014-10-31 116 Amazon Relational Database Service User Guide Regions and Availability Zones DB Instance Status Description restore-error The DB instance encountered an error attempting to restore to a point-in-time or from a snapshot. storage-full The instance has reached its storage capacity allocation. This is a critical status and should be remedied immediately; you should scale up your storage by modifying the DB instance. Set CloudWatch alarms to warn you when storage space is getting low so you don't run into this situation. upgrading The database engine version is being upgraded. Regions and Availability Zones Amazon cloud computing resources are housed in highly available data center facilities in different areas of the world (for example, North America, Europe, and Asia). Each data center location is called a region. Each region contains multiple distinct locations called Availability Zones, or AZs. Each Availability Zone is engineered to be isolated from failures in other Availability Zones, and to provide inexpensive, lowlatency network connectivity to other zones in the same region. By launching instances in separate Availability Zones, you can protect your applications from the failure of a single location. It is important to remember that each region is completely independent. Any Amazon RDS activity you initiate (for example, creating database instances or listing available database instances) runs only in your current default region. The default region can be changed in the console, by setting the EC2_REGION environment variable, or it can be overridden by using the --region parameter with the AWS command line interface. See Configuring the AWS Command Line Interface, specifically, the sections on Environment Variables and Command Line Options for more information. Amazon RDS supports a special AWS region called AWS GovCloud (US) that is designed to allow US government agencies and customers to move more sensitive workloads into the cloud by addressing their specific regulatory and compliance requirements. For more information on AWS GovCloud (US), see the AWS GovCloud (US) home page. To create or work with an Amazon RDS DB instance in a specific region, use the corresponding regional service endpoint. Amazon RDS supports the endpoints listed in the following table. API Version 2014-10-31 117 Amazon Relational Database Service User Guide Related Topics Region Name Endpoint US East (N. Virginia) Region us-east-1 https://rds.us-east-1.amazonaws.com US West (N. California) Region us-west-1 https://rds.us-west-1.amazonaws.com US West (Oregon) Region us-west-2 https://rds.us-west-2.amazonaws.com EU (Ireland) Region eu-west-1 https://rds.eu-west-1.amazonaws.com EU (Frankfurt) Region eu-central-1 https://rds.eu-central-1.amazonaws.com Asia Pacific (Tokyo) Region ap-northeast-1 https://rds.ap-northeast-1.amazonaws.com Asia Pacific (Seoul) Region ap-northeast-2 https://rds.ap-northeast-2.amazonaws.com Asia Pacific (Singapore) Region ap-southeast-1 https://rds.ap-southeast-1.amazonaws.com Asia Pacific (Sydney) Region ap-southeast-2 https://rds.ap-southeast-2.amazonaws.com South America (Sao Paulo) Region sa-east-1 https://rds.sa-east-1.amazonaws.com China (Beijing) Region cn-north-1 https://rds.cn-north-1.amazonaws.com.cn AWS GovCloud (US) Region us-gov-west-1 https://rds.us-gov-west-1.amazonaws.com If you do not explicitly specify an endpoint, the US West (Oregon) endpoint is the default. Related Topics • Regions and Availability Zones in the Amazon Elastic Compute Cloud User Guide. • Amazon RDS DB Instances (p. 108) High Availability (Multi-AZ) Amazon RDS provides high availability and failover support for DB instances using Multi-AZ deployments. Multi-AZ deployments for Oracle, PostgreSQL, MySQL, and MariaDB DB instances use Amazon technology, while SQL Server DB instances use SQL Server Mirroring. Note Amazon Aurora stores copies of the data in a DB cluster across multiple Availability Zones in a single region, regardless of whether the instances in the DB cluster span multiple Availability Zones. For more information on Amazon Aurora, see Aurora on Amazon RDS (p. 421). In a Multi-AZ deployment, Amazon RDS automatically provisions and maintains a synchronous standby replica in a different Availability Zone. The primary DB instance is synchronously replicated across Availability Zones to a standby replica to provide data redundancy, eliminate I/O freezes, and minimize latency spikes during system backups. Running a DB instance with high availability can enhance availability during planned system maintenance, and help protect your databases against DB instance failure and Availability Zone disruption. For more information on Availability Zones, see Regions and Availability Zones (p. 117). Note The high-availability feature is not a scaling solution for read-only scenarios; you cannot use a standby replica to serve read traffic. To service read-only traffic, you should use a Read Replica. For more information, see Working with PostgreSQL, MySQL, and MariaDB Read Replicas (p. 195). API Version 2014-10-31 118 Amazon Relational Database Service User Guide Failover Process for Amazon RDS When using the BYOL licensing model, you must have a license for both the primary instance and the standby replica. Using the RDS console, you can create a Multi-AZ deployment by simply specifying Multi-AZ when creating a DB instance. You can also use the console to convert existing DB instances to Multi-AZ deployments by modifying the DB instance and specifying the Multi-AZ option. The RDS console shows the Availability Zone of the standby replica, called the secondary AZ. You can specify a Multi-AZ deployment using the CLI as well. Use the AWS CLI describe-db-instances command, or the Amazon RDS API DescribeDBInstances action to show the Availability Zone of the standby replica (called the secondary AZ). The RDS console shows the Availability Zone of the standby replica (called the secondary AZ), or you can use the AWS CLI describe-db-instances command, or the Amazon RDS API DescribeDBInstances action to find the secondary AZ. When using the BYOL licensing model, you must have a license for both the primary instance and the standby replica. DB instances using Multi-AZ deployments may have increased write and commit latency compared to a Single-AZ deployment, due to the synchronous data replication that occurs. You may have a change in latency if your deployment fails over to the standby replica, although AWS is engineered with lowlatency network connectivity between Availability Zones. For production workloads, we recommend you use Provisioned IOPS and DB instance classes (m1.large and larger) that are optimized for Provisioned IOPS for fast, consistent performance. If you have a Single-AZ deployment, and you modify it to be a Multi-AZ deployment (for engines other than SQL Server or Amazon Aurora), then Amazon RDS takes a snapshot of the primary DB instance from your deployment and restores the snapshot into another Availability Zone. Amazon RDS then sets up synchronous replication between your primary DB instance and the new instance. This action avoids downtime when you convert from Single-AZ to Multi-AZ, but you can experience a significant performance impact when first converting to Multi-AZ. This impact is more noticeable for large and write-intensive DB instances. Failover Process for Amazon RDS In the event of a planned or unplanned outage of your DB instance, Amazon RDS automatically switches to a standby replica in another Availability Zone if you have enabled Multi-AZ. The time it takes for the failover to complete depends on the database activity and other conditions at the time the primary DB instance became unavailable. Failover times are typically 60-120 seconds. However, large transactions or a lengthy recovery process can increase failover time. When the failover is complete, it can take additional time for the RDS console UI to reflect the new Availability Zone. The failover mechanism automatically changes the DNS record of the DB instance to point to the standby DB instance. As a result, you will need to re-establish any existing connections to your DB instance. Due to how the Java DNS caching mechanism works, you may need to reconfigure your JVM API Version 2014-10-31 119 Amazon Relational Database Service User Guide Amazon RDS and Amazon VPC environment. For more information on how to manage a Java application that caches DNS values in the case of a failover, see the AWS SDK for Java. Amazon RDS handles failovers automatically so you can resume database operations as quickly as possible without administrative intervention. The primary DB instance switches over automatically to the standby replica if any of the following conditions occur: • An Availability Zone outage • The primary DB instance fails • The DB instance's server type is changed • The operating system of the DB instance is undergoing software patching • A manual failover of the DB instance was initiated using Reboot with failover There are several ways to determine if your Multi-AZ DB instance has failed over: • DB event subscriptions can be setup to notify you via email or SMS that a failover has been initiated. For more information about events, see Using Amazon RDS Event Notification (p. 304) • You can view your DB events via the Amazon RDS console or APIs. • You can view the current state of your Multi-AZ deployment via the Amazon RDS console and APIs. For information on how you can respond to failovers, reduce recovery time, and other best practices for Amazon RDS, see Best Practices for Amazon RDS (p. 98). Amazon RDS and Amazon Virtual Private Cloud (VPC) Amazon RDS lets you use the Amazon Virtual Private Cloud (VPC) service to create a virtual private cloud where you can launch a DB instance. When you use a virtual private cloud, you have control over your virtual networking environment: you can select your own IP address range, create subnets, and configure routing and access control lists. The basic functionality of Amazon RDS is the same whether it is running in a VPC or not: Amazon RDS manages backups, software patching, automatic failure detection, and recovery. There is no additional cost to run your DB instance in a VPC. Amazon RDS supports two VPC platforms in each region: The EC2-Classic platform (shown as EC2,VPC in the RDS console) requires you to use the Amazon VPC service if you want to create a VPC, and the EC2-VPC platform (shown as VPC in the RDS console), which provides your AWS account with a default VPC in a region. If you are a new customer to Amazon RDS or if you are API Version 2014-10-31 120 Amazon Relational Database Service User Guide DB Instance Backups creating DB instances in a region you have not worked in before, chances are good you are on the EC2-VPC platform and that you have a default VPC. To determine which platform your account supports in a particular region, see Determining Whether You Are Using the EC2-VPC or EC2-Classic Platform (p. 394). For more information about using a VPC with Amazon RDS, see Virtual Private Clouds (VPCs) and Amazon RDS (p. 394) DB Instance Backups To back up your DB instance, Amazon RDS creates a storage volume snapshot of your DB instance. This process backs up your entire DB instance, not just individual databases. Amazon RDS provides two methods for creating these backups: automated backups and manual (customer-initiated) DB snapshots. Your Amazon RDS backup storage for each region is composed of the automated backups and manual DB snapshots for that region and is equivalent to the sum of the database storage for all instances in that region. Moving a DB snapshot to another region increases the backup storage in the destination region. For information on backup storage costs, see Amazon RDS Pricing. Automated backups automatically back up your DB instance during a specific, user-definable backup window. Amazon RDS keeps these backups for a limited period that you can specify. You can later recover your database to any point in time during this backup retention period. Manual DB snapshots are backups that you initiate and that back up your DB instance to a particular known state. You can restore to that specific state at any time. Amazon RDS keeps all manual DB snapshots until you delete them. Note During the automatic backup window, storage I/O might be briefly suspended while the backup process initializes (typically under a few seconds) and you might experience a brief period of elevated latency. No I/O suspension occurs for Multi-AZ DB deployments, because the backup is taken from the standby. Automated Backup Automated backup is an Amazon RDS feature that automatically creates a backup of your DB instance. Automated backups are enabled by default for a new DB instance. An automated backup occurs during a daily user-configurable period of time known as the preferred backup window. Backups created during the backup window are retained for a user-configurable number of days (the backup retention period). Note that if the backup requires more time than allotted to the backup window, the backup will continue to completion. Note An immediate outage will occur if you change the backup retention period from 0 to a non-zero value or from a non-zero value to 0. The preferred backup window is the user-defined period of time during which your DB Instance is backed up. Amazon RDS uses these periodic data backups in conjunction with your transaction logs to enable you to restore your DB Instance to any second during your retention period, up to the LatestRestorableTime (typically up to the last few minutes). During the backup window, storage I/ O may be briefly suspended while the backup process initializes (typically under a few seconds) and you may experience a brief period of elevated latency. There is no I/O suspension for Multi-AZ DB deployments, since the backup is taken from the standby. When the backup retention changes to a non-zero value, the first backup occurs immediately. Changing the backup retention period to 0 turns off automatic backups for the DB instance, and deletes all existing automated backups for the instance. API Version 2014-10-31 121 Amazon Relational Database Service User Guide Automated Backup If you don't specify a preferred backup window when you create the DB instance, Amazon RDS assigns a default 30-minute backup window which is selected at random from an 8-hour block of time per region. The following table lists the time blocks for each region from which the default backups windows are assigned. Region Time Block US East (N. Virginia) Region 03:00-11:00 UTC US West (N. California) Region 06:00-14:00 UTC US West (Oregon) Region 06:00-14:00 UTC EU (Ireland) Region 22:00-06:00 UTC EU (Frankfurt) Region 23:00-07:00 UTC Asia Pacific (Tokyo) Region 13:00-21:00 UTC Asia Pacific (Seoul) Region 13:00-21:00 UTC Asia Pacific (Sydney) Region 12:00-20:00 UTC Asia Pacific (Singapore) Region 14:00-22:00 UTC South America (São Paulo) Region 00:00-08:00 UTC AWS GovCloud (US) Region 03:00-11:00 UTC Changes to the backup window take effect immediately. The backup window cannot overlap with the weekly maintenance window for the DB instance. When you delete a DB instance, you can choose to have Amazon RDS create a final DB snapshot before it deletes your DB instance. By using this approach, you can keep this final DB snapshot to restore the deleted DB instance from at a later date. After the DB instance is deleted, RDS retains this final DB snapshot and all other manual DB snapshots indefinitely. However, all automated backups are deleted and cannot be recovered when you delete a DB instance. For more information on working with automated backups, see Working With Automated Backups (p. 148). Point-in-Time Recovery In addition to the daily automated backup, Amazon RDS archives database change logs. This enables you to recover your database to any point in time during the backup retention period, up to the last five minutes of database usage. Amazon RDS stores multiple copies of your data, but for Single-AZ DB instances these copies are stored in a single availability zone. If for any reason a Single-AZ DB instance becomes unusable, you can use point-in-time recovery to launch a new DB instance with the latest restorable data. For more information on working with point-in-time recovery, see Restoring a DB Instance to a Specified Time (p. 173). API Version 2014-10-31 122 Amazon Relational Database Service User Guide Automated Backup Note Multi-AZ deployments store copies of your data in different Availability Zones for greater levels of data durability. For more information on Multi-AZ deployments, see High Availability (MultiAZ) (p. 118). Automated Backups with Unsupported MySQL Storage Engines Amazon RDS automated backups and DB snapshots are currently supported for all DB engines. For the MySQL DB engine, only the InnoDB storage engine is supported; use of these features with other MySQL storage engines, including MyISAM, may lead to unreliable behavior while restoring from backups. Specifically, since storage engines like MyISAM do not support reliable crash recovery, your tables can be corrupted in the event of a crash. For this reason, we encourage you to use the InnoDB storage engine. • To convert existing MyISAM tables to InnoDB tables, you can use alter table command. For example: ALTER TABLE table_name ENGINE=innodb, ALGORITHM=COPY; • If you choose to use MyISAM, you can attempt to manually repair tables that become damaged after a crash by using the REPAIR command (see: http://dev.mysql.com/doc/refman/5.5/en/repairtable.html). However, as noted in the MySQL documentation, there is a good chance that you will not be able to recover all your data. • If you want to take a snapshot of your MyISAM tables prior to restoring, follow these steps: 1. Stop all activity to your MyISAM tables (that is, close all sessions). You can close all sessions by calling the mysql.rds_kill command for each process that is returned from the SHOW FULL PROCESSLIST command. 2. Lock and flush each of your MyISAM tables. For example, the following commands lock and flush two tables named myisam_table1 and myisam_table2: mysql> FLUSH TABLES myisam_table, myisam_table2 WITH READ LOCK; 3. Create a snapshot of your DB instance. When the snapshot has completed, release the locks and resume activity on the MyISAM tables. You can release the locks on your tables using the following command: mysql> UNLOCK TABLES; These steps force MyISAM to flush data stored in memory to disk thereby ensuring a clean start when you restore from a DB snapshot. For more information on creating a DB snapshot, see Creating a DB Snapshot (p. 152). Automated Backups with Unsupported MariaDB Storage Engines Amazon RDS automated backups and DB snapshots are currently supported for all DB engines. For the MariaDB DB engine, only the XtraDB storage engine is supported; use of these features with other MariaDB storage engines, including Aria, might lead to unreliable behavior while restoring from backups. Even though Aria is a crash-resistant alternative to MyISAM, your tables can still be corrupted in the event of a crash. For this reason, we encourage you to use the XtraDB storage engine. • To convert existing Aria tables to XtraDB tables, you can use ALTER TABLE command. For example: ALTER TABLE table_name ENGINE=xtradb, ALGORITHM=COPY; API Version 2014-10-31 123 Amazon Relational Database Service User Guide DB Snapshots • If you choose to use Aria, you can attempt to manually repair tables that become damaged after a crash by using the REPAIR TABLE command. For more information, see http://mariadb.com/kb/en/ mariadb/repair-table/. • If you want to take a snapshot of your Aria tables prior to restoring, follow these steps: 1. Stop all activity to your Aria tables (that is, close all sessions). 2. Lock and flush each of your Aria tables. 3. Create a snapshot of your DB instance. When the snapshot has completed, release the locks and resume activity on the Aria tables. These steps force Aria to flush data stored in memory to disk, thereby ensuring a clean start when you restore from a DB snapshot. DB Snapshots A DB snapshot is a user-initiated storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases.DB snapshots enable you to back up your DB instance in a known state as frequently as you wish, and then restore to that specific state at any time. DB snapshots can be created with the Amazon RDS console or the CreateDBSnapshot action in the Amazon RDS API. DB snapshots are kept until you explicitly delete them with the Amazon RDS console or the DeleteDBSnapshot action in the Amazon RDS API. For more information on working with DB snapshots, see Creating a DB Snapshot (p. 152) and Restoring From a DB Snapshot (p. 154). Related Topics • Creating a DB Snapshot (p. 152) • Restoring From a DB Snapshot (p. 154) • Copying a DB Snapshot (p. 158) • Working With Automated Backups (p. 148) DB Instance Replication Currently, you can create replicas of your DB instances in two ways. All DB instances can have a Multi-AZ deployment, where Amazon RDS automatically provisions and manages a standby replica in a different Availability Zone (independent infrastructure in a physically separate location). In the event of planned database maintenance, DB instance failure, or an Availability Zone failure, Amazon RDS will automatically failover to the standby so that database operations can resume quickly without administrative intervention. For more information on Multi-AZ deployments, see High Availability (MultiAZ) (p. 118). Amazon RDS also uses the PostgreSQL, MySQL, and MariaDB DB engines' built-in replication functionality to create a special type of DB instance called a Read Replica from a source DB instance. Updates made to the source DB instance are asynchronously copied to the Read Replica. You can reduce the load on your source DB instance by routing read queries from your applications to the Read Replica. Read Replicas allow you to elastically scale out beyond the capacity constraints of a single DB instance for read-heavy database workloads. For more information about Read Replicas, see Working with PostgreSQL, MySQL, and MariaDB Read Replicas (p. 195) API Version 2014-10-31 124 Amazon Relational Database Service User Guide Amazon RDS DB Instance Lifecycle The lifecycle of an Amazon RDS DB instance includes creating, modifying, maintaining and upgrading, performing backups and restores, rebooting, and deleting the instance. This section provides information on and links to more about these processes. Many tasks you need to perform on a DB instance, such as rebooting or renaming, are performed the same way for all DB engines. Tasks such as creating a DB instance for a specific DB engine, connecting to a DB instance, and importing data into that DB instance are all tasks that are specific to each DB engine. The following table shows the Amazon RDS operations you are most likely to use, and provides links to procedural instruction and examples. Some of these topics are in this section, and others appear in other sections of the Amazon RDS documentation. Topic Section in Amazon RDS User Guide Creating a DB instance (DB engine specific) Creating a DB Instance Running the MySQL Database Engine (p. 663) Creating a DB Instance Running the Oracle Database Engine (p. 750) Creating a DB Instance Running the PostgreSQL Database Engine (p. 918) Creating a DB Instance Running the Microsoft SQL Server Database Engine (p. 579) Creating a DB Instance Running the MariaDB Database Engine (p. 533) Backup and Restore Backing up a DB instance Backing Up and Restoring (p. 147) Creating a snapshot of a DB instance Backing Up and Restoring (p. 147) Performing a point-in-time restore Restoring a DB Instance to a Specified Time (p. 173) Modifying API Version 2014-10-31 125 Amazon Relational Database Service User Guide Topic Section in Amazon RDS User Guide Modifying a DB instance (DB engine specific) Modifying a DB Instance Running the MySQL Database Engine (p. 675) Modifying a DB Instance Running the Oracle Database Engine (p. 763) Modifying a DB Instance Running the PostgreSQL Database Engine (p. 929) Modifying a DB Instance Running the Microsoft SQL Server Database Engine (p. 598) Modifying a DB Instance Running the MariaDB Database Engine (p. 546) Renaming a DB instance Renaming a DB Instance (p. 178) Changing the storage type Working with Storage Types (p. 187) Tagging a DB instance Tagging Amazon RDS Resources (p. 213) Maintaining and Upgrading Performing maintenance on a DB instance Amazon RDS Maintenance Window (p. 128) Upgrading a DB instance DB Instance Maintenance and Upgrades (p. 127) Rebooting a DB instance Rebooting a DB Instance (p. 185) Deleting a DB instance Deleting a DB Instance (p. 181) API Version 2014-10-31 126 Amazon Relational Database Service User Guide Maintenance and Upgrades DB Instance Maintenance and Upgrades Changes to a DB instance can occur when you manually modify a DB instance, such as when you upgrade the DB engine version, or when Amazon RDS performs maintenance on an instance. This section provides information on how you can upgrade a DB engine version and information on process Amazon RDS uses to perform required maintenance. Topics • Amazon RDS Maintenance (p. 127) • Updating the Operating System for a DB Instance (p. 131) • Upgrading the Database Engine Version for a DB Instance (p. 135) Amazon RDS Maintenance Periodically, Amazon RDS performs maintenance on Amazon RDS resources, such as DB instances. Maintenance most often involves updates to the DB instance's operating system (OS). Note Amazon Aurora periodically releases a new engine version and patches all DB clusters with the new version. For details on Amazon Aurora database upgrades, see Amazon Aurora Database Engine Updates (p. 512). You can choose to manually apply maintenance items on a DB instance at your convenience, or wait for the automatic maintenance process initiated by Amazon RDS during your weekly maintenance window. You can view whether a maintenance update is available for your DB instance both on the RDS console and by using the Amazon RDS API. If an update is available, you can choose to do one of the following: • Defer the maintenance items. • Apply the maintenance items immediately. • Schedule the maintenance items to start during your next maintenance window. Note The maintenance window determines when pending operations start, but does not limit the total execution time of these operations. Maintenance operations are not guaranteed to finish before the maintenance window ends, and can continue beyond the specified end time. Certain maintenance items will be marked as Required in the Maintenance column in the Amazon RDS console. These updates cannot be deferred indefinitely. If you choose to defer a required update, you will receive a communication from AWS that notifies you of the time at which the update will be performed on your DB instance. Other updates will be marked as Available. You can defer these maintenance items indefinitely and the update will not be applied to your DB instance. Maintenance items require that Amazon RDS take your DB instance offline for a short time. Maintenance that requires your DB instance to be offline include scale compute operations, which generally take only a few minutes from start to finish, and required operating system or database patching. Required patching is automatically scheduled only for patches that are related to security and instance reliability. Such patching occurs infrequently (typically once every few months) and seldom requires more than a fraction of your maintenance window. Running your DB instance as a Multi-AZ deployment can further reduce the impact of a maintenance event, because Amazon RDS will conduct maintenance by following these steps: 1. Perform maintenance on the standby. API Version 2014-10-31 127 Amazon Relational Database Service User Guide Amazon RDS Maintenance 2. Promote the standby to primary. 3. Perform maintenance on the old primary, which becomes the new standby. Note When you modify the database engine for your DB instance in a Multi-AZ deployment, then Amazon RDS upgrades both the primary and secondary DB instances at the same time. In this case, the database engine for the entire Multi-AZ deployment is shut down during the upgrade. For more information on Multi-AZ deployments, see High Availability (Multi-AZ) (p. 118). Amazon RDS Maintenance Window Every DB instance has a weekly maintenance window during which any system changes are applied. You can think of the maintenance window as an opportunity to control when DB instance modifications and software patching occur, in the event either are requested or required. If a maintenance event is scheduled for a given week, it will be initiated during the 30 minute maintenance window you identify. Most maintenance events also complete during the 30 minute maintenance window, although larger maintenance events may take more than 30 minutes to complete. The 30-minute maintenance window is selected at random from an 8-hour block of time per region. If you don't specify a preferred maintenance window when you create the DB instance, Amazon RDS assigns a 30-minute maintenance window on a randomly selected day of the week. RDS will consume some of the resources on your DB instance while maintenance is being applied. You may observe a minimal effect on performance. On rare occasions, a Multi-AZ failover may be required for a maintenance update to complete. The following table lists the time blocks for each region from which the default maintenance windows are assigned. Region Time Block US East (N. Virginia) Region 03:00-11:00 UTC US West (N. California) Region 06:00-14:00 UTC US West (Oregon) Region 06:00-14:00 UTC EU (Ireland) Region 22:00-06:00 UTC EU (Frankfurt) Region 23:00-07:00 UTC Asia Pacific (Tokyo) Region 13:00-21:00 UTC Asia Pacific (Seoul) Region 13:00-21:00 UTC Asia Pacific (Sydney) Region 12:00-20:00 UTC Asia Pacific (Singapore) Region 14:00-22:00 UTC South America (São Paulo) Region 00:00-08:00 UTC AWS GovCloud (US) Region 06:00-14:00 UTC API Version 2014-10-31 128 Amazon Relational Database Service User Guide Amazon RDS Maintenance Adjusting the Preferred Maintenance Window The maintenance window should fall at the time of lowest usage and thus might need modification from time to time. Your DB instance will only be unavailable during this time if the system changes, such as a scale storage operation or a change in DB instance class, are being applied and require an outage, and only for the minimum amount of time required to make the necessary changes. In the following example, you adjust the preferred maintenance window for a DB Instance. For the purpose of this example, we assume that the DB instance named mydbinstance exists and has a preferred maintenance window of "Sun:05:00-Sun:06:00" UTC. AWS Management Console To adjust the preferred maintenance window 1. Launch the AWS Management Console. a. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. b. Click on the DB Instances link in the Navigation panel on the left side of the console display. The My Instances list appears. c. Right-click on the DB Instance in the My DB Instances list and select Modify from the dropdown menu. The Modify DB Instance window appears. 2. Type the maintenance window into the Maintenance Window text box using the format "day:hour:minute-day:hour:minute". Note The maintenance window and the backup window for the DB instance cannot overlap. If you enter a value for the maintenance window that overlaps the backup window, an error message appears. 3. Click the OK button. Changes to the maintenance window take effect immediately. CLI To adjust the preferred maintenance window, use the AWS CLI modify-db-instance command with the following parameters: • --db-instance-identifier • --preferred-maintenance-window API Version 2014-10-31 129 Amazon Relational Database Service User Guide Amazon RDS Maintenance Example The following code example sets the maintenance window to Tuesdays from 4:00-4:30AM UTC. For Linux, OS X, or Unix: aws rds modify-db-instance \ --db-instance-identifier mydbinstance \ --preferred-maintenance-window Tue:04:00-Tue:04:30 For Windows: aws rds modify-db-instance ^ --db-instance-identifier mydbinstance ^ --preferred-maintenance-window Tue:04:00-Tue:04:30 This command produces output similar to the following. DBINSTANCE mydbinstance 2009-10-22T18:10:15.274Z db.m3.large mysql 60 master available mydbinstance.clouwupjnvmq.us-east-1.rds.amazonaws.com 3306 us-east-1a 1 n 5.6.27 general-public-license SECGROUP default active PARAMGRP default.mysql5.6 in-sync API To adjust the preferred maintenance window, use the Amazon RDS API ModifyDBInstance action with the following parameters: • DBInstanceIdentifier = mydbinstance • PreferredMaintenanceWindow = Tue:04:00-Tue:04:30 Example The following code example sets the maintenance window to Tuesdays from 4:00-4:30AM UTC. https://rds.amazonaws.com/ ?Action=ModifyDBInstance &DBInstanceIdentifier=mydbinstance &PreferredMaintenanceWindow=Tue:04:00-Tue:04:30 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2009-10-14T17%3A48%3A21.746Z &AWSAccessKeyId= &Signature= Related Topics • Updating the Operating System for a DB Instance (p. 131) • Upgrading the Database Engine Version for a DB Instance (p. 135) API Version 2014-10-31 130 Amazon Relational Database Service User Guide Updating Operating Systems Updating the Operating System for a DB Instance Amazon RDS allows you to choose when you upgrade the underlying operating system. You can decide when Amazon RDS applies OS updates by using the RDS console, AWS command line interface (CLI), or RDS API. Upgrades to the operating system are most often for security issues and should be done as soon as possible. This gives you the ability to see ahead of time when a given required maintenance update will be applied to their instances, as well as the ability to opt in to the maintenance ahead of the scheduled start time. Note Your DB instance is not automatically backed up when an OS update is applied, so you should backup your instance before you apply the update. You can choose to apply OS updates on a DB instance at your convenience or you can wait for the maintenance process initiated by Amazon RDS to apply the update during your maintenance window. You can view whether an OS update is available for your DB instance both on the Amazon RDS console and by using the AWS CLI or Amazon RDS API. If an update is available, it will be indicated by the word Available in the Maintenance column for the DB instance on the Amazon RDS console. For OS updates that are marked Available, you can choose to do one of the following: • Defer the OS update. • Have the OS update applied immediately. • Schedule the OS update to be applied during your next maintenance window. Note The maintenance window determines when pending operations start, but does not limit the total execution time of these operations. Maintenance operations are not guaranteed to finish before the maintenance window ends, and can continue beyond the specified end time. Certain OS updates will be marked as Required in the Maintenance column in the Amazon RDS console. These updates cannot be deferred indefinitely. If you choose to defer a required update, you will receive a notice from Amazon RDS indicating the time when the update will be performed on your DB instance. Other updates will be marked as Available. You can defer these OS updates indefinitely and the update will not be applied to your DB instance. If you use the Amazon RDS console, it will indicate when an operating system update is either available or required for your DB instance. For example, the following screenshot shows that an OS update is available: API Version 2014-10-31 131 Amazon Relational Database Service User Guide Updating Operating Systems The Maintenance column indicates whatever option you select. For example, the following screenshot shows that the selected DB instance can be updated either immediately or during the DB instance's next maintenance window: AWS Management Console To manage an OS update for a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, click Instances. 3. Click the check box for the DB instance that has a required operating system update. 4. Click Instance Actions and click one of the following: • Upgrade Now • Upgrade at Next Window Note If you choose the Upgrade at Next Window option, and later want to delay the OS update, you can click Instance Actions and then select Defer Upgrade. CLI To apply a pending OS update to a DB instance use the AWS CLI command apply-pendingmaintenance-action to apply pending maintenance actions. API Version 2014-10-31 132 Amazon Relational Database Service User Guide Updating Operating Systems Example For Linux, OS X, or Unix: aws rds apply-pending-maintenance-action \ --resource-identifier arn:aws:rds:us-west-2:001234567890:db:mysql-db \ --apply-action system-update \ --opt-in-type immediate For Windows: aws rds apply-pending-maintenance-action ^ --resource-identifier arn:aws:rds:us-west-2:001234567890:db:mysql-db ^ --apply-action system-update ^ --opt-in-type immediate To return a list of resources that have at least one pending OS update, use the AWS CLI command describe-pending-maintenance-actions to list all pending maintenance actions. Example For Linux, OS X, or Unix: aws rds describe-pending-maintenance-actions \ --resource-identifier arn:aws:rds:us-west-2:001234567890:db:mysql-db For Windows: aws rds describe-pending-maintenance-actions ^ --resource-identifier arn:aws:rds:us-west-2:001234567890:db:mysql-db API To apply an OS update to a DB instance, call the Amazon RDS API ApplyPendingMaintenanceAction action. Example https://rds.us-west-2.amazonaws.com/ ?Action=ApplyPendingMaintenanceAction &ResourceIdentifier=arn:aws:rds:us-east-1:123456781234:db:my-instance &ApplyAction=system-update &OptInType=immediate &SignatureMethod=HmacSHA256 &SignatureVersion=4 &Version=2014-10-31 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20141216/us-west-2/rds/aws4_request &X-Amz-Date=20140421T194732Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=6e25c542bf96fe24b28c12976ec92d2f856ab1d2a158e21c35441a736e4fde2b API Version 2014-10-31 133 Amazon Relational Database Service User Guide Updating Operating Systems To return a list of resources that have at least one pending OS update, call the Amazon RDS API DescribePendingMaintenanceActions action. Example https://rds.us-west-2.amazonaws.com/ ?Action=DescribePendingMaintenanceActions &SignatureMethod=HmacSHA256 &SignatureVersion=4 &Version=2014-10-31 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20141216/us-west-2/rds/aws4_request &X-Amz-Date=20140421T194732Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=6e25c542bf96fe24b28c12976ec92d2f856ab1d2a158e21c35441a736e4fde2b Related Topics • Amazon RDS Maintenance (p. 127) • Upgrading the Database Engine Version for a DB Instance (p. 135) API Version 2014-10-31 134 Amazon Relational Database Service User Guide Upgrading Database Engine Versions Upgrading the Database Engine Version for a DB Instance You can choose to upgrade a DB instance in some cases when a new DB engine version is supported by Amazon RDS. Database version upgrades consist of major and minor version upgrades. Major database version upgrades can contain changes that are not backward-compatible with existing applications. As a result, Amazon Relational Database Service (Amazon RDS) doesn't apply major version upgrades automatically; you must manually modify your DB instance. You should thoroughly test any upgrade before applying it to your production instances. Each DB engine handles minor version upgrades slightly differently. For example, you can have Amazon RDS automatically apply minor version upgrades to a DB instance running PostgreSQL, but you must manually apply any minor version upgrades to a DB instance running Oracle. For more information, see the section for your DB engine version following. • Upgrading the MySQL DB Engine (p. 136) • Upgrading the MariaDB DB Engine (p. 138) • Upgrading the PostgreSQL DB Engine (p. 138) • Upgrading the Oracle DB Engine (p. 141) • Upgrading the SQL Server DB Engine (p. 144) We don’t automatically upgrade an Amazon RDS DB instance until we post an announcement to the forums announcement page and send a customer e-mail notification. Even though upgrades take place during the instance maintenance window, we still schedule them at specific times through the year. We schedule them so you can plan around them, because downtime is required to upgrade a DB engine version, even for Multi-AZ instances. Amazon RDS takes two DB snapshots during the upgrade process. The first DB snapshot is of the DB instance before any upgrade changes have been made. If the upgrade doesn't work for your databases, you can restore this snapshot to create a DB instance running the old version. The second DB snapshot is taken when the upgrade completes. After the upgrade is complete, you can't revert to the previous version of the database engine. If you want to return to the previous version, restore the first DB snapshot taken to create a new DB instance. You control when to upgrade your DB instance to a new version supported by Amazon RDS. This level of control helps you maintain compatibility with specific database versions and test new versions with your application before deploying in production. When you are ready, you can perform version upgrades at the times that best fit your schedule. For information on OS updates for your DB instance, see Updating the Operating System for a DB Instance (p. 131). If your DB instance is using read replication, you must upgrade all of the Read Replicas before upgrading the source instance. If your DB instance is in a Multi-AZ deployment, both the primary and standby replicas are upgraded. The primary and standby DB instances are upgraded at the same time and you will experience an outage until the upgrade is complete. The time for the outage varies based on your database engine, version, and the size of your DB instance. API Version 2014-10-31 135 Amazon Relational Database Service User Guide Upgrading Database Engine Versions Upgrading the MySQL DB Engine Major Version Upgrades for MySQL Amazon RDS supports the following in-place upgrades for major versions of the MySQL database engine: • MySQL 5.1 to MySQL 5.5 • MySQL 5.5 to MySQL 5.6 • MySQL 5.6 to MySQL 5.7 Note You can only create MySQL version 5.7 DB instances with current generation DB instance classes. If you want to upgrade a MySQL version 5.6 DB instance running on a previous generation DB instance class to a MySQL version 5.7 DB instance, you must first modify the DB instance to use a current generation DB instance class. After the DB instance has been modified to use a current generation DB instance class, you can then modify the DB instance to use the MySQL version 5.7 database engine. For information on Amazon RDS DB instance classes, see DB Instance Class (p. 109). To perform a major version upgrade for a MySQL version 5.1 DB instance on Amazon RDS to MySQL version 5.6 or later, you must first perform any available OS updates. You can then upgrade your DB instance to MySQL version 5.5. When that upgrade is complete, you can upgrade your DB instance to MySQL version 5.6. Once you have a version 5.6 DB instance, you can then upgrade that DB instance to MySQL version 5.7. MySQL DB instances created before April 24, 2014, show an available OS update until the update has been applied. For more information on OS updates, see Updating the Operating System for a DB Instance (p. 131). During a major version upgrade of MySQL, Amazon RDS runs the MySQL binary mysql_upgrade to upgrade tables, if required. Also, Amazon RDS empties the slow_log and general_log tables during a major version upgrade. To preserve log information, save the log contents before the major version upgrade. MySQL major version upgrades typically complete in about 10 minutes. Some upgrades might take longer because of the DB instance class size or because the instance doesn't follow certain operational guidelines in Best Practices for Amazon RDS (p. 98). If you upgrade a DB instance from the Amazon RDS console, the status of the DB instance indicates when the upgrade is complete. If you upgrade using the AWS Command Line Interface (AWS CLI), use the describe-db-instances command and check the Status value. Upgrades to MySQL Version 5.7 Might Be Slow MySQL version 5.6.4 introduced a new date and time format for the datetime, time, and timestamp columns that allows fractional components in date and time values. When upgrading a DB instance to MySQL version 5.7, MySQL will force the conversion of all date and time column types to the new format. Because this conversion rebuilds your tables, it might take a considerable amount of time to complete the DB instance upgrade. The forced conversion will occur for any DB instances that are running a version prior to MySQL version 5.6.4, and also any DB instances that were upgraded from a version prior to MySQL version 5.6.4 to a version other than 5.7. If your DB instance is running a version prior to MySQL version 5.6.4, or was upgraded from a version prior to MySQL version 5.6.4, then we recommend that you convert the datetime, time, and timestamp columns in your database before upgrading your DB instance to MySQL version 5.7. This conversion can significantly reduce the amount of time required to upgrade the DB instance to MySQL version 5.7. To upgrade your date and time columns to the new format, issue the ALTER TABLE FORCE; command for each table that contains date or time columns. Because API Version 2014-10-31 136 Amazon Relational Database Service User Guide Upgrading Database Engine Versions altering a table locks the table as read-only, we recommend that you perform this update during a maintenance window. You can use the following query to find all tables in your database that have columns of type datetime, time, or timestamp and to create an ALTER TABLE FORCE; command for each table: SELECT DISTINCT CONCAT('ALTER TABLE `', REPLACE(is_tables.TABLE_SCHEMA, '`', '``'), '`.`', REPLACE(is_tables.TABLE_NAME, '`', '``'), '` FORCE;') FROM information_schema.TABLES is_tables INNER JOIN information_schema.COLUMNS col ON col.TABLE_SCHEMA = is_tables.TABLE_SCHEMA AND col.TABLE_NAME = is_tables.TABLE_NAME LEFT OUTER JOIN information_schema.INNODB_SYS_TABLES systables ON SUBSTRING_INDEX(systables.NAME, '#', 1) = CONCAT(is_tables.TABLE_SCHEMA,'/',is_tables.TABLE_NAME) LEFT OUTER JOIN information_schema.INNODB_SYS_COLUMNS syscolumns ON syscolumns.TABLE_ID = systables.TABLE_ID AND syscolumns.NAME = col.COLUMN_NAME WHERE col.COLUMN_TYPE IN ('time','timestamp','datetime') AND is_tables.TABLE_TYPE = 'BASE TABLE' AND is_tables.TABLE_SCHEMA NOT IN ('mysql','information_schema','performance_schema') AND (is_tables.ENGINE = 'InnoDB' AND syscolumns.MTYPE = 6); Minor Version Upgrades for MySQL Minor version upgrades only occur automatically if a minor upgrade replaces an unsafe version, such as a minor upgrade that contains bug fixes for a previous version. In all other cases, you must modify the DB instance manually to perform a minor version upgrade. We don’t automatically upgrade an Amazon RDS DB instance until we post an announcement to the forums announcement page and send a customer e-mail notification. Even though upgrades take place during the instance maintenance window, we still schedule them at specific times through the year. We schedule them so you can plan around them, because downtime is required to upgrade a DB engine version, even for Multi-AZ instances. Upgrading a MySQL Database with Reduced Downtime If your MySQL DB instance is currently in use with a production application, you can use the following procedure to upgrade the database version for your DB instance and reduce the amount of downtime for your application. This procedure shows an example of upgrading from MySQL version 5.5 to MySQL version 5.6. To upgrade an MySQL database while a DB instance is in use 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. Create a Read Replica of your MySQL 5.5 DB instance. This process creates an upgradable copy of your database. a. On the console, choose Instances, and then choose the DB instance that you want to upgrade. b. Choose Instance Actions, and then choose Create Read Replica. c. Provide a value for DB Instance Identifier for your Read Replica and ensure that the DB instance Class and other settings match your MySQL 5.5 DB instance. d. Choose Yes, Create Read Replica. API Version 2014-10-31 137 Amazon Relational Database Service User Guide Upgrading Database Engine Versions 3. When the Read Replica has been created and Status shows available, upgrade the Read Replica to MySQL 5.6. a. On the console, choose Instances, and then choose the Read Replica that you just created. b. Choose Instance Actions, and then choose Modify. c. For DB Engine Version, choose the MySQL 5.6 version to upgrade to, and then choose Apply Immediately. Choose Continue. d. Choose Modify DB Instance to start the upgrade. 4. When the upgrade is complete and Status shows available, verify that the upgraded Read Replica is up to date with the master MySQL 5.5 DB instance. You can do this by connecting to the Read Replica and issuing the SHOW SLAVE STATUS command. If the Seconds_Behind_Master field is 0, then replication is up to date. 5. Make your MySQL 5.6 Read Replica a master DB instance. Important When you promote your MySQL 5.6 Read Replica to a standalone, single-AZ DB instance, it will no longer be a replication slave to your MySQL 5.5 DB instance. We recommend that you promote your MySQL 5.6 Read Replica during a maintenance window when your source MySQL 5.5 DB instance is in read-only mode and all write operations are suspended. When the promotion is completed, you can direct your write operations to the upgraded MySQL 5.6 DB instance to ensure that no write operations are lost. In addition, we recommend that before promoting your MySQL 5.6 Read Replica you perform all necessary data definition language (DDL) operations, such as creating indexes, on the MySQL 5.6 Read Replica. This approach avoids negative effects on the performance of the MySQL 5.6 Read Replica after it has been promoted. To promote a Read Replica, use this procedure: a. On the console, choose Instances, and then choose the Read Replica that you just upgraded. b. Choose Instance Actions, and then choose Promote Read Replica. c. Enable automated backups for the Read Replica instance. For more information, see Working With Automated Backups (p. 148). Choose Continue. d. 6. Choose Yes, Promote Read Replica. You now have an upgraded version of your MySQL database. At this point, you can direct your applications to the new MySQL 5.6 DB instance, add Read Replicas, set up Multi-AZ support, and so on. Upgrading the MariaDB DB Engine Major Version Upgrades for MariaDB Amazon RDS currently only supports version 10.0 for MariaDB. Minor Version Upgrades for MariaDB Minor version upgrades occur automatically if you set the Auto Minor Version Upgrade option on your DB instance to Yes. In all other cases, you must modify the DB instance to perform a minor version upgrade. Upgrading the PostgreSQL DB Engine Amazon RDS supports major and minor version upgrades for PostgreSQL DB instances. API Version 2014-10-31 138 Amazon Relational Database Service User Guide Upgrading Database Engine Versions You can initiate a major version upgrade manually by modifying your instance. However, there are recommended steps to follow when performing a major version upgrade. For details, see Major Version Upgrades (p. 139). You can initiate a minor version upgrade manually by modifying your instance, or select the Auto Minor Version Upgrade option when creating or modifying a DB instance to have your instance automatically upgraded once the new version is tested and approved by Amazon RDS. AWS RDS does not automatically upgrade PostgreSQL extensions. To upgrade an extension, you must use the ALTER EXTENSION UPDATE command. For example, to upgrade PostGIS when you upgrade the PostgreSQL DB engine from 9.4.x to 9.5.x, you would run the following command: ALTER EXTENSION POSTGIS UPDATE TO '2.2.2' Major Version Upgrades Amazon RDS supports an in-place upgrade from a PostgreSQL 9.3.x DB instance to a PostgreSQL 9.4.x DB instance and PostgreSQL 9.4.x DB instance to a PostgreSQL 9.5.x DB instance. Amazon RDS uses the pg_upgrade utility found at http://www.postgresql.org/docs/9.4/static/pgupgrade.html to safely upgrade your instance. Because some PostgreSQL minor versions updates for 9.3 were released after major version 9.4 was released, you cannot upgrade from version 9.3.9 to 9.4.1, and you cannot upgrade from version 9.3.10 to 9.4.1 or 9.4.4. Read Replicas cannot undergo a major version upgrade. The source instance can undergo a major version upgrade, but all Read Replicas remain as readable nodes on the previous engine version. After a source instance is upgraded, its Read Replicas can no longer replicate changes performed on the source instance. We recommend that you either promote your Read Replicas, or delete and recreate them after the source instance has upgraded to a different major version. Major Version Upgrade Process We recommend the following process when upgrading an Amazon RDS PostgreSQL DB instance: 1. Have a version-compatible parameter group ready – If you are using a custom parameter group, you must specify either a default parameter group for the new DB engine version or create your own custom parameter group for the new DB engine version. Associating the new parameter group with the DB instance requires a customer-initiated database reboot after the upgrade completes. The instance's parameter group status will show pending-reboot if the instance needs to be rebooted to apply the parameter group changes. An instance's parameter group status can be viewed in the AWS console or by using a "describe" call such as describe-dbinstances. 2. Check for unsupported usage: 1. Prepared transactions – Commit or roll back all open prepared transactions before attempting an upgrade. You can use the following query to verify that there are no open prepared transactions on your instance: SELECT count(*) FROM pg_catalog.pg_prepared_xacts; 2. The line data type – If you are upgrading an RDS PostgreSQL 9.3 instance, you must remove all uses of the line data type before attempting an upgrade, because the line data type was not fully implemented in PostgreSQL until version 9.4. API Version 2014-10-31 139 Amazon Relational Database Service User Guide Upgrading Database Engine Versions You can use the following query on each database to be upgraded to verify that there are no uses of the line data type in each database: SELECT count(*) FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n, pg_catalog.pg_attribute a WHERE c.oid = a.attrelid AND NOT a.attisdropped AND a.atttypid = 'pg_catalog.line'::pg_catalog.regtype AND c.relnamespace = n.oid AND n.nspname !~ '^pg_temp_' AND n.nspname !~ '^pg_toast_temp_' AND n.nspname NOT IN ('pg_catalog', 'information_schema'); Note To list all databases on an instance, use the following query: SELECT d.datname FROM pg_catalog.pg_database d WHERE d.datallowconn = true; 3. Reg* data types – Remove all uses of the reg* data types before attempting an upgrade, because these data types contain information that cannot be persisted with pg_upgrade. Uses of reg* data types cannot be upgraded, except for regtype and regclass. Remove all usages before attempting an upgrade. You can use the following query to verify that there are no uses of unsupported reg* data types in each database: SELECT count(*) FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n, pg_catalog.pg_attribute a WHERE c.oid = a.attrelid AND NOT a.attisdropped AND a.atttypid IN ('pg_catalog.regproc'::pg_catalog.regtype, 'pg_catalog.regprocedure'::pg_catalog.regtype, 'pg_catalog.regoper'::pg_catalog.regtype, 'pg_catalog.regoperator'::pg_catalog.regtype, 'pg_catalog.regconfig'::pg_catalog.regtype, 'pg_catalog.regdictionary'::pg_catalog.regtype) AND c.relnamespace = n.oid AND n.nspname NOT IN ('pg_catalog', 'information_schema'); 3. Perform a VACUUM operation before upgrading your instance. The pg_upgrade utility vacuums each database when you upgrade to a different major version. If you haven't performed a VACUUM operation, the upgrade process can take much longer, causing increased downtime for your RDS instance. 4. Perform a dry run of your major version upgrade. We highly recommend testing major version upgrade on a duplicate of your production database before attempting it on your production database. To create a duplicate test instance, you can either restore your database from a recent snapshot or point-in-time restore your database to its latest restorable time. After you have completed the major version upgrade, consider testing your application on the upgraded database API Version 2014-10-31 140 Amazon Relational Database Service User Guide Upgrading Database Engine Versions 5. 6. with a similar workload in order to verify that everything works as expected. After the upgrade is verified, you can delete this test instance. We recommend that you perform a backup before performing the major version upgrade so that you have a known restore point for your database. Upgrade your production instance. If the dry-run major version upgrade was successful, you should now be able to upgrade your production database with confidence. You can use Amazon RDS to view two logs that the pg_upgrade utility produces: pg_upgrade_internal.log and pg_upgrade_server.log. Amazon RDS appends a timestamp to the file name for these logs. You can view these logs as you can any other log. You cannot perform a point-in-time restore of your instance to a point in time during the upgrade process. During the upgrade process, RDS takes an automatic backup of the instance after the upgrade has been performed. You can perform a point-in-time restore to times before the upgrade began and after the automatic backup of your instance has completed. The public and template1 databases and the public schema in every database on the instance are renamed during the major version upgrade. These objects will appear in the logs with their original name and a random string appended. The string is appended so that custom settings such as the locale and owner are preserved during the major version upgrade. Once the upgrade completes, the objects are renamed back to their original names. Minor Version Upgrades Minor version upgrades occur automatically if a minor upgrade has been tested and approved by Amazon RDS and you selected the Auto Minor Version Upgrade option. In all other cases, you must modify the DB instance manually to perform a minor version upgrade. If you select the Auto Minor Version Upgrade option when creating or modifying a DB instance, you can have your instance automatically upgraded after the new version is tested and approved by Amazon RDS. If your PostgreSQL DB instance is using read replication, you must upgrade all of the Read Replicas before upgrading the source instance. If the DB instance is in a Multi-AZ deployment, both the primary and standby replicas are upgraded, and the instance might not be available until the upgrade is complete. PostgreSQL components The following table shows the component versions that ship with the two latest Amazon RDS PostgreSQL versions: Component Version in Amazon RDS PostgreSQL 9.3.10 Version in Amazon RDS PostgreSQL 9.4.5 PostGIS 2.1.8 2.1.8 GEOS 3.5.0 3.5.0 GDAL 1.11.2 1.11.2 PROJ 4.9.1 4.9.1 proj-datumgrid 1.5 1.5 PLv8 1.4.4 1.4.4 Upgrading the Oracle DB Engine Amazon RDS supports the following upgrades to an Oracle DB instance. API Version 2014-10-31 141 Amazon Relational Database Service User Guide Upgrading Database Engine Versions • Major Version Upgrades – major version upgrades are currently unsupported. • Minor Version Upgrades – minor version upgrades are supported, but do not occur automatically. You must modify the DB instance manually to perform a minor version upgrade. For information about what Oracle versions are available on Amazon RDS, see Appendix: Oracle Database Engine Release Notes (p. 869). Oracle SE2 Upgrade Paths The following table shows supported upgrade paths to Standard Edition Two (SE2). For more information about the License Included and Bring Your Own License models, see Oracle Licensing (p. 749). Your Existing Configuration Supported SE2 Configuration SE 12.1.0.1 Bring Your Own License SE2 12.1.0.2 Bring Your Own License or License Included SE1 12.1.0.1 Bring Your Own License SE2 12.1.0.2 Bring Your Own License or License Included SE1 12.1.0.1 Licence Included SE2 12.1.0.2 Bring Your Own License or License Included SE2 12.1.0.2 Bring Your Own License SE2 12.1.0.2 Bring Your Own License or License Included Option Group Considerations If your DB instance uses the default option group, when you upgrade your DB instance, Amazon RDS automatically assigns your DB instance the correct default option group for your upgraded configuration. If your DB instance uses a custom option group, in some cases Amazon RDS can't automatically assign your DB instance a new option group. For example, when you upgrade from version 12.1.0.1 SE or SE1 to version 12.1.0.2 SE2. In that case, you must specify a new option group when you upgrade. We recommend that you create a new option group, and add the same options to it as your existing custom option group. For more information, see Creating an Option Group (p. 224) or Making a Copy of an Option Group (p. 226). Parameter Group Considerations If your DB instance uses the default parameter group, when you upgrade your DB instance, Amazon RDS automatically assigns your DB instance the default parameter group for your upgraded configuration. If your DB instance uses a custom parameter group, in some cases Amazon RDS can't automatically assign your DB instance a new parameter group. For example, when you upgrade from version 12.1.0.1 SE or SE1 to version 12.1.0.2 SE2. In that case, you must specify a new parameter group when you upgrade. We recommend that you create a new parameter group, and configure the parameters as in your existing custom parameter group. For more information, see Creating a DB Parameter Group (p. 244) or Copying a DB Parameter Group (p. 249). API Version 2014-10-31 142 Amazon Relational Database Service User Guide Upgrading Database Engine Versions Upgrading by Using the AWS Management Console To upgrade an Oracle DB instance by using the AWS Management Console, you follow the same procedure as when you modify the DB instance. For more detailed instructions, see Modifying a DB Instance Running the Oracle Database Engine (p. 763). Upgrading by Using the CLI To upgrade an Oracle DB instance, use the AWS CLI modify-db-instance command with the following parameters: • --db-instance-identifier — the name of the db instance. • --engine-version — the version number of the database engine to upgrade to. • --no-apply-immediately — apply changes during the next maintenance window. To apply changes immediately, use --apply-immediately. You might also need to include the following parameters. For more information, see Option Group Considerations (p. 142) and Parameter Group Considerations (p. 142). • --option-group-name — the option group for the upgraded db instance. • --db-parameter-group-name — the parameter group for the upgraded db instance. Example The following code upgrades a DB instance. These changes are applied during the next maintenance window. For Linux, OS X, or Unix: aws rds modify-db-instance \ --db-instance-identifier \ --engine-version <12.1.0.2.v5> \ --option-group-name \ --db-parameter-group-name \ --no-apply-immediately For Windows: aws rds modify-db-instance ^ --db-instance-identifier ^ --engine-version <12.1.0.2.v5> ^ --option-group-name ^ --db-parameter-group-name ^ --no-apply-immediately Upgrading by Using the API To upgrade an Oracle DB instance, use the Amazon RDS API ModifyDBInstance action with the following parameters: • DBInstanceIdentifier — the name of the db instance, for example mydbinstance. • EngineVersion — the version number of the database engine to upgrade to, for example 12.1.0.2.v5. • ApplyImmediately — whether to apply changes immediately or during the next maintenance window. To apply changes immediately, set the value to true. To apply changes during the next maintenance window, set the value to false. API Version 2014-10-31 143 Amazon Relational Database Service User Guide Upgrading Database Engine Versions You might also need to include the following parameters. For more information, see Option Group Considerations (p. 142) and Parameter Group Considerations (p. 142). • OptionGroupName — the option group for the upgraded db instance, for example default:oracle-ee-12-1. • DBParameterGroupName — the parameter group for the upgraded db instance, for example default.oracle-ee-12.1. Example The following code upgrades a DB instance. These changes are applied during the next maintenance window. https://rds.us-east-1.amazonaws.com/ ?Action=ModifyDBInstance &ApplyImmediately=false &DBInstanceIdentifier=mydbinstance &DBParameterGroupName=default.oracle-ee-12.1 &EngineVersion=12.1.0.2.v5 &OptionGroupName=default:oracle-ee-12-1 &SignatureMethod=HmacSHA256 &SignatureVersion=4 &Version=2013-09-09 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20131016/us-east-1/rds/aws4_request &X-Amz-Date=20131016T233051Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=087a8eb41cb1ab0fc9ec1575f23e73757ffc6a1e42d7d2b30b9cc0be988cff97 Upgrading the SQL Server DB Engine Amazon RDS supports both major and minor version upgrades for a SQL Server DB instance. All upgrades must be manually applied and will take the instance offline while the upgrade takes place. Major Version Upgrades Amazon RDS currently supports the following DB engine in-place major version upgrades: • SQL Server 2008 R2 SP3 (10.50.6000.34.v1) to SQL Server 2012 SP2 (11.00.5058.0.v1) • SQL Server 2008 R2 SP1 (10.50.2789.0.v1) to SQL Server 2012 RTM (11.00.2100.60.v1) • SQL Server 2008 R2 SP1 (10.50.2789.0.v1) to SQL Server 2012 SP2 (11.00.5058.0.v1) • 10.50.2789.0.v1 (SQL Server 2008 R2 SP1) to SQL Server 2014 SP1 CU2 (12.00.4422.0.v1) • 10.50.6000.34.v1 (SQL Server 2008 R2 SP3) to SQL Server 2014 SP1 CU2 (12.00.4422.0.v1) • 11.00.2100.60.v1 (SQL Server 2012 RTM) to SQL Server 2014 SP1 CU2 (12.00.4422.0.v1) • 11.00.5058.0.v1 (SQL Server 2012 SP2) to SQL Server 2014 SP1 CU2 (12.00.4422.0.v1) Note If your DB instance uses a custom option group, you need to create a new option group with your existing settings that is compatible with the new major version prior to upgrading. Specify the new option group when you upgrade your DB instance. For more information about creating an option group, see Working with Option Groups (p. 223). API Version 2014-10-31 144 Amazon Relational Database Service User Guide Upgrading Database Engine Versions During a minor or major version upgrade of SQL Server, the Free Storage Space and Disk Queue Depth metrics will display -1. After the upgrade is complete, both metrics will return to normal. Minor Version Upgrades Minor version upgrades do not occur automatically. You must modify the DB instance manually to perform a minor version upgrade. The following minor version upgrades are supported for SQL Server on Amazon RDS: • Upgrading from SQL Server 2008 R2 SP1 (10.50.2789.0.v1) to SQL Server 2008 R2 SP3 (10.50.6000.34.v1) • Upgrading from SQL Server 2012 RTM (11.00.2100.60.v1) to SQL Server 2012 SP2 (11.00.5058.0.v1) Testing an Upgrade Before you perform a major version upgrade on your DB instance, you should thoroughly test both your database and the host application for compatibility. We suggest you do the following: 1. Review the upgrade documentation for the new version of the database engine to see if there are compatibility issues that might affect your database or applications: • MySQL 5.5 Upgrade Documentation • MySQL 5.6 Upgrade Documentation • Upgrade to SQL Server 2012 2. If your DB instance is a member of a custom DB parameter group, you need to create a new DB parameter group with your existing settings that is compatible with the new major version. Specify the new DB parameter group when you upgrade your test instance, so that your upgrade testing ensures that it works correctly. For more information about creating a DB parameter group, see Working with DB Parameter Groups (p. 243). 3. Create a DB snapshot of the DB instance to be upgraded. For more information, see Creating a DB Snapshot (p. 152). 4. Restore the DB snapshot to create a new test DB instance. For more information, see Restoring From a DB Snapshot (p. 154). 5. Modify this new test DB instance to upgrade it to the new version, using one of the methods detailed following. If you created a new parameter group in step 2, specify that parameter group. 6. Evaluate the storage used by the upgraded instance to determine if the upgrade requires additional storage. 7. Run as many of your quality assurance tests against the upgraded DB instance as needed to ensure that your database and application work correctly with the new version. Implement any new tests needed to evaluate the impact of any compatibility issues you identified in step 1. Test all stored procedures and functions. Direct test versions of your host applications to the upgraded DB instance. 8. If all tests pass, then perform the upgrade on your production DB instance. We suggest you do not allow write operations to the DB instance until you can confirm that everything is working correctly. Upgrading the DB Engine Version of a DB Instance For DB engines that can be upgraded, use the following procedures to upgrade. API Version 2014-10-31 145 Amazon Relational Database Service User Guide Upgrading Database Engine Versions AWS Management Console To apply a DB engine major version upgrade to a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, click Instances. 3. Click the check box for the DB instance that you want to upgrade. 4. Click Instance Actions and click Modify. 5. In the DB Engine Version box, click the new version. 6. To upgrade immediately, click to select the Apply Immediately check box. To delay the upgrade to the next maintenance window, make sure this check box is clear. 7. Click Continue. 8. Review the modification summary information. To proceed with the upgrade, click Modify DB Instance. To cancel the upgrade, click the X in the upper right corner. CLI To apply a DB engine major version upgrade to a DB instance • Use the AWS CLI command modify-db-instance specifying the DB instance identifier and using the following parameters: • --db-instance-identifier the database instance name • --engine-version = the new DB engine version • --allow-major-version-upgrade to allows major version upgrades, or --no-allowmajor-version-upgrade to disallow major version upgrades. • --apply-immediately to upgrade immediately, or --no-apply-immediately to delay the upgrade until the next maintenance window Example For Linux, OS X, or Unix: aws rds modify-db-instance \ --db-instance-identifier SQLServer1 \ --engine-version 11.00 \ --allow-major-version-upgrade \ --apply-immediately For Windows: aws rds modify-db-instance ^ --db-instance-identifier SQLServer1 ^ --engine-version 11.00 ^ --allow-major-version-upgrade ^ --apply-immediately API Version 2014-10-31 146 Amazon Relational Database Service User Guide Backing Up and Restoring API To apply a DB engine major version upgrade to a DB instance • Call ModifyDBInstance with the following parameters: • DBInstanceIdentifier = the identifier of the instance to be upgraded • EngineVersion = the new DB engine version • AllowMajorVersionUpgrade = true • ApplyImmediately = true to upgrade immediately, or false to delay the upgrade until the next maintenance window Example https://rds.amazonaws.com/ ?Action=ModifyDBInstance &DBInstanceIdentifier=MySQL-Instance1 &EngineVersion=5.5.31 &AllowMajorVersionUpgrade=true &ApplyImmediately=true Related Topics • Amazon RDS Maintenance (p. 127) • Updating the Operating System for a DB Instance (p. 131) Backing Up and Restoring This section shows how to back up and restore a DB instance. Topics • Working With Automated Backups (p. 148) • Creating a DB Snapshot (p. 152) • Restoring From a DB Snapshot (p. 154) • Copying a DB Snapshot (p. 158) • Sharing a DB Snapshot or DB Cluster Snapshot (p. 166) • Restoring a DB Instance to a Specified Time (p. 173) API Version 2014-10-31 147 Amazon Relational Database Service User Guide Working With Automated Backups Working With Automated Backups Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases. You can set the backup retention period when you create a DB instance. If you don't set the backup retention period, Amazon RDS uses a default period retention period of one day. You can modify the backup retention period; valid values are 0 (for no backup retention) to a maximum of 35 days. Manual snapshot limits (50 per region) do not apply to automated backups. Important An outage will occur if you change the backup retention period from 0 to a non-zero value or from a non-zero value to 0. All automated backups are deleted and cannot be recovered when you delete a DB instance. Manual snapshots are not deleted. For information on pricing for storing manual snapshots long-term, see Amazon RDS Pricing. In this example, you will enable and then disable backups for an existing DB instance called mydbinstance. Disabling Automated Backups You may want to temporarily disable automated backups in certain situations; for example, while loading large amounts of data. Important We highly discourage disabling automated backups because it disables point-in-time recovery. If you disable and then re-enable automated backups, you are only able to restore starting from the time you re-enabled automated backups. In these examples, you disable automated backups for a DB instance by setting the backup retention parameter to 0. AWS Management Console To disable automated backups immediately 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, click DB Instances, and then select the check box next to the DB instance you want to modify. 3. Click the Modify button. The Modify DB Instance window appears. 4. Select 0 in the Backup Retention Period drop-down list box. 5. Check the Apply Immediately check box. 6. Click the OK button. CLI To disable automated backups immediately, use the modify-db-instance command and set the backup retention period to 0 with --apply-immediately. API Version 2014-10-31 148 Amazon Relational Database Service User Guide Working With Automated Backups Example The following example immediately disabled automatic backups. For Linux, OS X, or Unix: aws rds modify-db-instance \ --db-instance-identifier mydbinstance \ --backup-retention-period 0 \ --apply-immediately For Windows: aws rds modify-db-instance ^ --db-instance-identifier mydbinstance ^ --backup-retention-period 0 ^ --apply-immediately To know when the modification is in effect, call describe-db-instances for the DB instance until the value for backup retention period is 0 and mydbinstance status is available. aws rds describe-db-instances --db-instance-identifier mydbinstance API To disable automated backups immediately, call the Amazon RDS API action ModifyDBInstance with the following parameters: • DBInstanceIdentifier = mydbinstance • BackupRetentionPeriod = 0 Example https://rds.amazonaws.com/ ?Action=ModifyDBInstance &DBInstanceIdentifier=mydbinstance &BackupRetentionPeriod=0 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2009-10-14T17%3A48%3A21.746Z &AWSAccessKeyId= &Signature= Enabling Automated Backups If your DB instance doesn't have automated backups enabled, you can enable them at any time. The same request used to disable automated backups can be used to enable them by using a positive non-zero value for the backup retention period. When automated backups are enabled, a backup is immediately created. All automated backups are deleted and cannot be recovered when you delete a DB instance. Manual snapshots are not deleted. In this example, you enable automated backups for a DB instance by setting the backup retention period parameter for the DB instance to a positive non-zero value (in this case, 3). API Version 2014-10-31 149 Amazon Relational Database Service User Guide Working With Automated Backups AWS Management Console To enable automated backups immediately 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, click DB Instances, and then select the check box next to the DB instance you want to modify. Click the Modify button or right-click the DB instance and select Modify from the context menu. 3. The Modify DB Instance window appears. 4. 5. Select 3 in the Backup Retention Period drop-down list box. Check the Apply Immediately check box. 6. Click the OK button. CLI To enable automated backups immediately, use the AWS CLI modify-db-instance command. In this example, we will enable automated backups by setting the backup retention period to 3 days. Include the following parameters: • --db-instance-identifier • --backup-retention-period • --apply-immediately or --no-apply-immediately Example For Linux, OS X, or Unix: aws rds modify-db-instance \ --db-instance-identifier mydbinstance --backup-retention-period 3 \ --apply-immediately \ For Windows: aws rds modify-db-instance ^ --db-instance-identifier mydbinstance --backup-retention-period 3 ^ --apply-immediately ^ API To enable automated backups immediately, use the AWS CLI ModifyDBInstance command. In this example, we will enable automated backups by setting the backup retention period to 3 days. Include the following parameters: • DBInstanceIdentifier = mydbinstance • BackupRetentionPeriod = 3 • ApplyImmediately = true API Version 2014-10-31 150 Amazon Relational Database Service User Guide Working With Automated Backups Example https://rds.amazonaws.com/ ?Action=ModifyDBInstance &DBInstanceIdentifier=mydbinstance &BackupRetentionPeriod=3 &ApplyImmediately=true &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2009-10-14T17%3A48%3A21.746Z &AWSAccessKeyId= &Signature= Related Topics • Restoring a DB Instance to a Specified Time (p. 173) • DB Instance Backups (p. 121) API Version 2014-10-31 151 Amazon Relational Database Service User Guide Creating a DB Snapshot Creating a DB Snapshot Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases. Creating this DB snapshot on a Single-AZ DB instance results in a brief I/O suspension that typically lasting no more than a few minutes. Multi-AZ DB instances are not affected by this I/O suspension since the backup is taken on the standby. When you create a DB snapshot, you need to identify which DB instance you are going to back up, and then give your DB snapshot a name so you can restore from it later. In this example, you create a DB snapshot called mydbsnapshot for a DB instance called mydbinstance. AWS Management Console To create a DB snapshot 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, click DB Instances. 3. Click Instance Actions, and then click Take DB Snapshot. The Take DB Snapshot window appears. 4. Type the name of the snapshot in the Snapshot Name text box. 5. Click Yes, Take Snapshot. CLI To create a DB snapshot, use the AWS CLI create-db-snapshot command with the following parameters: • --db-instance-identifier • --db-snapshot-identifier API Version 2014-10-31 152 Amazon Relational Database Service User Guide Creating a DB Snapshot Example For Linux, OS X, or Unix: aws rds create-db-snapshot / --db-instance-identifier mydbinstance / --db-snapshot-identifier mydbsnapshot For Windows: aws rds create-db-snapshot ^ --db-instance-identifier mydbinstance ^ --db-snapshot-identifier mydbsnapshot The output from this command should look similar to the following: DBSNAPSHOT mydbsnapshot mydbinstance 2009-10-21T01:54:49.521Z 50 creating sa 5.6.27 general-public-license MySQL API To create a DB snapshot, use the AWS CLI create-db-snapshot command with the following parameters: • DBInstanceIdentifier = mydbinstance • DBSnapshotIdentifier = mydbsnapshot Example https://rds.us-east-1.amazonaws.com/ ?Action=CreateDBSnapshot &DBInstanceIdentifier=mydbinstance &DBSnapshotIdentifier=mydbsnapshot &SignatureMethod=HmacSHA256 &SignatureVersion=4 &Version=2013-09-09 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20140423/us-east-1/rds/aws4_request &X-Amz-Date=20140423T161105Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=e9649af6edcfbab4016f04d72e1b7fc16d8734c37477afcf25b3def625484ed2 Related Topics • Restoring From a DB Snapshot (p. 154) • Copying a DB Snapshot (p. 158) • Sharing a DB Snapshot or DB Cluster Snapshot (p. 166) • DB Instance Backups (p. 121) API Version 2014-10-31 153 Amazon Relational Database Service User Guide Restoring From a DB Snapshot Restoring From a DB Snapshot Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases. You can create a DB instance by restoring from this DB snapshot. When you restore the DB instance, you provide the name of the DB snapshot to restore from, and then provide a name for the new DB instance that is created from the restore. You cannot restore from a DB snapshot to an existing DB instance; a new DB instance is created when you restore. When you restore a DB instance, only the default DB parameter and security groups are associated with the restored instance. As soon as the restore is complete, you should associate any custom DB parameter or security groups used by the instance you restored from. You must apply these changes explicitly using the RDS console's Modify command, the ModifyDBInstance Amazon RDS API, or the AWS CLI modify-db-instance command line tool, once the DB instance is available. We recommend that you retain parameter groups for any DB snapshots you have so that you can associate a restored instance with the correct parameter file. Note If you use Oracle GoldenGate, always retain the parameter group with the compatible parameter. If you restore an instance from a DB snapshot, you must modify the restored instance to use the parameter group that has a matching or greater compatible parameter value. This should be done as soon as possible after the restore action, and will require a reboot of the instance. The option group associated with the DB snapshot is associated with the restored DB instance once it is created. For example, if the DB snapshot you are restoring from uses Oracle Transparent Data Encryption, the restored DB instance will use the same option group, which had the TDE option. When an option group is assigned to a DB instance, it is also linked to the supported platform the DB instance is on, either VPC or EC2-Classic (non-VPC). Furthermore, if a DB instance is in a VPC, the option group associated with the instance is linked to that VPC. This means that you cannot use the option group assigned to a DB instance if you attempt to restore the instance into a different VPC or onto a different platform. If you restore a DB instance into a different VPC or onto a different platform, you must either assign the default option group to the instance, assign an option group that is linked to that VPC or platform, or create a new option group and assign it to the DB instance. Note that with persistent or permanent options, such as Oracle TDE, you must create a new option group that includes the persistent or permanent option when restoring a DB instance into a different VPC. You can change to a different edition of the DB engine when restoring from a DB snapshot only if the DB snapshot has the required storage allocated for the new edition. For example, to change from SQL Server Web Edition to SQL Server Standard Edition, the DB snapshot must have been created from a SQL Server DB instance that had at least 200 GB of allocated storage, which is the minimum allocated storage for SQL Server Standard edition. You can restore a DB instance and use a different storage type than the source DB snapshot. In this case the restoration process will be slower because of the additional work required to migrate the data to the new storage type. In the case of restoring to or from Magnetic (Standard) storage, the migration process is the slowest as Magnetic storage does not have the IOPS capability of Provisioned IOPS or General Purpose (SSD) storage. In this example, you restore from a previously created DB snapshot called mydbsnapshot and create a new DB instance called mynewdbinstance. AWS Management Console To restore a DB instance from a DB snapshot 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. API Version 2014-10-31 154 Amazon Relational Database Service User Guide Restoring From a DB Snapshot 2. In the navigation pane, choose Snapshots. 3. Choose the DB snapshot that you want to restore from. 4. Choose Restore Snapshot. The Restore DB Instance window appears. 5. Type the name of the restored DB instance in the DB Instance Identifier text box. 6. Choose Restore DB Instance. 7. Only the default DB parameter and security groups are associated with the restored instance. If you want to restore the functionality of the DB instance to that of the DB instance that the snapshot was created from, you must modify the DB instance to use the security group and parameter group used by the previous DB instance. The next steps assume that your DB instance is in a VPC; if your DB instance is not in a VPC, use the EC2 Management Console to locate the security group you need for the DB instance. 8. Sign in to the AWS Management Console and open the Amazon VPC console at https:// console.aws.amazon.com/vpc/. 9. In the navigation pane, choose Security Groups. 10. Select the security group that you want to use for your DB instances. If you need to add rules to link the security group to a security group for an EC2 instance, see A DB Instance in a VPC Accessed by an EC2 Instance in the Same VPC (p. 396) for more information. CLI To restore a DB instance from a DB snapshot, use the AWS CLI command restore-db-instance-fromdb-snapshot. API Version 2014-10-31 155 Amazon Relational Database Service User Guide Restoring From a DB Snapshot Example For Linux, OS X, or Unix: aws rds restore-db-instance-from-db-snapshot \ --db-instance-identifier mynewdbinstance \ --db-snapshot-identifier mydbsnapshot For Windows: aws rds restore-db-instance-from-db-snapshot ^ --db-instance-identifier mynewdbinstance ^ --db-snapshot-identifier mydbsnapshot This command returns output similar to the following: DBINSTANCE mynewdbinstance db.m3.large MySQL creating 3 n 5.6.27 general-public-license 50 sa After the DB instance has been restored, you must add the DB instance to the security group and parameter group used by the DB instance used to create the DB snapshot if you want the same functionality as that of the previous DB instance. API To restore a DB instance from a DB snapshot, call the Amazon RDS API function RestoreDBInstanceFromDBSnapshot with the following parameters: • DBSnapshotIdentifier = rds:mysqldb-2014-04-22-08-15 • DBInstanceIdentifier = mynewdbinstance Example https://rds.us-east-1.amazonaws.com/ ?Action=RestoreDBInstanceFromDBSnapshot &DBInstanceIdentifier=mynewdbinstance &DBSnapshotIdentifier=rds%3Amysqldb-2014-04-22-08-15 &SignatureMethod=HmacSHA256 &SignatureVersion=4 &Version=2013-09-09 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20140428/us-east-1/rds/aws4_request &X-Amz-Date=20140428T232655Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=78ac761e8c8f54a8c0727f4e67ad0a766fbb0024510b9aa34ea6d1f7df52fe92 Related Topics • Creating a DB Snapshot (p. 152) • Copying a DB Snapshot (p. 158) • Sharing a DB Snapshot or DB Cluster Snapshot (p. 166) API Version 2014-10-31 156 Amazon Relational Database Service User Guide Restoring From a DB Snapshot • DB Snapshots (p. 124) API Version 2014-10-31 157 Amazon Relational Database Service User Guide Copying a DB Snapshot Copying a DB Snapshot With Amazon Relational Database Service (Amazon RDS), you can copy a DB snapshot using one of these methods: • Copy an automated or manual DB snapshot to create a manual DB snapshot in the same AWS region. • Copy either an automated or manual DB snapshot from one region to another region. • Copy an automated or manual DB cluster snapshot (Aurora) to create a manual DB cluster snapshot in the same AWS region. You cannot copy a DB cluster snapshot to a different region. To copy a DB snapshot, use the AWS Management Console, the copy-db-snapshot commmand, or the CopyDBSnapshot API action. To copy an Amazon Aurora DB cluster snapshot, use the AWS Management Console, the copy-dbcluster-snapshot commmand, or the CopyDBClusterSnapshot API action. If you create a manual DB snapshot or DB cluster snapshot, you can keep that snapshot indefinitely. However, automated snapshots are deleted after their retention period expires. Amazon RDS storage costs may apply to your snapshot backups. For information on backup storage costs, see Amazon RDS Pricing. If you copy a DB snapshot to another AWS region, you create a manual DB snapshot that is retained in that region. To copy a DB snapshot to another AWS region, you can use the AWS Management Console, the copy-db-snapshot AWS CLI command, or the CopyDBSnapshot RDS API action. • To copy a DB snapshot to another AWS region by using the AWS Management Console, specify the Destination Region for the DB snapshot on the Make Copy of DB Snapshot page. • To copy a DB snapshot using the copy-db-snapshot CLI command or CopyDBSnapshot API action, issue the command in the AWS region that you want to copy the DB snapshot to, and then use an Amazon RDS Amazon Resource Name (ARN) to specify the source DB snapshot to be copied, including the source region. For information about Amazon RDS ARN formats, see Working with Amazon Resource Names (ARNs) in Amazon RDS (p. 217). Amazon RDS deletes automated snapshots either at the end of their retention period, when you disable automated snapshots for a DB instance or DB cluster, or when you delete a DB instance or DB cluster. If you want to keep an automated snapshot for a longer period, copy it to create a manual snapshot, which is retained until you delete it. Amazon RDS storage costs apply to snapshots that you retain after you delete a DB instance or DB cluster. You can copy a snapshot that has been encrypted using an AWS Key Management System (AWS KMS) encryption key. If you copy an encrypted snapshot, the copy of the snapshot must also be encrypted. You can encrypt the snapshot with the same KMS encryption key as the original snapshot, or you can specify a different KMS encryption key to encrypt the copy of the snapshot. You can also encrypt a copy of an unencrypted snapshot. This can be a quick way to add encryption to a previously unencrypted DB instance. That is, you can create a snapshot of your DB instance or DB cluster when you are ready to encrypt it, and then create a copy of that snapshot and specify a KMS encryption key to encrypt the copy of the snapshot. You can then restore an encrypted DB instance or DB cluster from the encrypted snapshot. You do not need to encrypt an Amazon Aurora DB cluster snapshot in order to create an encrypted copy of an Aurora DB cluster. If you specify a KMS encryption key when restoring from an unencrypted DB cluster snapshot, the restored DB cluster is encrypted using the specified KMS encryption key. API Version 2014-10-31 158 Amazon Relational Database Service User Guide Copying a DB Snapshot You can share manual snapshots with other AWS accounts and copy snapshots shared to you by other AWS accounts. For more information, see Sharing an Encrypted Snapshot (p. 166). Note If you are copying an encrypted snapshot that has been shared from another AWS account, you must have access to the KMS encryption key that was used to encrypt the DB snapshot. You cannot copy encrypted snapshots from other regions. For more information, see Sharing an Encrypted Snapshot (p. 166). Copying a DB Snapshot to Another Region For each AWS account, you can copy up to five DB snapshots at a time from one region to another. Copying a snapshot out of the source region incurs Amazon RDS data transfer charges. For more information about Amazon RDS data transfer pricing, go to Amazon Relational Database Service Pricing. Note Because KMS encryption keys are specific to the region that they are created in, you cannot copy an encrypted snapshot from one region to another. Depending on the regions involved and the amount of data to be copied, a cross-region snapshot can take hours to complete. If there are large numbers of cross-region DB snapshot copy requests from a given source region, Amazon RDS might queue new cross-region copy requests for that source region until some of the in-progress copies have completed. No progress information is displayed about copy requests while they are in the queue. Progress information is displayed when the copy starts. After the DB snapshot copy has been created in the new region, the DB snapshot copy behaves the same as all other DB snapshots in that region. For example, the following CLI copy command results in a DB snapshot in the us-west-2 region with the identifier mysql-instance1-snapshot-20130805copy. For Linux, OS X, or Unix: aws rds copy-db-snapshot \ --source-db-snapshot-identifier arn:aws:rds:useast-1:123456789012:snapshot:mysql-instance1-snapshot-20130805 \ --region us-west-2 \ --target-db-snapshot-identifier mysql-instance1-snapshot-20130805-copy For Windows: aws rds copy-db-snapshot ^ --source-db-snapshot-identifier arn:aws:rds:useast-1:123456789012:snapshot:mysql-instance1-snapshot-20130805 ^ --region us-west-2 ^ --target-db-snapshot-identifier mysql-instance1-snapshot-20130805-copy When the copy is finished, the AWS Management Console shows the DB snapshot with the name mysql-instance1-snapshot-20130805-copy in your list of DB snapshots in us-west-2. You can perform all DB snapshot actions by using the DB snapshot identifier. For example, running the following CLI command in the us-west-2 region will create a new DB instance with data from the DB snapshot copy: For Linux, OS X, or Unix: aws rds restore-db-instance-from-db-snapshot \ --db-instance-identifier mysql-instance1-west \ API Version 2014-10-31 159 Amazon Relational Database Service User Guide Copying a DB Snapshot --region us-west-2 \ --db-snapshot-identifier mysql-instance1-snapshot-20130805-copy For Windows: aws rds restore-db-instance-from-db-snapshot ^ --db-instance-identifier mysql-instance1-west ^ --region us-west-2 ^ --db-snapshot-identifier mysql-instance1-snapshot-20130805-copy There are some limitations to how and where you can copy DB snapshots: • You cannot copy a DB snapshot to or from the AWS GovCloud (US) region. • You cannot copy a DB snapshot across regions if it was created from a DB instance that is using Oracle Transparent Data Encryption (TDE) or Microsoft SQL Server TDE. • You cannot copy a SQL Server DB snapshot across regions if the DB snapshot was created from an instance using Multi-AZ mirroring. A snapshot copied across regions doesn't include either the parameter group or option group that was used by the DB instance the snapshot was created from. When you restore a snapshot to create a new DB instance, that DB instance is assigned the default parameter group and default option group for the region it is created in. To give the new DB instance the same parameters and options as the source, you must do the following: 1. In the destination region, create a parameter group with the same settings as the parameter group used by the source DB instance, or note the name of an existing parameter group that has those settings. 2. In the destination region, create an option group with the same settings as the option group used by the source DB instance, or note the name of an existing option group that has those settings. 3. After restoring the snapshot in the destination region, modify the new DB instance to add the parameter group and option group available in the destination region. AWS Management Console To copy a DB snapshot 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, choose Snapshots. 3. Set Filter to Automated Snapshots. Select the check box for the automated DB snapshot you want to copy. Choose Copy Snapshot The Copy DB Snapshot window appears. 4. Verify that the name of the automated DB snapshot you want to copy appears in Source DB Snapshot. To copy the DB snapshot to a different region, choose that region for Destination Region. Type the name of the DB snapshot copy in New DB Snapshot Identifier. To copy tags and values from the snapshot to the copy of the snapshot, choose Copy Tags. API Version 2014-10-31 160 Amazon Relational Database Service User Guide Copying a DB Snapshot To encrypt the copied DB snapshot, choose Yes for Enable Encryption, and then specify the KMS key identifier to use to encrypt the copied DB snapshot for Master Key. API Version 2014-10-31 161 Amazon Relational Database Service User Guide Copying a DB Snapshot If the DB snapshot being copied is encrypted, specify the KMS key identifier for the KMS encryption key that will be used to encrypt the DB snapshot as the Master Key. API Version 2014-10-31 162 Amazon Relational Database Service User Guide Copying a DB Snapshot 5. Choose Yes, Copy Snapshot. CLI To copy a DB snapshot, use the AWS CLI copy-db-snapshot command. (To copy an Amazon Aurora DB cluster snapshot, use the copy-db-cluster-snapshot commmand. You cannot copy Aurora DB cluster snapshots to different regions.) The following parameters are required: • --source-db-snapshot-identifier • --target-db-snapshot-identifier API Version 2014-10-31 163 Amazon Relational Database Service User Guide Copying a DB Snapshot Example The following code makes a copy of the snapshot rds:mydbinstance-2013-09-04-22-50 named mydbsnapshotcopy. When the copy is made all tags on the original snapshot are copied to the snapshot copy. For Linux, OS X, or Unix: aws rds copy-db-snapshot \ --source-db-snapshot-identifier rds:mydbinstance-2013-09-04-22-50 \ --target-db-snapshot-identifier mydbsnapshotcopy \ --copy-tags For Windows: aws rds copy-db-snapshot ^ --source-db-snapshot-identifier rds:mydbinstance-2013-09-04-22-50 ^ --target-db-snapshot-identifier mydbsnapshotcopy ^ --copy-tags The output from this command should look similar to the following: DBSNAPSHOT mydbsnapshotcopy 2013-09-04T22:51:29.982Z mydbinstance 2013-09-04T22:50:22.355Z mysql 5 available MasterUser default:mysql-5-6 5.6.12 general-public-license manual API To copy a DB snapshot, use the Amazon RDS API CopyDBSnapshot action. (To copy an Amazon Aurora DB cluster snapshot, use the CopyDBClusterSnapshot API action. You cannot copy Aurora DB cluster snapshots to different regions.) The following parameters are required: • SourceDBSnapshotIdentifier = arn%3Aaws%3Ards%3Auseast-1%3A815981987263%3Asnapshot%3Ards%3Amysqldb-2014-04-27-08-15 • TargetDBSnapshotIdentifier = mydbsnapshotcopy Example https://rds.us-east-1.amazonaws.com/ ?Action=CopyDBSnapshot &CopyTags=true &SignatureMethod=HmacSHA256 &SignatureVersion=4 &SourceDBSnapshotIdentifier=arn%3Aaws%3Ards%3Auseast-1%3A815981987263%3Asnapshot%3Ards%3Amysqldb-2014-04-27-08-15 &TargetDBSnapshotIdentifier=mydbsnapshotcopy &Version=2013-09-09 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20140429/us-east-1/rds/aws4_request &X-Amz-Date=20140429T175351Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=9164337efa99caf850e874a1cb7ef62f3cea29d0b448b9e0e7c53b288ddffed2 API Version 2014-10-31 164 Amazon Relational Database Service User Guide Copying a DB Snapshot Related Topics • Creating a DB Snapshot (p. 152) • Restoring From a DB Snapshot (p. 154) • Sharing a DB Snapshot or DB Cluster Snapshot (p. 166) • DB Instance Backups (p. 121) API Version 2014-10-31 165 Amazon Relational Database Service User Guide Sharing a DB Snapshot or DB Cluster Snapshot Sharing a DB Snapshot or DB Cluster Snapshot Using Amazon RDS, you can share a manual DB snapshot or DB cluster snapshot with up to 20 other AWS accounts. AWS accounts that you share a manual snapshot with can copy the snapshot, or restore a DB instance or DB cluster from that snapshot. Using this approach, you can copy a DB instance or DB cluster to another AWS account. For more information on copying a snapshot, see Copying a DB Snapshot (p. 158). For more information on restoring from a snapshot, see Restoring From a DB Snapshot (p. 154). You can also share a manual snapshot as public, which makes the snapshot available to all AWS accounts. Take care when sharing a snapshot as public so that none of your private information is included in any of your public snapshots. You can copy a shared snapshot to another region. For information on copying snapshots to other regions, see Copying a DB Snapshot to Another Region (p. 159). The following limitations apply when sharing manual snapshots with other AWS accounts: • When you restore a DB instance or DB cluster from a shared snapshot using the AWS Command Line Interface (AWS CLI) or Amazon RDS API, you must specify the Amazon Resource Name (ARN) of the shared snapshot as the snapshot identifier. • You cannot share a DB snapshot that uses an option group with permanent or persistent options. A permanent option cannot be removed from an option group. Option groups with persistent options cannot be removed from a DB instance once the option group has been assigned to the DB instance. The following table lists permanent and persistent options and their related DB engines. Option Name Persistent Permanent DB Engine TDE Yes No Microsoft SQL Server Enterprise Edition TDE Yes Yes Oracle Enterprise Edition TDE_HSM Yes Yes Oracle Enterprise Edition Timezone Yes Yes Oracle Enterprise Edition Oracle Standard Edition Oracle Standard Edition One Sharing an Encrypted Snapshot You can share DB snapshots that have been encrypted "at rest" using the AES-256 encryption algorithm, as described in Encrypting Amazon RDS Resources (p. 384). However, users can only copy encrypted DB snapshots if they have access to the AWS Key Management Service (AWS KMS) encryption key that was used to encrypt the DB snapshot. You can share AWS KMS encryption keys with another AWS account by adding the other account to the KMS key policy. Before you share an encrypted DB snapshot, you must first update the KMS key policy by adding any accounts you intend to share the snapshot with. For details on updating a key policy, see Key Policies in the AWS KMS Developer Guide. For an example of creating a key policy, see Allowing Access to an AWS KMS Encryption Key (p. 167) later in this topic. When you have shared your KMS encryption key, you can then share DB snapshots encrypted with that key with other AWS accounts just as you share an unencrypted snapshot. API Version 2014-10-31 166 Amazon Relational Database Service User Guide Sharing a DB Snapshot or DB Cluster Snapshot If you have access to a shared, encrypted DB snapshot, you can copy the DB snapshot and then restore a DB instance from that copy. However, you can't restore a DB instance from the original, source DB snapshot. For more information on copying a DB snapshot, see Copying a DB Snapshot (p. 158). For more information on restoring a DB instance from a DB snapshot, see Restoring From a DB Snapshot (p. 154). These restrictions apply to sharing encrypted snapshots: • You cannot share encrypted DB snapshots as public. • You cannot share encrypted Amazon Aurora DB cluster snapshots. • You cannot share Oracle or Microsoft SQL Server snapshots that are encrypted using Transparent Data Encryption (TDE). Note You cannot share a DB snapshot that has been encrypted using the default AWS KMS encryption key of the AWS account that shared the DB snapshot. Allowing Access to an AWS KMS Encryption Key For another AWS account to copy an encrypted DB snapshot shared from your account, the account that you share your snapshot with must have access to the KMS key that encrypted the snapshot. To allow another AWS account access to a AWS KMS key, update the key policy for the KMS key with the ARN of the AWS account that you are sharing to as a Principal in the KMS key policy, and then allow the kms:CreateGrant action. After you have given an AWS account access to your KMS encryption key, to copy your encrypted snapshot, that AWS account must create an AWS Identify and Access Management (IAM) user if it doesn’t already have one. In addition, that AWS account must also attach an IAM policy to that IAM user that allows the IAM user to copy an encrypted DB snapshot using your KMS key. The account must be an IAM user and cannot be a root AWS account identity due to KMS security restrictions. In the following key policy example, user 111122223333 is the owner of the KMS encryption key, and user 444455556666 is the account that the key is being shared with. This updated key policy gives the AWS account access to the KMS key by including the ARN for the root AWS account identity for user 444455556666 as a Principal for the policy, and by allowing the kms:CreateGrant action. { "Id": "key-policy-1", "Version": "2012-10-17", "Statement": [ { "Sid": "Allow use of the key", "Effect": "Allow", "Principal": {"AWS": [ "arn:aws:iam::111122223333:user/KeyUser", "arn:aws:iam::444455556666:root" ]}, "Action": [ "kms:CreateGrant", "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt", "kms:GenerateDataKey*", "kms:DescribeKey" ], "Resource": "*" }, API Version 2014-10-31 167 Amazon Relational Database Service User Guide Sharing a DB Snapshot or DB Cluster Snapshot { "Sid": "Allow attachment of persistent resources", "Effect": "Allow", "Principal": {"AWS": [ "arn:aws:iam::111122223333:user/KeyUser", "arn:aws:iam::444455556666:root" ]}, "Action": [ "kms:CreateGrant", "kms:ListGrants", "kms:RevokeGrant" ], "Resource": "*", "Condition": {"Bool": {"kms:GrantIsForAWSResource": true}} } ] } Once the external AWS account has access to your KMS key, the owner of that AWS account can create a policy that allows an IAM user created for that account to copy an encrypted DB snapshot encrypted with that KMS key. The following example shows a policy that can be attached to an IAM user for AWS account 444455556666 that enables the IAM user to copy a shared DB snapshot from AWS account 111122223333 that has been encrypted with the KMS key c989c1dd-a3f2-4a5d-8d96e793d082ab26 in the us-west-2 region. { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowUseOfTheKey", "Effect": "Allow", "Action": [ "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:DescribeKey", "kms:CreateGrant", "kms:RetireGrant" ], "Resource": ["arn:aws:kms:us-west-2: 111122223333:key/c989c1dda3f2-4a5d-8d96-e793d082ab26"], }, { "Sid": "AllowAttachmentOfPersistentResources", "Effect": "Allow", "Action": [ "kms:CreateGrant", "kms:ListGrants", "kms:RevokeGrant" ], "Resource": ["arn:aws:kms:us-west-2: 111122223333:key/c989c1dda3f2-4a5d-8d96-e793d082ab26"], "Condition": { API Version 2014-10-31 168 Amazon Relational Database Service User Guide Sharing a DB Snapshot or DB Cluster Snapshot "Bool": { "kms:GrantIsForAWSResource": true } } } ] } For details on updating a key policy, see Key Policies in the AWS KMS Developer Guide. Sharing a Snapshot by Using the Amazon RDS Console Using the Amazon RDS console, you can share a manual DB snapshot with up to 20 AWS accounts. You can also use the console to stop sharing a manual DB snapshot with one or more accounts. To share a manual DB snapshot by using the Amazon RDS console 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, choose Snapshots. 3. For Filter, choose Manual Snapshots, and then select the check box for the manual DB snapshot that you want to share. Choose Share Snapshot. The Manage Snapshot Permissions window appears. 4. For DB Snapshot Visibility, choose Public to permit all AWS accounts to restore a DB instance from your manual DB snapshot. Choose Private to permit only AWS accounts that you specify to restore a DB instance from your manual DB snapshot. Warning If you set DB Snapshot Visibility to Public, all AWS accounts can restore a DB instance from your manual DB snapshot and have access to your data. Do not share any manual DB snapshots that contain private information as Public. 5. For AWS Account ID, type the AWS account identifier for an account that you want to permit to restore a DB instance from your manual DB snapshot, and then choose Add. Repeat to include additional AWS account identifiers, up to 20 AWS accounts. If you make an error when adding an AWS account identifier to the list of permitted accounts, you can delete it from the list by choosing Delete at the right of the incorrect AWS account identifier. API Version 2014-10-31 169 Amazon Relational Database Service User Guide Sharing a DB Snapshot or DB Cluster Snapshot 6. After you have added identifiers for all of the AWS accounts that you want to permit to restore the manual DB snapshot, choose Save to save your changes. To stop sharing a manual DB snapshot with an AWS account 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, choose Snapshots. 3. For Filter, choose Manual Snapshots, and then select the check box for the manual DB snapshot you want to stop sharing with an AWS account. Choose Share Snapshot. 4. To remove permission for an AWS account, choose Delete for the AWS account identifier for that account from the list of authorized accounts. API Version 2014-10-31 170 Amazon Relational Database Service User Guide Sharing a DB Snapshot or DB Cluster Snapshot 5. Choose Save to save your changes. Sharing a Snapshot by Using the Amazon RDS API You can also share a manual DB snapshot with other AWS accounts by using the Amazon RDS API. To do so, call the ModifyDBSnapshotAttribute action for DB instances, or the ModifyDBClusterSnapshotAttribute action for Amazon Aurora DB clusters. Specify restore for AttributeName, and use the ValuesToAdd parameter to add a list of the IDs for the AWS accounts that are authorized to restore the manual DB snapshot. To make the manual DB snapshot public and restorable by all AWS accounts, use the value all. However, take care not to add the all value for any manual DB snapshots that contain private information that you don't want to be available to all AWS accounts. To remove sharing permission for an AWS account, use the ModifyDBSnapshotAttribute or ModifyDBClusterSnapshotAttribute action with AttributeName set to restore and the ValuesToRemove parameter. To mark a manual snapshot as private, remove the value all from the values list for the restore attribute. The following example permits two AWS account identifiers, 123451234512 and 123456789012, to restore the DB snapshot named manual-snapshot1, and removes the all attribute value to mark the DB snapshot as private. https://rds.us-west-2.amazonaws.com/ ?Action=ModifyDBSnapshotAttribute &AttributeName=restore &DBSnapshotIdentifier=manual-snapshot1 &SignatureMethod=HmacSHA256&SignatureVersion=4 &ValuesToAdd.member.1=123451234512 &ValuesToAdd.member.2=123456789012 &ValuesToRemove.member.1=all API Version 2014-10-31 171 Amazon Relational Database Service User Guide Sharing a DB Snapshot or DB Cluster Snapshot &Version=2014-10-31 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20150922/us-west-2/rds/aws4_request &X-Amz-Date=20150922T220515Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=ef38f1ce3dab4e1dbf113d8d2a265c67d17ece1999ffd36be85714ed36dddbb3 To list all of the AWS accounts permitted to restore a DB snapshot, use the DescribeDBSnapshotAttributes or DescribeDBClusterSnapshotAttributes API action. Related Topics • Creating a DB Snapshot (p. 152) • Copying a DB Snapshot (p. 158) • Restoring From a DB Snapshot (p. 154) • DB Instance Backups (p. 121) API Version 2014-10-31 172 Amazon Relational Database Service User Guide Restoring a DB Instance to a Specified Time Restoring a DB Instance to a Specified Time The Amazon RDS automated backup feature automatically creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases. This backup occurs during a daily user-configurable 30 minute period known as the backup window. Automated backups are kept for a configurable number of days (called the backup retention period). You can restore your DB instance to any specific time during this retention period, creating a new DB instance. When you restore a DB instance to a point in time, the default DB security group is applied to the new DB instance. If you need custom DB security groups applied to your DB instance, you must apply them explicitly using the AWS Management Console, the Amazon RDS API ModifyDBInstance action, or the AWS CLI modify-db-instance command once the DB instance is available. You can restore to any point in time during your backup retention period. To determine the latest restorable time for a DB instance, use the AWS CLI describe-db-instances command and look at the value returned in the LatestRestorableTime field for the DB instance. The latest restorable time for a DB instance is typically within 5 minutes of the current time. The OFFLINE, EMERGENCY, and SINGLE_USER modes are not currently supported. Setting any database into one of these modes will cause the latest restorable time to stop moving ahead for the whole instance. Several of the database engines used by Amazon RDS have special considerations when restoring from a point in time. When you restore an Oracle DB instance to a point in time, you can specify a different Oracle DB engine, license model, and DBName (SID) to be used by the new DB instance. When you restore a SQL Server DB instance to a point in time, each database within that instance is restored to a point in time within 1 second of each other database within the instance. Transactions that span multiple databases within the instance may be restored inconsistently. Some actions, such as changing the recovery model of a SQL Server database, can break the sequence of logs that are use for point-in-time recovery. In some cases, Amazon RDS can detect this issue and the latest restorable time is prevented from moving forward; in other cases, such as when a SQL Server database uses the BULK_LOGGED recovery model, the break in log sequence is not detected. It may not be possible to restore a SQL Server DB instance to a point in time if there is a break in the log sequence. For these reasons, Amazon RDS does not support changing the recovery model of SQL Server databases. AWS Management Console To restore a DB instance to a specified time 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. 3. In the navigation pane, click DB Instances. Click Instance Actions, and then click Restore To Point In Time. 4. 5. The Restore DB Instance window appears. Click on the Use Custom Restore Time radio button. Enter the date and time that you wish to restore to in the Use Custom Restore Time text boxes. 6. 7. Type the name of the restored DB instance in the DB Instance Identifier text box. Click the Launch DB Instance button. CLI To restore a DB instance to a specified time, use the ASW CLI command restore-db-instance-topoint-in-time to create a new database instance. API Version 2014-10-31 173 Amazon Relational Database Service User Guide Restoring a DB Instance to a Specified Time Example For Linux, OS X, or Unix: aws rds restore-db-instance-to-point-in-time \ --source-db-instance-identifier mysourcedbinstance \ --target-db-instance-identifier mytargetdbinstance \ --restore-time 2009-10-14T23:45:00.000Z For Windows: aws rds restore-db-instance-to-point-in-time ^ --source-db-instance-identifier mysourcedbinstance ^ --target-db-instance-identifier mytargetdbinstance ^ --restore-time 2009-10-14T23:45:00.000Z API To restore a DB instance to a specified time, call the Amazon RDS API RestoreDBInstanceToPointInTime function with the following parameters: • SourceDBInstanceIdentifier = mysourcedbinstance • TargetDBInstanceIdentifier = mytargetdbinstance • RestoreTime = 2013-10-14T23:45:00.000Z Example https://rds.us-east-1.amazonaws.com/ ?Action=RestoreDBInstanceToPointInTime &RestoreTime=2013-10-14T23%3A45%3A00.000Z &SignatureMethod=HmacSHA256 &SignatureVersion=4 &SourceDBInstanceIdentifier=mysourcedbinstance &TargetDBInstanceIdentifier=mytargetdbinstance &Version=2013-09-09 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20131016/us-east-1/rds/aws4_request &X-Amz-Date=20131016T233051Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;xamz-date &X-AmzSignature=087a8eb41cb1ab0fc9ec1575f23e73757ffc6a1e42d7d2b30b9cc0be988cff97 Related Topics • Creating a DB Snapshot (p. 152) • Restoring From a DB Snapshot (p. 154) • Copying a DB Snapshot (p. 158) • DB Instance Backups (p. 121) API Version 2014-10-31 174 Amazon Relational Database Service User Guide Modifying a DB Instance Modifying a DB Instance and Using the Apply Immediately Parameter Most modifications to a DB instance can be applied immediately, applied during the next maintenance window, or manually applied when you reboot the instance. Some changes can result in an outage because Amazon RDS must reboot the instance for the change to take effect. Some modifications, such as changing a parameter group, require that you manually reboot the DB instance for the change to take effect. When you modify a DB instance, you have the option of applying the changes immediately by selecting the Apply Immediately option in the RDS console or setting the ApplyImmediately parameter to true using the CLI or RDS API. The following table shows when a change is applied when you modify a DB instance setting, and the impact of selecting the Apply Immediately option in the RDS console or setting the ApplyImmediately parameter to true has on that change. Note Changing some DB instance settings cause an outage to occur when the DB instance is rebooted. Review the impact before changing settings. DB Instance Setting If Apply Immediately is set to true If Apply Immediately is set to false Allocated storage Change is made immediately. Performance may be degraded. Automatically upgrade minor versions No difference in when the change is Change is asynchronously applied applied. Change is asynchronously as soon as possible. applied as soon as possible. An outage will occur if this parameter An outage will occur if a newer is set to true during the maintenance minor version is available, and window, and a newer minor version Amazon RDS has enabled auto is available, and RDS has enabled patching for that engine version. auto patching for that engine version. (applies only if you opted in to autoupgrades when you created the DB instance) Backup retention period Change is applied immediately. An immediate outage will occur if you change from 0 to a non-zero value or from a non-zero value to 0. Change is applied during the next maintenance window. Performance may be degraded. If you change the parameter from one non-zero value to another non-zero value, the change is asynchronously applied as soon as possible. In all other cases, the change is applied during the next maintenance window. An outage will occur if you change this parameter from 0 to a non-zero value or from a non-zero value to 0. Database Port Change is applied immediately and the DB instance is rebooted. Apply Immediately is ignored for changes to this parameter. Change is applied immediately and the DB instance is rebooted. Apply Immediately is ignored for changes to this parameter. Instance class Change is applied immediately and an immediate outage will occur. Change is applied during the next maintenance window. Changing this setting causes an outage to occur. API Version 2014-10-31 175 Amazon Relational Database Service User Guide Modifying a DB Instance DB Instance Setting If Apply Immediately is set to true If Apply Immediately is set to false Instance identifier The name change is applied immediately and an immediate outage will occur. The name change is applied during the next maintenance window. Changing this setting causes an outage to occur. Master password No difference in when the change is Change is asynchronously applied applied. Change is asynchronously as soon as possible applied as soon as possible. Multi-AZ Change is applied immediately. Change is applied during the next maintenance window. Option group Change is applied immediately. Change is applied during the next maintenance window. If the parameter change results in an option group that enables OEM, this change can cause a brief (subsecond) period during which new connections are rejected but existing connections are not interrupted. Parameter group name The name change is applied immediately. Any parameter value changes are applied to the DB instance after you manually reboot the DB instance. The name change is applied immediately. Any parameter value changes are applied to the DB instance after you manually reboot the DB instance. Preferred backup window No difference in when the change is Change is asynchronously applied applied. Change is asynchronously as soon as possible. applied as soon as possible. Preferred maintenance window Change is applied immediately. Change is applied immediately. If there are one or more pending actions that cause a outage, and the maintenance window is changed to include the current time, then those pending actions are applied immediately. If you set the window to the current time, there must be at least 30 minutes between the current time and end of the window to ensure pending changes are applied. Publicly Accessible Change is applied immediately. Apply Immediately is ignored for changes to this parameter. Security group name No difference in when the change is Change is asynchronously applied applied. Change is asynchronously as soon as possible. applied as soon as possible. API Version 2014-10-31 176 Change is applied immediately. Apply Immediately is ignored for changes to this parameter. Amazon Relational Database Service User Guide Related Topics DB Instance Setting If Apply Immediately is set to true If Apply Immediately is set to false Storage type Change is applied immediately and in some cases, an immediate outage will occur. Changing from Magnetic to General Purpose (SSD) or Provisioned IOPS (SSD) will result in an outage. Also, changing from Provisioned IOPS (SSD) or General Purpose (SSD) to Magnetic will result in an outage. For more information about storage, see Storage for Amazon RDS (p. 410). Change is applied during the next maintenance window and in some cases an immediate outage will occur at that time. Changing from Magnetic to General Purpose (SSD) or Provisioned IOPS (SSD) will result in an outage. Also, changing from Provisioned IOPS (SSD) or General Purpose (SSD) to Magnetic will result in an outage. For more information about storage, see Storage for Amazon RDS (p. 410). Related Topics • Modifying a DB Instance Running the MariaDB Database Engine (p. 546) • Modifying a DB Instance Running the Microsoft SQL Server Database Engine (p. 598) • Modifying a DB Instance Running the MySQL Database Engine (p. 675) • Modifying a DB Instance Running the Oracle Database Engine (p. 763) • Modifying a DB Instance Running the PostgreSQL Database Engine (p. 929) API Version 2014-10-31 177 Amazon Relational Database Service User Guide Renaming a DB Instance Renaming a DB Instance You can rename a DB instance by using the AWS Management Console, the AWS CLI modify-dbinstance command, or the Amazon RDS API ModifyDBInstance action. Renaming a DB instance can have far-reaching effects; the following is a list of things you should know before you rename a DB instance. • When you rename a DB instance, the endpoint for the DB instance changes, because the URL includes the name you assigned to the DB instance. You should always redirect traffic from the old URL to the new one. • When you rename a DB instance, the old DNS name that was used by the DB instance is immediately deleted, although it could remain cached for a few minutes. The new DNS name for the renamed DB instance becomes effective in about 10 minutes. The renamed DB instance is not available until the new name becomes effective. • You cannot use an existing DB instance name when renaming an instance. • All read replicas associated with a DB instance remain associated with that instance after it is renamed. For example, suppose you have a DB instance that serves your production database and the instance has several associated read replicas. If you rename the DB instance and then replace it in the production environment with a DB snapshot, the DB instance that you renamed will still have the read replicas associated with it. • Metrics and events associated with the name of a DB instance will be maintained if you reuse a DB instance name. For example, if you promote a Read Replica and rename it to be the name of the previous master, the events and metrics associated with the master will be associated with the renamed instance. • DB instance tags remain with the DB instance, regardless of renaming. • DB snapshots are retained for a renamed DB instance. Renaming to Replace an Existing DB Instance The most common reasons for renaming a DB instance are that you are promoting a Read Replica or you are restoring data from a DB snapshot or PITR. By renaming the database, you can replace the DB instance without having to change any application code that references the DB instance. In these cases, you would do the following: 1. Stop all traffic going to the master DB instance. This can involve redirecting traffic from accessing the databases on the DB instance or some other way you want to use to prevent traffic from accessing your databases on the DB instance. 2. Rename the master DB instance to a name that indicates it is no longer the master as described later in this topic. 3. Create a new master DB instance by restoring from a DB snapshot or by promoting a read replica, and then give the new instance the name of the previous master DB instance. 4. Associate any read replicas with the new master DB instance. If you delete the old master DB instance, you are responsible for deleting any unwanted DB snapshots of the old master instance. For information about promoting a Read Replica, see Promoting a Read Replica to Be a DB Instance (p. 201). API Version 2014-10-31 178 Amazon Relational Database Service User Guide AWS Management Console AWS Management Console To rename a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, select DB Instances. 3. 4. Select the check box next to the DB instance you want to rename. From the Instance Actions dropdown menu, select Modify. 5. Enter a new name in the DB Instance Identifier text box. Select the Apply Immediately check box, and then click Continue. 6. Click Modify DB Instance to complete the change. CLI To rename a DB instance, use the AWS CLI command modify-db-instance. Provide the current -db-instance-identifier value and --new-db-instance-identifier parameter with the new name of the DB instance. Example For Linux, OS X, or Unix: aws rds modify-db-instance \ --db-instance-identifier DBInstanceIdentifier \ --new-db-instance-identifier NewDBInstanceIdentifier For Windows: aws rds modify-db-instance ^ --db-instance-identifier DBInstanceIdentifier ^ --new-db-instance-identifier NewDBInstanceIdentifier API To rename a DB instance, call Amazon RDS API function ModifyDBInstance with the following parameters: • DBInstanceIdentifier = existing name for the instance • NewDBInstanceIdentifier = new name for the instance https://rds.amazonaws.com/ ?Action=ModifyDBInstance &DBInstanceIdentifier=mydbinstance &NewDBInstanceIdentifier=mynewdbinstanceidentifier &Version=2012-01-15 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2012-01-20T22%3A06%3A23.624Z &AWSAccessKeyId= &Signature= API Version 2014-10-31 179 Amazon Relational Database Service User Guide Related Topics Related Topics • Modifying a DB Instance Running the MariaDB Database Engine (p. 546) • Modifying a DB Instance Running the Microsoft SQL Server Database Engine (p. 598) • Modifying a DB Instance Running the MySQL Database Engine (p. 675) • Modifying a DB Instance Running the Oracle Database Engine (p. 763) • Modifying a DB Instance Running the PostgreSQL Database Engine (p. 929) API Version 2014-10-31 180 Amazon Relational Database Service User Guide Deleting a DB Instance Deleting a DB Instance You can delete a DB instance in any state and at any time. To delete a DB instance, you must specify the name of the instance and specify if you want to have a final DB snapshot taken of the instance. If the DB instance you are deleting has a status of "Creating," you will not be able to have a final DB snapshot taken. If the DB instance is in a failure state with a status of "failed," "incompatible-restore," or "incompatible-network," you can only delete the instance when the SkipFinalSnapshot parameter is set to "true." Important If you choose not to create a final DB snapshot, you will not be able to later restore the DB instance to its final state. When you delete a DB instance, all automated backups are deleted and cannot be recovered. Manual DB snapshots of the instance are not deleted. If the DB instance you want to delete has a Read Replica, you should either promote the Read Replica or delete it. For more information on promoting a Read Replica, see Promoting a Read Replica to Be a DB Instance (p. 201) In the following examples, you delete a DB instance both with and without a final DB snapshot. Deleting a DB Instance with No Final Snapshot You can skip creating a final DB snapshot if you want to quickly delete a DB instance. Note that when you delete a DB instance, all automated backups are deleted and cannot be recovered. Manual snapshots are not deleted. AWS Management Console To delete a DB instance with no final DB snapshot 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the DB Instances list, select the check box next to the DB instance you wish to delete. 3. Click Instance Actions, and then select Delete from the context menu. 4. Select No in the Create final Snapshot? drop-down list box. 5. Click Yes, Delete. CLI To delete a DB instance with no final DB snapshot, use the AWS CLI delete-db-instance command with the following parameters. • --db-instance-identifier • --skip-final-snapshot API Version 2014-10-31 181 Amazon Relational Database Service User Guide Deleting a DB Instance with a Final Snapshot Example For Linux, OS X, or Unix: aws rds delete-db-instance \ --db-instance-identifier mydbinstance \ --skip-final-snapshot For Linux, OS X, or Unix: aws rds delete-db-instance ^ --db-instance-identifier mydbinstance ^ --skip-final-snapshot API To delete a DB instance with no final DB snapshot, use the AWS CLI delete-db-instance command with the following parameters. • DBInstanceIdentifier = mydbinstance • SkipFinalSnapshot = true Example https://rds.amazonaws.com/ ?Action=DeleteDBInstance &DBInstanceIdentifier=mydbinstance &SkipFinalSnapshot=true &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2009-10-14T22%3A20%3A46.297Z &AWSAccessKeyId= &Signature= Deleting a DB Instance with a Final Snapshot You can create a final DB snapshot if you want to be able to restore a deleted DB instance at a later time. All automated backups will also be deleted and cannot be recovered. Manual snapshots are not deleted. AWS Management Console To delete a DB instance with a final DB snapshot 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the DB Instances list, select the check box next to the DB Instance you wish to delete. 3. Click Instance Actions, and then select Delete from the context menu. 4. Select Yes in the Create final Snapshot? drop-down list box. 5. Type the name of your final DB snapshot into the Final Snapshot name text box. API Version 2014-10-31 182 Amazon Relational Database Service User Guide Deleting a DB Instance with a Final Snapshot 6. Click Yes, Delete. CLI To delete a DB instance with a final DB snapshot, use the AWS CLI delete-db-instance command with the following parameters. • --db-instance-identifier • --final-snapshot-identifier Example For Linux, OS X, or Unix: aws rds delete-db-instance \ --db-instance-identifier mydbinstance \ --final-snapshot-identifier myfinaldbsnapshot For Windows: aws rds delete-db-instance ^ --db-instance-identifier mydbinstance ^ --final-snapshot-identifier myfinaldbsnapshot This command should produce output similar to the following: Once you begin deleting this database, it will no longer be able to accept connections. Are you sure you want to delete this database? [Ny]y DBINSTANCE mydbinstance 2009-10-21T01:54:49.521Z db.m3.medium MySQL 50 sa deleting us-east-1a 3 SECGROUP default active API To delete a DB instance with a final DB snapshot, use the Amazon RDS APIDeleteDBInstance action with the following parameters. • DBInstanceIdentifier = mydbinstance • FinalDBSnapshotIdentifier = myfinaldbsnapshot Example https://rds.amazonaws.com/ ?Action=DeleteDBInstance &DBInstanceIdentifier=mydbinstance &FinalDBSnapshotIdentifier=myfinaldbsnapshot &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2009-10-14T22%3A20%3A46.297Z &AWSAccessKeyId= &Signature= API Version 2014-10-31 183 Amazon Relational Database Service User Guide Related Topics Related Topics • Creating a DB Instance Running the MySQL Database Engine (p. 663) • Amazon RDS DB Instances (p. 108) API Version 2014-10-31 184 Amazon Relational Database Service User Guide Rebooting a DB Instance Rebooting a DB Instance In some cases, if you modify a DB instance, change the DB parameter group associated with the instance, or change a static DB parameter in a parameter group the instances uses, you must reboot the instance for the changes to take effect. Rebooting a DB instance restarts the database engine service. A reboot also applies to the DB instance any modifications to the associated DB parameter group that were pending. Rebooting a DB instance results in a momentary outage of the instance, during which the DB instance status is set to rebooting. If the Amazon RDS instance is configured for MultiAZ, it is possible that the reboot will be conducted through a failover. An Amazon RDS event is created when the reboot is completed. If your DB instance is a Multi-AZ deployment, you can force a failover from one availability zone to another when you select the Reboot option. When you force a failover of your DB instance, Amazon RDS automatically switches to a standby replica in another Availability Zone and updates the DNS record for the DB instance to point to the standby DB instance. As a result, you will need to clean up and re-establish any existing connections to your DB instance. Reboot with failover is beneficial when you want to simulate a failure of a DB instance for testing, or restore operations to the original AZ after a failover occurs. For more information, see High Availability (Multi-AZ). The time required to reboot is a function of the specific database engine's crash recovery process. To improve the reboot time, we recommend that you reduce database activities as much as possible during the reboot process to reduce rollback activity for in-transit transactions. In the console, the Reboot option may be disabled if the DB instance is not in the "Available" state. This can be due to several reasons, such as an in-progress backup or a customer-requested modification or a maintenance-window action. AWS Management Console To reboot a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, click Instances. 3. Select the check box of the DB instance that you want to reboot. 4. Select Instance Actions and then select Reboot from the drop down menu. 5. To force a failover from one AZ to another, select the Reboot with failover? check box in the Reboot DB Instance dialog box. 6. Click Yes, Reboot. To cancel the reboot instead, click Cancel. CLI To reboot a DB instance, use the AWS CLI command reboot-db-instance. To force a failover from one AZ to the other, use the --force-failover parameter. For Linux, OS X, or Unix: aws rds reboot-db-instance \ --db-instance-identifier dbInstanceID \ --force-failover For Windows: API Version 2014-10-31 185 Amazon Relational Database Service User Guide API aws rds reboot-db-instance ^ --db-instance-identifier dbInstanceID ^ --force-failover API To reboot a DB instance, call the Amazon RDS API function RebootDBInstance with the following parameters: • DBInstanceIdentifier=mydbinstance • ForceFailover=true https://rds.amazonaws.com/ ?Action=RebootDBInstance &DBInstanceIdentifier=mydbinstance &ForceFailover=true &Version=2012-01-15 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2012-01-20T22%3A06%3A23.624Z &AWSAccessKeyId= &Signature= API Version 2014-10-31 186 Amazon Relational Database Service User Guide Working with Storage Types Working with Storage Types Data storage in Amazon RDS is specified by selecting a storage type and providing a storage size (GB) when you create or modify a DB instance. You can change the type of storage your instance uses by modifying the DB instance, but changing the type of storage in some cases might result in a short outage for the instance. Changing from Magnetic to either General Purpose (SSD) or Provisioned IOPS (SSD) results in an outage. Also, changing from General Purpose (SSD) or Provisioned IOPS (SSD) to Magnetic results in an outage. The outage time is typically 60–120 seconds. For more information about Amazon RDS storage types, see Amazon RDS Storage Types (p. 410). Increasing the allocated storage does not result in an outage. Note that you cannot reduce the amount of storage once it has been allocated. The only way to reduce the amount of storage allocated to a DB instance is to dump the data out of the DB instance, create a new DB instance with less storage space, and then load the data into the new DB instance. When estimating your storage needs, take into consideration that Amazon RDS allocates a minimum amount of storage for file system structures. This reserved space can be up to 3 percent of the allocated storage for a DB instance, though in most cases the reserved space is far less. You should set up an Amazon CloudWatch alarm for your DB instance's free storage space and react when necessary. For information on setting CloudWatch alarms, see the CloudWatch Getting Started Guide. Topics • Modifying a DB Instance to Use a Different Storage Type (p. 187) • Modifying IOPS and Storage Settings for a DB Instance That Uses Provisioned IOPS Storage (p. 189) • Creating a DB Instance That Uses Provisioned IOPS Storage (p. 191) • Creating a MySQL or MariaDB Read Replica That Uses Provisioned IOPS Storage (p. 193) Modifying a DB Instance to Use a Different Storage Type You can use the Amazon RDS console, the Amazon RDS API, or the Command Line Interface (CLI) to modify a DB instance to use Standard, General Purpose (SSD), or Provisioned IOPS storage. You must specify either a value for allocated storage or specify both allocated storage and IOPS values. You might need to modify the amount of allocated storage in order to maintain the required ratio between IOPS and storage. For more information about the required ratio between IOPS and storage, see the Using Provisioned IOPS Storage with Multi-AZ, Read Replicas, Snapshots, VPC, and DB Instance Classes (p. 416). Note You cannot modify an existing SQL Server DB instance to change storage type or modify storage allocation. In some cases an immediate outage occurs when you convert from one storage type to another. If you change from Magnetic to General Purpose (SSD) or Provisioned IOPS (SSD), a short outage occurs. Also, if you change from Provisioned IOPS (SSD) or General Purpose (SSD) to Magnetic, a short outage occurs. For DB instances in a single Availability Zone, the DB instance might be unavailable for a few minutes when the conversion is initiated. For multi-AZ deployments, the time the DB instance is unavailable is limited to the time it takes for a failover operation to complete, which typically takes less than two minutes. Although your DB instance is available for reads and writes during the conversion, you might experience degraded performance until the conversion process is complete. This process can take several hours. Whenever you change the storage type of a DB instance, the data for that DB instance is migrated to a new volume. The duration of the migration depends on several factors such as database load, API Version 2014-10-31 187 Amazon Relational Database Service User Guide Modifying a DB Instance to Use a Different Storage Type storage size, storage type, and amount of IOPS provisioned (if any). Typical migration times are under 24 hours, but can take up to several days in some cases. During the migration, the DB instance is available for use, but might experience performance degradation. Caution While the migration takes place, nightly backups are suspended and no other Amazon RDS operations can take place, including Modify, Reboot, Delete, Create Read Replica, and Take DB Snapshot. AWS Management Console To modify a DB instance to use a different storage type 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. On the navigation pane on the Amazon RDS console, choose DB Instances. 3. Choose the DB instance that you want to modify. 4. For Instance Actions, choose Modify. 5. Choose the new Storage Type for the DB instance and type a value for Allocated Storage. If you are modifying your DB instance to use the Provisioned IOPS storage type, then you must also provide a Provisioned IOPS value. For more information, see Modifying IOPS and Storage Settings for a DB Instance That Uses Provisioned IOPS Storage (p. 189). 6. To immediately initiate conversion of the DB instance to use the new storage type, select the Apply Immediately check box. If the check box is cleared (the default), the changes are applied during the next maintenance window. In some cases, an immediate outage occurs when the conversion is applied. Changing from Magnetic to General Purpose (SSD) or Provisioned IOPS (SSD) results in an outage. Also, changing from Provisioned IOPS (SSD) or General Purpose (SSD) to Magnetic results in an outage. For more information about storage, see Storage for Amazon RDS (p. 410). 7. When the settings are as you want them, choose Continue. API Version 2014-10-31 188 Amazon Relational Database Service User Guide Modifying IOPS and Storage Settings for a DB Instance That Uses Provisioned IOPS CLI To modify a DB instance to use a different storage type use the AWS CLI modify-db-instance command. Set the following parameters: • --allocated-storage – Amount of storage to be allocated for the DB instance, in gigabytes. • --storage-type – The new storage type for the DB instance. You can specify gp2 for general purpose (SSD), io1 for Provisioned IOPS), or standard for magnetic storage. • --apply-immediately – Use --apply-immediately to initiate conversion immediately, or --no-apply-immediately (the default) to apply the conversion during the next maintenance window. In some cases, an immediate outage occurs when the conversion is applied. Changing from Magnetic to General Purpose (SSD) or Provisioned IOPS (SSD) will result in an outage. Also, changing from Provisioned IOPS (SSD) or General Purpose (SSD) to Magnetic will result in an outage. For more information about storage, see Storage for Amazon RDS (p. 410). API Use the Amazon RDS API ModifyDBInstance action. Set the following parameters: • AllocatedStorage – Amount of storage to be allocated for the DB instance, in gigabytes. • StorageType – The new storage type for the DB instance. You can specify gp2 for general purpose (SSD), io1 for Provisioned IOPS), or standard for magnetic storage. • ApplyImmediately – Set to True if you want to initiate conversion immediately. If False (the default), the conversion is applied during the next maintenance window. In some cases an immediate outage occurs when the conversion is applied. Changing from Magnetic to General Purpose (SSD) or Provisioned IOPS (SSD) will result in an outage. Also, changing from Provisioned IOPS (SSD) or General Purpose (SSD) to Magnetic will result in an outage. For more information about storage, see Storage for Amazon RDS (p. 410). Modifying IOPS and Storage Settings for a DB Instance That Uses Provisioned IOPS Storage You can modify the settings for an Oracle, PostgreSQL, MySQL, or MariaDB DB instance that uses Provisioned IOPS storage by using the AWS Management Console, the Amazon RDS API, or the Command Line Interface (CLI). You must specify the storage type, allocated storage, and the amount of Provisioned IOPS that you require. You can choose from 1000 IOPS and 100 GB of storage up to 30,000 IOPS and 3 TB (3000 GB) of storage, depending on your database engine. You cannot reduce the amount of allocated storage from the value currently allocated for the DB instance. For more information, see Using Provisioned IOPS Storage with Multi-AZ, Read Replicas, Snapshots, VPC, and DB Instance Classes (p. 416). Note You cannot modify the IOPS rate or allocated storage settings for a SQL Server DB instance. AWS Management Console To modify the Provisioned IOPS settings for a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, choose DB Instances. API Version 2014-10-31 189 Amazon Relational Database Service User Guide Modifying IOPS and Storage Settings for a DB Instance That Uses Provisioned IOPS Note To filter the list of DB instances, for Search DB Instances, type a text string for Amazon RDS to use to filter the results. Only DB instances whose names contain the string appear. 3. Choose the DB instance with Provisioned IOPS storage that you want to modify. 4. For Instance Actions, choose Modify. 5. On the Modify DB Instance page, type the value that you want for either Allocated Storage or Provisioned IOPS. If the value you specify for either Allocated Storage or Provisioned IOPS is outside the limits supported by the other parameter, a warning message is displayed indicating the range of values required for the other parameter. 6. To apply the changes to the DB instance immediately, select the Apply Immediately check box. If you leave the check box cleared, the changes are applied during the next maintenance window. 7. Choose Continue. 8. Review the parameters that will be changed, and choose Modify DB Instance to complete the modification. The new value for allocated storage or for provisioned IOPS appears in the Pending Values column. API Version 2014-10-31 190 Amazon Relational Database Service User Guide Creating a DB Instance That Uses Provisioned IOPS Storage CLI To modify the Provisioned IOPS settings for a DB instance use the AWS CLI modify-db-instance command. Set the following parameters: • --storage-type – Set to io1 for Provisioned IOPS. • --allocated-storage – Amount of storage to be allocated for the DB instance, in gigabytes. • --iops – The new amount of Provisioned IOPS for the DB instance, expressed in I/O operations per second. • --apply-immediately – Use --apply-immediately to initiate conversion immediately. Use --no-apply-immediately (the default) to apply the conversion during the next maintenance window. API To modify the Provisioned IOPS settings for a DB instance use the Amazon RDS API ModifyDBInstance action. Set the following parameters: • StorageType – Set to io1 for Provisioned IOPS. • AllocatedStorage – Amount of storage to be allocated for the DB instance, in gigabytes. • Iops – The new IOPS rate for the DB instance, expressed in I/O operations per second. • ApplyImmediately – Set to True if you want to initiate conversion immediately. If False (the default), the conversion is applied during the next maintenance window. Creating a DB Instance That Uses Provisioned IOPS Storage You can create a DB instance that uses Provisioned IOPS by setting several parameters when you launch the DB instance. You can use the AWS Management Console, the Amazon RDS API, or the Command Line Interface (CLI). For more information about the settings you should use when creating a DB instance, see Creating a DB Instance Running the MySQL Database Engine (p. 663), Creating a DB Instance Running the MariaDB Database Engine (p. 533), Creating a DB Instance Running the Oracle Database Engine (p. 750), or Creating a DB Instance Running the Microsoft SQL Server Database Engine (p. 579). AWS Management Console To create a new DB instance that uses Provisioned IOPS storage 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. From the Amazon RDS console, choose Launch DB Instance. API Version 2014-10-31 191 Amazon Relational Database Service User Guide Creating a DB Instance That Uses Provisioned IOPS Storage 3. In the Launch RDS DB Instance wizard, on the Engine Selection page, choose the Select button next to the DB engine that you want. 4. On the Specify DB Details page, choose Provisioned IOPS (SSD) for Storage Type. 5. Specify values for Allocated Storage and Provisioned IOPS. You can change these values but the ratio between provisioned IOPS and allocated storage must be in a range between 3:1 and 10:1 for MySQL, MariaDB, and Oracle instances. SQL Server requires a ratio of 10:1. 6. When the settings are as you want them, choose Continue. Type the remaining values to create the DB instance. CLI To create a new DB instance that uses Provisioned IOPS storage use the AWS CLI create-dbinstance command. Specify the required parameters and include values for the following parameters that apply to Provisioned IOPS storage: • --storage-type – Set to io1 for Provisioned IOPS. • --allocated-storage - Amount of storage to be allocated for the DB instance, in gigabytes. • --iops - The new IOPS rate for the DB instance, expressed in I/O operations per second. API To create a new DB instance that uses Provisioned IOPS storage use the Amazon RDS API CreateDBInstance action. Specify the required parameters and include values for the following parameters that apply to Provisioned IOPS storage: • StorageType – Set to io1 for Provisioned IOPS. • AllocatedStorage - Amount of storage to be allocated for the DB instance, in gigabytes. • Iops - The new IOPS rate for the DB instance, expressed in I/O operations per second. API Version 2014-10-31 192 Amazon Relational Database Service User Guide Creating a MySQL or MariaDB Read Replica That Uses Provisioned IOPS Storage Creating a MySQL or MariaDB Read Replica That Uses Provisioned IOPS Storage You can create a MySQL or MariaDB Read Replica that uses Provisioned IOPS storage. You can create a Read Replica that uses Provisioned IOPS storage by using a source DB instance that uses either standard storage or Provisioned IOPS storage. AWS Management Console For a complete description on how to create a Read Replica, see Creating a Read Replica (p. 199). To create a Read Replica DB instance that uses Provisioned IOPS storage 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the Navigation pane, choose DB Instances. 3. Choose the MySQL or MariaDB DB instance with Provisioned IOPS storage that you want to use as the source for the Read Replica, and choose Instance Actions, Create Read Replica. Important The DB instance that you are creating a Read Replica for must have allocated storage within the range of storage for MySQL and MariaDB PIOPS (100 GB–3 TB). If the allocated storage for that DB instance is not within that range, then the Provisioned IOPS storage type isn't available as an option when creating the Read Replica. Instead, you can set only the GP2 or Standard storage types. You can modify the allocated storage for the source DB instance to be within the range of storage for MySQL and MariaDB PIOPS before creating a Read Replica. For more information on the PIOPS range of storage, see Amazon RDS Provisioned IOPS Storage to Improve Performance (p. 415). For information on modifying a MySQL DB instance, see Modifying a DB Instance Running the MySQL Database Engine (p. 675). For information on modifying a MariaDB DB instance, see Modifying a DB Instance Running the MariaDB Database Engine (p. 546). 4. On the Create Read Replica DB Instance page, type a DB instance identifier for the Read Replica. API Version 2014-10-31 193 Amazon Relational Database Service User Guide Creating a MySQL or MariaDB Read Replica That Uses Provisioned IOPS Storage 5. Choose Yes, Create Read Replica. CLI To create a Read Replica DB instance that uses Provisioned IOPS use the AWS CLI create-dbinstance-read-replica command. Specify the required parameters and include values for the following parameters that apply to Provisioned IOPS storage: • --allocated-storage - Amount of storage to be allocated for the DB instance, in gigabytes. • --iops - The new IOPS rate for the DB instance, expressed in I/O operations per second. API To create a Read Replica DB instance that uses Provisioned IOPS use the Amazon RDS API CreateDBInstanceReadReplica action. Specify the required parameters and include values for the following parameters that apply to Provisioned IOPS storage: • AllocatedStorage - Amount of storage to be allocated for the DB instance, in gigabytes. • Iops - The new IOPS rate for the DB instance, expressed in I/O operations per second. API Version 2014-10-31 194 Amazon Relational Database Service User Guide Working with Read Replicas Working with PostgreSQL, MySQL, and MariaDB Read Replicas Amazon RDS uses the MySQL, MariaDB, and PostgreSQL (version 9.3.5 and later) DB engines' built-in replication functionality to create a special type of DB instance called a Read Replica from a source DB instance. Updates made to the source DB instance are asynchronously copied to the Read Replica. You can reduce the load on your source DB instance by routing read queries from your applications to the Read Replica. Using Read Replicas, you can elastically scale out beyond the capacity constraints of a single DB instance for read-heavy database workloads. Note that the information in this topic applies to creating Amazon RDS Read Replicas either in the same region as the source DB instance, or in a separate region. This topic does not apply to setting up replication with an instance that is running on an Amazon EC2 instance or that is on-premises. When you create a Read Replica, you first specify an existing DB instance as the source. Then, Amazon RDS takes a snapshot of the source instance and creates a read-only instance from the snapshot. Amazon RDS then uses the asynchronous replication method for the DB engine to update the Read Replica whenever there is a change to the source DB instance. The Read Replica operates as a DB instance that allows only read-only connections; applications can connect to a Read Replica the same way they would to any DB instance. Amazon RDS replicates all databases in the source DB instance. Amazon RDS sets up a secure communications channel between the source DB instance and a Read Replica if that Read Replica is in a different AWS region from the DB instance. Amazon RDS establishes any AWS security configurations, such as adding security group entries, needed to enable the secure channel. PostgreSQL DB instances use a secure connection that you can encrypt by setting the ssl parameter to 1 for both the source and the replica instances. Topics • Amazon RDS Read Replica Overview (p. 195) • PostgreSQL Read Replicas (version 9.3.5 and later) (p. 197) • MySQL and MariaDB Read Replicas (p. 198) • Creating a Read Replica (p. 199) • Promoting a Read Replica to Be a DB Instance (p. 201) • Replicating a Read Replica Across Regions (p. 203) • Monitoring Read Replication (p. 208) • Troubleshooting a MySQL or MariaDB Read Replica Problem (p. 210) • Troubleshooting a PostgreSQL Read Replica Problem (p. 211) Amazon RDS Read Replica Overview Deploying one or more Read Replica for a given source DB instance might make sense in a variety of scenarios, including the following: • Scaling beyond the compute or I/O capacity of a single DB instance for read-heavy database workloads. This excess read traffic can be directed to one or more Read Replicas. • Serving read traffic while the source DB instance is unavailable. If your source DB instance cannot take I/O requests (for example, due to I/O suspension for backups or scheduled maintenance), you can direct read traffic to your Read Replica(s). For this use case, keep in mind that the data on the Read Replica might be "stale" because the source DB instance is unavailable. • Business reporting or data warehousing scenarios where you might want business reporting queries to run against a Read Replica, rather than your primary, production DB instance. API Version 2014-10-31 195 Amazon Relational Database Service User Guide Amazon RDS Read Replica Overview By default, a Read Replica is created with the same storage type as the source DB instance. However, you can create a Read Replica that has a different storage type from the source DB instance based on the options listed in the following table. Source DB Instance Storage Type Source DB Instance Storage Allocation Read Replica Storage Type Options PIOPS 100 GB - 3 TB PIOPS | GP2 | Standard GP2 100 GB - 3 TB PIOPS | GP2 | Standard GP2 Less than 100 GB GP2 | Standard Standard 100 GB - 3 TB PIOPS | GP2 | Standard Standard Less than 100 GB GP2 | Standard Amazon RDS does not support circular replication. You cannot configure a DB instance to serve as a replication source for an existing DB instance; you can only create a new Read Replica from an existing DB instance. For example, if MyDBInstance replicates to ReadReplica1, you cannot configure ReadReplica1 to replicate back to MyDBInstance. From ReadReplica1, you can only create a new Read Replica, such as ReadReplica2. For MySQL, MariaDB, and PostgreSQL Read Replicas, you can monitor replication lag in Amazon CloudWatch by viewing the Amazon RDS ReplicaLag metric. For MySQL and MariaDB, the ReplicaLag metric reports the value of the Seconds_Behind_Master field of the SHOW SLAVE STATUS command. For PostgreSQL, the ReplicaLag metric reports the value of SELECT extract(epoch from now() - pg_last_xact_replay_timestamp()) AS slave_lag. Common causes for replication lag for MySQL and MariaDB are the following: • A network outage. • Writing to tables with indexes on a Read Replica. If the read_only parameter is not set to 0 on the Read Replica, it can break replication. • Using a non-transactional storage engine such as MyISAM. Replication is only supported for the InnoDB storage engine on MySQL and the XtraDB storage engine on MariaDB. When the ReplicaLag metric reaches 0, the replica has caught up to the source DB instance. If the ReplicaLag metric returns -1, then replication is currently not active. ReplicaLag = -1 is equivalent to Seconds_Behind_Master = NULL. Differences Between PostgreSQL and MySQL or MariaDB Read Replicas Because the PostgreSQL DB engine implements replication differently than the MySQL and MariaDB DB engines, there are several significant differences you should know about: Feature/Behavior PostgreSQL MySQL and MariaDB What is the replication method? Physical replication. Logical replication. How are transaction logs purged? PostgreSQL has a parameter, Amazon RDS won't delete any wal_keep_segments, that dictates binary logs that have not been how many Write Ahead Log (WAL) applied. files are kept to provide data to the Read Replicas. The parameter API Version 2014-10-31 196 Amazon Relational Database Service User Guide PostgreSQL Read Replicas (version 9.3.5 and later) Feature/Behavior PostgreSQL MySQL and MariaDB value specifies the number of logs to keep. Can a replica be made writable? No. A PostgreSQL Read Replica is a physical copy and PostgreSQL doesn't allow for a Read Replica to be made writeable. Yes. You can enable the MySQL or MariaDB Read Replica to be writable. Can backups be performed on the replica? Yes, you can create a snapshot of a Yes. You can enable automatic PostgreSQL Read Replica, but you backups on a MySQL or MariaDB cannot enable automatic backups. Read Replica. Can you use parallel replication? No. PostgreSQL has a single process handling replication. Yes. MySQL version 5.6 and later and all supported MariaDB versions allow for parallel replication threads. PostgreSQL Read Replicas (version 9.3.5 and later) Amazon RDS PostgreSQL 9.3.5 and later uses PostgreSQL native streaming replication to create a read-only copy of a source (a "master" in Postgres terms) DB instance. This Read Replica (a "standby" in Postgres terms) DB instance is an asynchronously created physical replication of the master DB instance. It is created by a special connection that transmits WAL data between the source DB instance and the Read Replica where PostgreSQL asynchronously streams database changes as they are made. PostgreSQL uses a "replication" role to perform streaming replication. The role is privileged, but, can not be used to modify any data. PostgreSQL uses a single process for handling replication. Creating a PostgreSQL Read Replica does not require an outage for the master DB instance. Amazon RDS sets the necessary parameters and permissions for the source DB instance and the Read Replica without any service interruption. A snapshot is taken of the source DB instance and this snapshot becomes the Read Replica. No outage occurs when you delete a Read Replica either. You can create up to five Read Replicas from one source DB instance. For replication to operate effectively, each Read Replica should have the same amount of compute and storage resources as the source DB instance. If you scale the source DB instance, you should also scale the Read Replicas. Amazon RDS will override any incompatible parameters on the Read Replica if it prevents the Read Replica from starting. For example, if the max_connections parameter value is higher on the source DB instance than on the Read Replica, Amazon RDS will update the parameter on the Read Replica to be the same value as that on the source DB instance. Here are some important facts about PostgreSQL Read Replicas: • PostgreSQL Read Replicas are read-only and cannot be made writeable. • You cannot create a Read Replica from another Read Replica (that is, you cannot create cascading Read Replicas). • You can promote a PostgreSQL Read Replica to be a new source DB instance. Note that the Read Replica does not become the new source DB instance automatically. The Read Replica, when promoted, stops receiving WAL communications and is no longer a read-only instance. You must set up any replication you intend going forward because the promoted Read Replica is now a new source DB instance. • A PostgreSQL Read Replica will report a replication lag of up to five minutes if there are no user transactions occurring on the source DB instance. API Version 2014-10-31 197 Amazon Relational Database Service User Guide MySQL and MariaDB Read Replicas • Before a DB instance can serve as a source DB instance, you must enable automatic backups on the source DB instance by setting the backup retention period to a value other than 0. Situations That Break PostgreSQL Replication There are several situations where a PostgreSQL source DB instance can unintentionally break replication with a Read Replica. These situations include the following: • The max_wal_senders parameter is set too low to provide enough data to the number of Read Replicas. This situation causes replication to stop. • The PostgreSQL parameter, wal_keep_segments, dictates how many Write Ahead Log (WAL) files are kept to provide data to the Read Replicas. The parameter value specifies the number of logs to keep. If you set the parameter value too low, you can cause a Read Replica to fall so far behind that streaming replication stops. In this case, Amazon RDS will report a replication error and begin recovery on the Read Replica by replaying the source DB instance's archived WAL logs. This recovery process continues until the Read Replica has caught up enough to continue streaming replication. For more information on this process and how to determine the appropriate parameter setting, see Troubleshooting a PostgreSQL Read Replica Problem (p. 211). • A PostgreSQL Read Replica will require a reboot if the source DB instance endpoint changes. When the WAL stream that provides data to a Read Replica is broken, PostgreSQL switches into recovery mode to restore the Read Replica by using archived WAL files. Once this process is compete, PostgreSQL will attempt to re-establish streaming replication. MySQL and MariaDB Read Replicas Before a MySQL or MariaDB DB instance can serve as a replication source, you must enable automatic backups on the source DB instance by setting the backup retention period to a value other than 0. This requirement also applies to a Read Replica that is the source DB instance for another Read Replica. Automatic backups are supported only for Read Replicas running any version of MariaDB or MySQL 5.6 and later (not 5.1 or 5.5). You can configure replication based on binary log coordinates for both MySQL and MariaDB instance. For MariaDB instances, you can also configure replication based on global transaction IDs (GTIDs), which provides better crash safety. For more information about configuring replication using GTIDs on a MariaDB DB instance, see Configuring GTID-Based Replication into an Amazon RDS MariaDB DB instance (p. 551). You can create up to five Read Replicas from one DB instance. In order for replication to operate effectively, each Read Replica should have as much compute and storage resources as the source DB instance. If you scale the source DB instance, you should also scale the Read Replicas. If a Read Replica is running any version of MariaDB or MySQL 5.6 and later, you can specify it as the source DB instance for another Read Replica. For example, you can create ReadReplica1 from MyDBInstance, and then create ReadReplica2 from ReadReplica1. Updates made to MyDBInstance are replicated to ReadReplica1 and then replicated from ReadReplica1 to ReadReplica2. You cannot have more than four instances involved in a replication chain. For example, you can create ReadReplica1 from MySourceDBInstance, and then create ReadReplica2 from ReadReplica1, and then create ReadReplica3 from ReadReplica2, but you cannot create a ReadReplica4 from ReadReplica3. To enable automatic backups on a Read Replica for Amazon RDS MariaDB or MySQL version 5.6 and later, first create the Read Replica, then modify the Read Replica to enable automatic backups. Read Replicas are designed to support read queries, but you might need occasional updates, such as adding an index to speed the specific types of queries accessing the replica. You can enable updates by setting the read_only parameter to 0 in the DB parameter group for the Read Replica. API Version 2014-10-31 198 Amazon Relational Database Service User Guide Creating a Read Replica You can run multiple concurrent Read Replica create or delete actions that reference the same source DB instance, as long as you stay within the limit of five Read Replicas for the source instance. You can create a Read Replica from either single-AZ or Multi-AZ DB instance deployments. You use a Multi-AZ deployment to improve the durability and availability of a critical system, but you cannot use the Multi-AZ secondary to serve read-only queries. You must create Read Replicas from a high-traffic, Multi-AZ DB instance to offload read queries from the source DB instance. If the source instance of a Multi-AZ deployment fails over to the secondary, any associated Read Replicas are switched to use the secondary as their replication source. For MySQL and MariaDB DB instances, in some cases Read Replicas cannot be switched to the secondary if some binlog events are not flushed during the failure. In these cases, you must manually delete and recreate the Read Replicas. You can reduce the chance of this happening in MySQL 5.1 or 5.5 by setting the sync_binlog=1 and innodb_support_xa=1 dynamic variables. These settings might reduce performance, so test their impact before implementing the changes to a production environment. These problems are less likely to occur if you use MySQL 5.6 and later or MariaDB. For instances running MySQL 5.6 and later or MariaDB, the parameters are set by default to sync_binlog=1 and innodb_support_xa=1. You usually configure replication between Amazon RDS DB instances, but you can configure replication to import databases from instances of MySQL or MariaDB running outside of Amazon RDS, or to export databases to such instances. For more information, see Importing Data to an Amazon RDS MySQL or MariaDB DB Instance with Reduced Downtime (p. 685) and Using Replication to Export MySQL Data (p. 705). You can stop and restart the replication process on an Amazon RDS DB instance by calling the system stored procedures mysql.rds_stop_replication (p. 724) and mysql.rds_start_replication (p. 723). You can do this when replicating between two Amazon RDS instances for long-running operations such as creating large indexes. You also need to stop and start replication when importing or exporting databases. For more information, see Importing Data to an Amazon RDS MySQL or MariaDB DB Instance with Reduced Downtime (p. 685) and Using Replication to Export MySQL Data (p. 705). You must explicitly delete Read Replicas, using the same mechanisms for deleting a DB instance. If you delete the source DB instance without deleting the replicas, each replica is promoted to a standalone, single-AZ DB instance. If you promote a MySQL or MariaDB Read Replica that is in turn replicating to other Read Replicas, those Read Replicas remain active. Consider an example where MyDBInstance1 replicates to MyDBInstance2, and MyDBInstance2 replicates to MyDBInstance3. If you promote MyDBInstance2, replication from MyDBInstance1 to MyDBInstance2 no longer occurs, but MyDBInstance2 still replicates to MyDBInstance3. If replication is stopped for more than thirty consecutive days, either manually or due to a replication error, Amazon RDS terminates replication between the master DB instance and all Read Replicas in order to prevent increased storage requirements on the master DB instance and long failover times. The Read Replica DB instance is still available, but replication cannot be resumed because the binary logs required by the Read Replica are deleted from the master DB instance after replication is terminated. You can create a new Read Replica for the master DB instance to reestablish replication Creating a Read Replica You can create a Read Replica from an existing MySQL, MariaDB, or PostgreSQL DB instance using the AWS Management Console, CLI, or API. You create a Read Replica by specifying the SourceDBInstanceIdentifier, which is the DB instance identifier of the source DB instance from which you wish to replicate. When you initiate the creation of a Read Replica, Amazon RDS takes a DB snapshot of your source DB instance and begins replication. As a result, you experience a brief I/O suspension on your source API Version 2014-10-31 199 Amazon Relational Database Service User Guide Creating a Read Replica DB instance as the DB snapshot occurs. The I/O suspension typically lasts about one minute and can be avoided if the source DB instance is a Multi-AZ deployment (in the case of Multi-AZ deployments, DB snapshots are taken from the standby). An active, long-running transaction can slow the process of creating the Read Replica, so wait for long-running transactions to complete before creating a Read Replica. If you create multiple Read Replicas in parallel from the same source DB instance, Amazon RDS takes only one snapshot at the start of the first create action. When creating a Read Replica, there are a few things to consider. First, you must enable automatic backups on the source DB instance by setting the backup retention period to a value other than 0. This requirement also applies to a Read Replica that is the source DB instance for another Read Replica. For MySQL DB instances, automatic backups are supported only for Read Replicas running MySQL 5.6 and later, but not for MySQL versions 5.1 or 5.5. To enable automatic backups on an Amazon RDS MySQL version 5.6 and later Read Replica, first create the Read Replica, then modify the Read Replica to enable automatic backups. Preparing MySQL DB Instances That Use MyISAM If your MySQL DB instance uses a non-transactional engine such as MyISAM, you need to perform the following steps to successfully set up your Read Replica. These steps are required to ensure that the Read Replica has a consistent copy of your data. Note that these steps are not required if all of your tables use a transactional engine such as InnoDB. 1. Stop all data manipulation language (DML) and data definition language (DDL) operations on nontransactional tables in the source DB instance and wait for them to complete. SELECT statements can continue running. 2. Flush and lock the tables in the source DB instance. 3. Create the Read Replica using one of the methods in the following sections. 4. Check the progress of the Read Replica creation using, for example, the DescribeDBInstances API operation. Once the Read Replica is available, unlock the tables of the source DB instance and resume normal database operations. AWS Management Console To create a Read Replica from a source MySQL, MariaDB, or PostgreSQL DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, choose DB Instances. 3. In the Instances pane, choose the MySQL, MariaDB, or PostgreSQL DB instance that you want to use as the source for a Read Replica and choose Create Read Replica from Instance Actions. 4. Choose the instance specifications you want to use. It is a best practice to use the same DB instance class and storage type for the Read Replica. 5. Choose the settings you want to use. For DB Instance Identifier, type a name for the Read Replica. Adjust other settings as needed. 6. Choose the network, security, database, and maintenance settings you want to use. 7. Choose Create Read Replica. CLI To create a Read Replica from a source MySQL, MariaDB, or PostgreSQL DB instance, use the AWS CLI command create-db-instance-read-replica. API Version 2014-10-31 200 Amazon Relational Database Service User Guide Promoting a Read Replica to Be a DB Instance Example For Linux, OS X, or Unix: aws rds create-db-instance-read-replica \ --db-instance-identifier myreadreplica \ --source-db-instance-identifier mydbinstance For Windows: aws rds create-db-instance-read-replica ^ --db-instance-identifier myreadreplica ^ --source-db-instance-identifier mydbinstance API To create a Read Replica from a source MySQL, MariaDB, or PostgreSQL DB instance, call the Amazon RDS API function CreateDBInstanceReadReplica. https://rds.amazonaws.com/ ?Action=CreateDBInstanceReadReplica &DBInstanceIdentifier=myreadreplica &SourceDBInstanceIdentifier=mydbinstance &Version=2012-01-15 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2012-01-20T22%3A06%3A23.624Z &AWSAccessKeyId= &Signature= Promoting a Read Replica to Be a DB Instance You can promote a MySQL, MariaDB, or PostgreSQL Read Replica into a stand-alone, single-AZ DB instance. When you promote a Read Replica, the DB instance will be rebooted before it becomes available. There are several reasons you might want to convert a Read Replica into a single-AZ DB instance: • Performing DDL operations (MySQL and MariaDB only) – DDL operations, such as creating or rebuilding indexes, can take time and impose a significant performance penalty on your DB instance. You can perform these operations on a MySQL or MariaDB Read Replica once the Read Replica is in sync with its source DB instance. Then you can promote the Read Replica and direct your applications to use the promoted instance. • Sharding – Sharding embodies the "share-nothing" architecture and essentially involves breaking a large database into several smaller databases. Common ways to split a database include splitting tables that are not joined in the same query onto different hosts or duplicating a table across multiple hosts and then using a hashing algorithm to determine which host receives a given update. You can create Read Replicas corresponding to each of your shards (smaller databases) and promote them when you decide to convert them into stand-alone shards. You can then carve out the key space (if you are splitting rows) or distribution of tables for each of the shards depending on your requirements. • Implementing failure recovery – You can use Read Replica promotion as a data recovery scheme if the source DB instance fails; however, if your use case requires synchronous replication, API Version 2014-10-31 201 Amazon Relational Database Service User Guide Promoting a Read Replica to Be a DB Instance automatic failure detection, and failover, we recommend that you run your DB instance as a Multi-AZ deployment instead. If you are aware of the ramifications and limitations of asynchronous replication and you still want to use Read Replica promotion for data recovery, you first create a Read Replica and then monitor the source DB instance for failures. In the event of a failure, do the following: 1. Promote the Read Replica. 2. Direct database traffic to the promoted DB instance. 3. Create a replacement Read Replica with the promoted DB instance as its source. You can perform all of these operations using the Amazon Relational Database Service API Reference, and you can automate the process by using the Amazon Simple Workflow Service Developer Guide. The new DB instance that is created when you promote a Read Replica retains the backup retention period, backup window period, and parameter group of the former Read Replica source. The promotion process can take several minutes or longer to complete, depending on the size of the Read Replica. Once you promote the Read Replica into a single-AZ DB instance, it is just like any other single-AZ DB instance. For example, you can convert the new DB instance into a Multi-AZ DB instance, and you can create Read Replicas from it. You can also take DB snapshots and perform Point-In-Time Restore operations. Because the promoted DB instance is no longer a Read Replica, you cannot use it as a replication target. If a source DB instance has several Read Replicas, promoting one of the Read Replicas to a DB instance has no effect on the other replicas. We recommend that you enable automated backups on your Read Replica before promoting the Read Replica. This approach ensures that no backup is performed during the promotion process. Once the instance is promoted to a primary instance, backups are performed based on your backup settings. The following steps show the general process for promoting a Read Replica to a single-AZ DB instance. 1. Stop any transactions from being written to the Read Replica source DB instance, and then wait for all updates to be made to the Read Replica. Database updates occur on the Read Replica after they have occurred on the source DB instance, and this replication lag can vary significantly. Use the Replica Lag metric to determine when all updates have been made to the Read Replica. 2. For MySQL and MariaDB only: If you need to make changes to the MySQL or MariaDB Read Replica, you must the set the read_only parameter to 0 in the DB parameter group for the Read Replica. You can then perform all needed DDL operations, such as creating indexes, on the Read Replica. Actions taken on the Read Replica don't affect the performance of the source DB instance. 3. Promote the Read Replica by using the Promote Read Replica option on the Amazon RDS console, the AWS CLI command promote-read-replica, or the PromoteReadReplica Amazon RDS API operation. Note The promotion process takes a few minutes to complete. When you promote a Read Replica, replication is stopped and the Read Replica is rebooted. When the reboot is complete, the Read Replica is available as a single-AZ DB instance. AWS Management Console To promote a Read Replica to a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the Amazon RDS console, choose Read Replicas. 3. In the Read Replicas pane, select the check box beside the Read Replica that you want to promote. API Version 2014-10-31 202 Amazon Relational Database Service User Guide Replicating a Read Replica Across Regions 4. Choose Promote Read Replica. 5. In the Promote Read Replica dialog box, enter the backup retention period and the backup window for the new promoted DB instance. 6. When the settings are as you want them, choose Continue. 7. On the acknowledgment page, choose Yes, Promote. CLI To promote a Read Replica to a DB instance, use the AWS CLI promote-read-replica command. Example For Linux, OS X, or Unix: aws rds promote-read-replica \ --db-instance-identifier myreadreplica For Windows: aws rds promote-read-replica ^ --db-instance-identifier myreadreplica API To promote a Read Replica to a DB instance, call PromoteReadReplica. https://rds.amazonaws.com/ ?Action=PromoteReadReplica &DBInstanceIdentifier=myreadreplica &Version=2012-01-15 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2012-01-20T22%3A06%3A23.624Z &AWSAccessKeyId= &Signature= Replicating a Read Replica Across Regions With Amazon Relational Database Service (Amazon RDS), you can create a MySQL, PostgreSQL, or MariaDB Read Replica in a different AWS Region than the source DB instance. You create a Read Replica to do the following: • Improve your disaster recovery capabilities. • Scale read operations into a region closer to your users. • Make it easier to migrate from a data center in one region to a data center in another region. Creating a MySQL, PostgreSQL, or MariaDB Read Replica in a different region than the source instance is very similar to creating a replica in the same region. To create a Read Replica across regions, you can use the AWS Management Console, run the create-db-instance-read-replica command, or call the CreateDBInstanceReadReplica API action. API Version 2014-10-31 203 Amazon Relational Database Service User Guide Replicating a Read Replica Across Regions Note You can also create a replica of an Amazon Aurora DB cluster in a different region. For more information, see Replicating Amazon Aurora DB Clusters Across AWS Regions (p. 477). The following sections show you how to create a Read Replica from a source MySQL, MariaDB, or PostgreSQL DB instance in a different AWS Region. AWS Management Console You can create a Read Replica across regions using the AWS Management Console. To create a Read Replica across regions with the console 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, choose DB Instances. 3. In the Instances window, choose the MySQL, MariaDB, or PostgreSQL DB instance that you want to use as the source for a Read Replica, and then choose Create Read Replica from Instance Actions. 4. Choose the instance specifications you want to use. We recommend that you use the same DB instance class and storage type for the Read Replica. 5. Choose the other settings you want to use: • For DB Instance Identifier, type a name for the Read Replica. • In the Network & Security section, choose a value for Designation Region and Designation DB Subnet Group. • Choose the remaining network, security, database, and maintenance settings you want to use. 6. Choose Create Read Replica. AWS CLI To create a Read Replica from a source MySQL, MariaDB, or PostgreSQL DB instance in a different AWS Region, you can use the create-db-instance-read-replica command. In this case, you use create-db-instance-read-replica from the AWS Region where you want the Read Replica and specify the Amazon Resource Name (ARN) for the source DB instance. An ARN uniquely identifies a resource created in Amazon Web Services. For example, if your source DB instance is in the US East (N. Virginia) region, the ARN looks similar to the following. arn:aws:rds:us-east-1:123456789012:db:my-mysql-instance For information about ARNs, see Working with Amazon Resource Names (ARNs) in Amazon RDS (p. 217). API Version 2014-10-31 204 Amazon Relational Database Service User Guide Replicating a Read Replica Across Regions Example For Linux, OS X, or Unix: aws rds create-db-instance-read-replica \ --db-instance-identifier DBInstanceIdentifier \ --region us-west-2 \ --source-db-instance-identifier arn:aws:rds:us-east-1:123456789012:db:mymysql-instance For Windows: aws rds create-db-instance-read-replica ^ --db-instance-identifier DBInstanceIdentifier ^ --region us-west-2 ^ --source-db-instance-identifier arn:aws:rds:us-east-1:123456789012:db:mymysql-instance API To create a Read Replica from a source MySQL, MariaDB, or PostgreSQL DB instance in a different AWS Region, you can call the Amazon RDS API function CreateDBInstanceReadReplica. In this case, you call CreateDBInstanceReadReplica from the AWS Region where you want the Read Replica and specify the Amazon Resource Name (ARN) for the source DB instance. An ARN uniquely identifies a resource created in Amazon Web Services. For example, if your source DB instance is in the US East (N. Virginia) region, the ARN looks similar to the following. arn:aws:rds:us-east-1:123456789012:db:my-mysql-instance For information about ARNs, see Working with Amazon Resource Names (ARNs) in Amazon RDS (p. 217). Example https://us-west-2.rds.amazonaws.com/ ?Action=CreateDBInstanceReadReplica &DBInstanceIdentifier=myreadreplica &SourceDBInstanceIdentifier=arn:aws:rds:us-east-1:123456789012:db:mymysql-instance &Version=2012-01-15 &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2012-01-20T22%3A06%3A23.624Z &AWSAccessKeyId= &Signature= Cross-Region Replication Considerations All of the considerations for performing replication within a region apply to cross-region replication. The following extra considerations apply when replicating between regions: • You can only replicate between regions when using Amazon RDS DB instances of MariaDB, PostgreSQL versions 9.4.7 and 9.5.2 exclusively, or MySQL 5.6 and later. API Version 2014-10-31 205 Amazon Relational Database Service User Guide Replicating a Read Replica Across Regions • A source DB instance can have cross-region Read Replicas in multiple regions. • You can only create a cross-region Amazon RDS Read Replica from a source Amazon RDS DB instance that is not a Read Replica of another Amazon RDS DB instance. • You cannot set up a replication channel into or out of the AWS GovCloud (US) region. • Encrypted DB instances are currently not supported for cross-region Read Replicas. • You can expect to see a higher level of lag time for any Read Replica that is in a different region than the source instance, due to the longer network channels between regional data centers. • Within a region, all cross-region Read Replicas created from the same source DB instance must either be in the same Amazon VPC or be outside of a VPC. For cross-region Read Replicas, any of the create Read Replica commands that specify the --db-subnet-group-name parameter must specify a DB subnet group from the same VPC. • You can create a cross-region Read Replica in a VPC from a source DB instance that is not in an VPC. You can also create a cross-region Read Replica that is not in an VPC from a source DB instance that is in a VPC. Cross-Region Replication Costs The data transferred for cross-region replication incurs Amazon RDS data transfer charges. These cross-region replication actions generate charges for the data transferred out of the source region: • When you create a Read Replica, Amazon RDS takes a snapshot of the source instance and transfers the snapshot to the Read Replica region. • For each data modification made in the source databases, Amazon RDS transfers data from the source region to the Read Replica region. For more information about Amazon RDS data transfer pricing, see Amazon Relational Database Service Pricing. For MySQL and MariaDB instances, you can reduce your data transfer costs by reducing the number of cross-region Read Replicas that you create. For example, if you have a source DB instance in one region and want to have three Read Replicas in another region, only create one of the Read Replicas from the source DB instance, and then create the other two replicas from the first Read Replica instead of the source DB instance. For example, if you have source-instance-1 in one region, you can do the following: • Create read-replica-1 in the new region, specifying source-instance-1 as the source. • Create read-replica-2 from read-replica-1. • Create read-replica-3 from read-replica-1. In this example, you are only charged for the data transferred from source-instance-1 to readreplica-1. You are not charged for the data transferred from read-replica-1 to the other two replicas because they are all in the same region. If you create all three replicas directly from sourceinstance-1, you are charged for the data transfers to all three replicas. How Amazon RDS Does Cross-Region Replication Amazon RDS uses the following process to create a cross-region Read Replica. Depending on the regions involved and the amount of data in the databases, this process can take hours to complete. You can use this information to determine how far the process has proceeded when you create a cross-region Read Replica: 1. Amazon RDS begins configuring the source DB instance as a replication source and sets the status to modifying. API Version 2014-10-31 206 Amazon Relational Database Service User Guide Replicating a Read Replica Across Regions 2. Amazon RDS begins setting up the specified Read Replica in the destination region and sets the status to creating. 3. Amazon RDS creates an automated DB snapshot of the source DB instance in the source region. The format of the DB snapshot name is rds:-, where is the identifier of the source instance, and is the date and time the copy started. For example, rds:mysourceinstance-2013-11-14-09-24 was created from the instance mysourceinstance at 2013-11-14-09-24. During the creation of an automated DB snapshot, the source DB instance status remains modifying, the Read Replica status remains creating, and the DB snapshot status is creating. The progress column of the DB snapshot page in the console reports how far the DB snapshot creation has progressed. When the DB snapshot is complete, the status of both the DB snapshot and source DB instance are set to available. 4. Amazon RDS begins a cross-region snapshot copy for the initial data transfer. The snapshot copy is listed as an automated snapshot in the destination region with a status of creating. It has the same name as the source DB snapshot. The progress column of the DB snapshot display indicates how far the copy has progressed. When the copy is complete, the status of the DB snapshot copy is set to available. 5. Amazon RDS then uses the copied DB snapshot for the initial data load on the Read Replica. During this phase, the Read Replica will be in the list of DB instances in the destination, with a status of creating. When the load is complete, the Read Replica status is set to available, and the DB snapshot copy is deleted. 6. When the Read Replica reaches the available status, Amazon RDS starts by replicating the changes made to the source instance since the start of the create Read Replica operation. During this phase, the replication lag time for the Read Replica will be greater than 0. For MySQL, MariaDB, and PostgreSQL Read Replicas, you can monitor replication lag in Amazon CloudWatch by viewing the Amazon RDS ReplicaLag metric. For MySQL and MariaDB, the ReplicaLag metric reports the value of the Seconds_Behind_Master field of the SHOW SLAVE STATUS command. For PostgreSQL, the ReplicaLag metric reports the value of SELECT extract(epoch from now() - pg_last_xact_replay_timestamp()) AS slave_lag. Common causes for replication lag for MySQL and MariaDB are the following: • A network outage. • Writing to tables with indexes on a Read Replica. If the read_only parameter is not set to 0 on the Read Replica, it can break replication. • Using a non-transactional storage engine such as MyISAM. Replication is only supported for the InnoDB storage engine on MySQL and the XtraDB storage engine on MariaDB. When the ReplicaLag metric reaches 0, the replica has caught up to the source DB instance. If the ReplicaLag metric returns -1, then replication is currently not active. ReplicaLag = -1 is equivalent to Seconds_Behind_Master = NULL. PostgreSQL (versions 9.4.7 and 9.5.2 exclusively) uses physical replication slots to manage Write Ahead Log (WAL) retention on the source instance. For each cross-region Read Replica instance, Amazon RDS creates a physical replication slot and associates it with the instance. Two Amazon CloudWatch metrics, Oldest Replication Slot Lag and Transaction Logs Disk Usage, show how far behind the most lagging replica is in terms of WAL data received and how much storage is being used for WAL data. The Transaction Logs Disk Usage value can substantially increase when a cross-region Read Replica is lagging significantly. API Version 2014-10-31 207 Amazon Relational Database Service User Guide Monitoring Read Replication Cross-Region Replication Examples Example Create a Cross-Region Read Replica Outside of any VPC The following example creates a Read Replica in us-west-2 from a source DB instance in us-east-1. The Read Replica is created outside of a VPC: For Linux, OS X, or Unix: aws rds create-db-instance-read-replica \ --db-instance-identifier SimCoProd01Replica01 \ --region us-west-2 --source-db-instance-identifier arn:aws:rds:useast-1:123456789012:db:SimcoProd01 For Windows: aws rds create-db-instance-read-replica ^ --db-instance-identifier SimCoProd01Replica01 ^ --region us-west-2 --source-db-instance-identifier arn:aws:rds:useast-1:123456789012:db:SimcoProd01 Example Create Cross-Region Read Replica in a VPC This example creates a Read Replica in us-west-2 from a source DB instance in us-east-1. The Read Replica is created in the VPC associated with the specified DB subnet group: For Linux, OS X, or Unix: aws rds create-db-instance-read-replica \ --db-instance-identifier SimCoProd01Replica01 \ --region us-west-2 --db-subnet-group-name my-us-west-2-subnet --source-db-instance-identifier arn:aws:rds:useast-1:123456789012:db:SimcoProd01 For Windows: aws rds create-db-instance-read-replica ^ --db-instance-identifier SimCoProd01Replica01 ^ --region us-west-2 --db-subnet-group-name my-us-west-2-subnet --source-db-instance-identifier arn:aws:rds:useast-1:123456789012:db:SimcoProd01 Monitoring Read Replication You can monitor the status of a Read Replica in several ways. The Amazon RDS console shows the status of a Read Replica; you can also see the status of a Read Replica using the AWS CLI describe-db-instances command or the Amazon RDS API DescribeDBInstances action. API Version 2014-10-31 208 Amazon Relational Database Service User Guide Monitoring Read Replication The status of a Read Replica can be one of the following: • Replicating—The Read Replica is replicating successfully. • Error—An error has occurred with the replication. Check the Replication Error field in the Amazon RDS console or the event log to determine the exact error. For more information about troubleshooting a replication error, see Troubleshooting a MySQL or MariaDB Read Replica Problem (p. 210). • Stopped—(MySQL or MariaDB only) Replication has stopped because of a customer initiated request. • Terminated—The Read Replica has lagged the source DB instance for more than the backup retention period due to replication errors and is terminated. The Read Replica is still accessible for read operations but cannot synchronize with the source instance. If replication errors occur in a Read Replica for more than the backup retention period, replication is terminated to prevent increased storage requirements and long failover times. Broken replication can effect storage because the logs can grow in size and number due to the high volume of errors messages being written to the log. Broken replication can also affect failure recovery due to the time Amazon RDS requires to maintain and process the large number of logs during recovery. You can monitor how far a MySQL or MariaDB Read Replica is lagging the source DB instance by viewing the Seconds_Behind_Master data returned by the MySQL or MariaDB Show Slave Status command, or the CloudWatch Replica Lag statistic. If a replica lags too far behind for your environment, consider deleting and recreating the Read Replica. Also consider increasing the scale of the Read Replica to speed replication. API Version 2014-10-31 209 Amazon Relational Database Service User Guide Troubleshooting a MySQL or MariaDB Read Replica Problem Troubleshooting a MySQL or MariaDB Read Replica Problem MySQL and MariaDB's replication technologies are asynchronous. Because they are asynchronous, occasional BinLogDiskUsage increases on the source DB instance and ReplicaLag on the Read Replica are to be expected. For example, a high volume of write operations to the source DB instance can occur in parallel, while write operations to the Read Replica are serialized using a single I/O thread, can lead to a lag between the source instance and Read Replica. For more information about read-only replicas in the MySQL documentation, see Replication Implementation Details. For more information about read-only replicas in the MariaDB documentation, go to Replication Overview. You can do several things to reduce the lag between updates to a source DB instance and the subsequent updates to the Read Replica, such as the following: • Sizing a Read Replica to have a storage size and DB instance class comparable to the source DB instance. • Ensuring that parameter settings in the DB parameter groups used by the source DB instance and the Read Replica are compatible. For more information and an example, see the discussion of the max_allowed_packet parameter later in this section. Amazon RDS monitors the replication status of your Read Replicas and updates the Replication State field of the Read Replica instance to Error if replication stops for any reason, such as DML queries being run on your Read Replica that conflict with the updates made on the source DB instance. You can review the details of the associated error thrown by the MySQL or MariaDB engines by viewing the Replication Error field. Events that indicate the status of the Read Replica are also generated, including RDS-EVENT-0045 (p. 308), RDS-EVENT-0046 (p. 308), and RDSEVENT-0047 (p. 307). For more information about events and subscribing to events, see Using Amazon RDS Event Notification (p. 304). If a MySQL error message is returned, review the error number in the MySQL error message documentation. If a MariaDB error message is returned, review the error in the MariaDB error message documentation. One common issue that can cause replication errors is when the value for the max_allowed_packet parameter for a Read Replica is less than the max_allowed_packet parameter for the source DB instance. The max_allowed_packet parameter is a custom parameter that you can set in a DB parameter group that is used to specify the maximum size of DML that can be executed on the database. If the max_allowed_packet parameter value in the DB parameter group associated with a source DB instance is smaller than the max_allowed_packet parameter value in the DB parameter group associated with the source's Read Replica, the replication process can throw an error (Packet bigger than 'max_allowed_packet' bytes) and stop replication. You can fix the error by having the source and Read Replica use DB parameter groups with the same max_allowed_packet parameter values. Other common situations that can cause replication errors include the following: • Writing to tables on a Read Replica. If you are creating indexes on a Read Replica, you need to have the read_only parameter set to 0 to create the indexes. If you are writing to tables on the Read Replica, it might break replication. • Using a non-transactional storage engine such as MyISAM. Read replicas require a transactional storage engine. Replication is only supported for the InnoDB storage engine on MySQL and the XtraDB storage engine on MariaDB. • Using unsafe nondeterministic queries such as SYSDATE(). For more information, see Determination of Safe and Unsafe Statements in Binary Logging. If you decide that you can safely skip an error, you can follow the steps described in the section Skipping the Current Replication Error (p. 709). Otherwise, you can delete the Read Replica and API Version 2014-10-31 210 Amazon Relational Database Service User Guide Troubleshooting a PostgreSQL Read Replica Problem create a instance using the same DB instance identifier so that the endpoint remains the same as that of your old Read Replica. If a replication error is fixed, the Replication State changes to replicating. Troubleshooting a PostgreSQL Read Replica Problem PostgreSQL uses replication slots for cross-region replication, so the process for troubleshooting same region and cross region replication problems is different. Troubleshooting PostgreSQL Read Replica Problems Within a Region The PostgreSQL parameter, wal_keep_segments, dictates how many Write Ahead Log (WAL) files are kept to provide data to the Read Replicas. The parameter value specifies the number of logs to keep. If you set the parameter value too low, you can cause a Read Replica to fall so far behind that streaming replication stops. In this case, Amazon RDS will report a replication error and begin recovery on the Read Replica by replaying the source DB instance's archived WAL logs. This recovery process continues until the Read Replica has caught up enough to continue streaming replication. The PostgreSQL log will show when Amazon RDS is recovering a Read Replica that is this state by replaying archived WAL files. 2014-11-07 19:01:10 UTC::@:[23180]:DEBUG: switched WAL source from archive to stream after failure 2014-11-07 19:01:10 UTC::@:[11575]:LOG: started streaming WAL from primary at 1A/D3000000 on timeline 1 2014-11-07 19:01:10 UTC::@:[11575]:FATAL: could not receive data from WAL stream: ERROR: requested WAL segment 000000010000001A000000D3 has already been removed 2014-11-07 19:01:10 UTC::@:[23180]:DEBUG: could not restore file "00000002.history" from archive: return code 0 2014-11-07 19:01:15 UTC::@:[23180]:DEBUG: switched WAL source from stream to archive after failure recovering 000000010000001A000000D3 2014-11-07 19:01:16 UTC::@: [23180]:LOG: restored log file "000000010000001A000000D3" from archive Once Amazon RDS has replayed enough archived WAL files on the replica to catch up and allow the Read Replica to begin streaming again, PostgreSQL will resume streaming and write a similar line to the following to the log file: 2014-11-07 19:41:36 UTC::@:[24714]:LOG: at 1B/B6000000 on timeline 1 started streaming WAL from primary You can determine how many WAL files you should keep by looking at the checkpoint information in the log. The PostgreSQL log shows the following information at each checkpoint. By looking at the "# recycled" transaction log files of these log statements, a user can understand how many transaction files will be recycled during a time range and use this information to tune the wal_keep_segments parameter. API Version 2014-10-31 211 Amazon Relational Database Service User Guide Troubleshooting a PostgreSQL Read Replica Problem 2014-11-07 19:59:35 UTC::@:[26820]:LOG: checkpoint complete: wrote 376 buffers (0.2%); 0 transaction log file(s) added, 0 removed, 1 recycled; write=35.681 s, sync=0.013 s, total=35.703 s; sync files=10, longest=0.013 s, average=0.001 s For example, if the PostgreSQL log shows that 35 files are recycled from the "checkpoint completed" log statements within a 5 minute time frame, we know that with this usage pattern a Read Replica relies on 35 transaction files in 5 minutes and could not survive 5 minutes in a non-streaming state if the source DB instance is set to the default wal_keep_segments parameter value of 32. Troubleshooting PostgreSQL Read Replica Problems Across Regions PostgreSQL (versions 9.4.7 and 9.5.2 exclusively) uses physical replication slots to manage Write Ahead Log (WAL) retention on the source DB instance. For each cross-region Read Replica instance, Amazon RDS creates and associates a physical replication slot. You can use two Amazon CloudWatch metrics, Oldest Replication Slot Lag and Transaction Logs Disk Usage, to see how far behind the most lagging replica is in terms of WAL data received and to see how much storage is being used for WAL data. The Transaction Logs Disk Usage value can substantially increase when a cross-region Read Replica is lagging significantly. If the workload on your DB instance generates a large amount of WAL data, you might need to change the DB instance class of your source DB instance and Read Replica to one with High / 10Gb network performance for the replica to keep up. The Amazon CloudWatch metric Transaction Logs Generation can help you understand the rate at which your workload is generating WAL data. To determine the status of a cross-region Read Replica, you can query pg_replication_slots on the source instance, as in the following example: postgres=# select * from pg_replication_slots; slot_name | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn ____________________________________________________________________________________________ rds_us_east_1_db_uzwlholddgpblksce6hgw4nkte | | physical | | | t | 12598 | | | 4E/95000060 (1 row) API Version 2014-10-31 212 Amazon Relational Database Service User Guide Tagging Amazon RDS Resources Tagging Amazon RDS Resources What You Should Know About Amazon RDS Resource Tags You can use Amazon RDS tags to add metadata to your Amazon RDS resources. In addition, these tags can be used with IAM policies to manage access to Amazon RDS resources and to control what actions can be applied to the Amazon RDS resources. Finally, these tags can be used to track costs by grouping expenses for similarly tagged resources. All Amazon RDS resources can be tagged: • DB instances • DB clusters • Read replicas • DB snapshots • DB cluster snapshots • Reserved DB instances • Event subscriptions • DB option groups • DB parameter groups • DB cluster parameter groups • DB security groups • DB subnet groups For information on managing access to tagged resources with IAM policies, see Authentication and Access Control for Amazon RDS (p. 357). An Amazon RDS tag is a name-value pair that you define and associate with an Amazon RDS resource. The name is referred to as the key. Supplying a value for the key is optional. You can use tags to assign arbitrary information to an Amazon RDS resource. A tag key could be used, for example, to define a category, and the tag value could be a item in that category. For example, you could define a tag key of “project” and a tag value of “Salix,” indicating that the Amazon RDS resource is assigned to the Salix project. You could also use tags to designate Amazon RDS resources as being used for test or production by using a key such as environment=test or environment =production. We recommend that you use a consistent set of tag keys to make it easier to track metadata associated with Amazon RDS resources. Use tags to organize your AWS bill to reflect your own cost structure. To do this, sign up to get your AWS account bill with tag key values included. Then, to see the cost of combined resources, organize your billing information according to resources with the same tag key values. For example, you can tag several resources with a specific application name, and then organize your billing information to see the total cost of that application across several services. For more information, see Cost Allocation and Tagging in About AWS Billing and Cost Management. Each Amazon RDS resource has a tag set, which contains all the tags that are assigned to that Amazon RDS resource. A tag set can contain as many as ten tags, or it can be empty. If you add a tag to an Amazon RDS resource that has the same key as an existing tag on resource, the new value overwrites the old value. AWS does not apply any semantic meaning to your tags; tags are interpreted strictly as character strings. Amazon RDS may set tags on a DB instance or other Amazon RDS resources, depending on API Version 2014-10-31 213 Amazon Relational Database Service User Guide AWS Management Console the settings that you use when you create the resource. For example, Amazon RDS may add a tag indicating that a DB instance is for production or for testing. The following list describes the characteristics of a DB instance tag. • The tag key is the required name of the tag. The string value can be from 1 to 128 Unicode characters in length and cannot be prefixed with "aws:" or "rds:". The string may contain only the set of Unicode letters, digits, white-space, '_', '.', '/', '=', '+', '-' (Java regex: "^([\\p{L}\\p{Z}\\p{N}_.:/=+\ \-]*)$"). • The tag value is an optional string value of the tag. The string value can be from 1 to 256 Unicode characters in length and cannot be prefixed with "aws:". The string may contain only the set of Unicode letters, digits, white-space, '_', '.', '/', '=', '+', '-' (Java regex: "^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-]*)$"). Values do not have to be unique in a tag set and can be null. For example, you can have a key-value pair in a tag set of project/Trinity and cost-center/Trinity. You can use the AWS Management Console, the command line interface, or the Amazon RDS API to add, list, and delete tags on Amazon RDS resources. When using the command line interface or the Amazon RDS API, you must provide the Amazon Resource Name (ARN) for the Amazon RDS resource you want to work with. For more information about constructing an ARN, see Constructing a New Amazon RDS ARN (p. 217). Note that tags are cached for authorization purposes. Because of this, additions and updates to tags on Amazon RDS resources may take several minutes before they are available. Copying Tags When you create or restore a DB instance, you can specify that the tags from the DB instance are copied to snapshots of the DB instance. Copying tags ensures that the metadata for the DB snapshots matches that of the source DB instance and any access policies for the DB snapshot also match those of the source DB instance. Tags are not copied by default. You can specify that tags are copied to DB snapshots for the following actions: • Creating a DB instance. • Restoring a DB instance. • Creating a Read Replica. • Copying a DB snapshot. Note If you include a value for the --tag-key parameter of the create-db-snapshot AWS CLI command (or supply at least one tag to the CreateDBSnapshot API action) then RDS will not copy tags from the source DB instance to the new DB snapshot. This functionality applies even if the source DB instance has the --copy-tags-to-snapshot (CopyTagsToSnapshot) option enabled. If you take this approach, you can create a copy of a DB instance from a DB snapshot without adding tags that don't apply to the new DB instance. Once you have created your DB snapshot using the AWS CLI create-db-snapshot command (or the CreateDBSnapshot Amazon RDS API action) you can then add tags as described later in this topic. AWS Management Console The process to tag an Amazon RDS resource is similar for all resources. The following procedure shows how to tag an Amazon RDS DB instance. API Version 2014-10-31 214 Amazon Relational Database Service User Guide AWS Management Console To add a tag to a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, choose Instances. Note To filter the list of DB instances in the DB Instances pane, in the box beside the Viewing box, type a text string. Only DB instances that contain the string will appear. 3. Select the DB instance that you want to tag. The inline summary appears. 4. In the inline summary, choose the details icon to open the details section. 5. In the details section, scroll down and choose Tags to open the tags section. 6. Choose Add/Edit Tags. The Tag DB Instance pane appears. 7. Choose Add another Tag. 8. Type a key and value for the tag, and then choose Save Tags. To delete a tag from a DB instance 1. Sign in to the AWS Management Console and open the Amazon RDS console at https:// console.aws.amazon.com/rds/. 2. In the navigation pane, click Instances. Note To filter the list of DB instances in the DB Instances pane, in the box beside the Viewing box, type a text string. Only DB instances that contain the string will appear. 3. Select the DB instance from which you want to remove a tag. The inline summary appears. 4. In the inline summary, choose the details icon to open the details section. 5. In the details section, scroll down and choose Tags to open the tags section. 6. Choose Add/Edit Tags. The Tag DB Instance pane appears. API Version 2014-10-31 215 Amazon Relational Database Service User Guide CLI 7. Choose the red "X" in the Remove column next to the tag you want to delete, and then choose Save Tags. CLI You can add, list, or remove tags for a DB instance using the AWS CLI. • To add one or more tags to an Amazon RDS resource, use the AWS CLI command add-tags-toresource. • To list the tags on an Amazon RDS resource, use the AWS CLI command list-tags-for-resource. • To remove one or more tags from an Amazon RDS resource, use the AWS CLI command removetags-from-resource. To learn more about how to construct the required ARN, see Constructing a New Amazon RDS ARN (p. 217). API You can add, list, or remove tags for a DB instance using the Amazon RDS API. • To add a tag to an Amazon RDS resource, use the AddTagsToResource operation. • To list tags that are assigned to an Amazon RDS resource, use the ListTagsForResource. • To remove tags from an Amazon RDS resource, use the RemoveTagsFromResource operation. To learn more about how to construct the required ARN, see Constructing a New Amazon RDS ARN (p. 217). When working with XML using the Amazon RDS API, tags use the following schema: Project Trinity User Jones API Version 2014-10-31 216 Amazon Relational Database Service User Guide Working with Amazon Resource Names (ARNs) in Amazon RDS The following table provides a list of the allowed XML tags and their characteristics. Note that values for Key and Value are case dependent. For example, project=Trinity and PROJECT=Trinity are two distinct tags. Tagging element Description TagSet A tag set is a container for all tags assigned to an Amazon RDS resource. There can be only one tag set per resource. You work with a TagSet only through the Amazon RDS API. Tag A tag is a user-defined key-value pair. There can be from 1 to 10 tags in a tag set. Key A key is the required name of the tag. The string value can be from 1 to 128 Unicode characters in length and cannot be prefixed with "rds:" or "aws:". The string may only contain only the set of Unicode letters, digits, white-space, '_', '.', '/', '=', '+', '-' (Java regex: "^([\\p{L}\\p{Z}\\p{N}_.:/=+\ \-]*)$"). Keys must be unique to a tag set. For example, you cannot have a key-pair in a tag set with the key the same but with different values, such as project/ Trinity and project/Xanadu. Value A value is the optional value of the tag. The string value can be from 1 to 256 Unicode characters in length and cannot be prefixed with "rds:" or "aws:". The string may only contain only the set of Unicode letters, digits, white-space, '_', '.', '/', '=', '+', '-' (Java regex: "^([\\p{L}\\p{Z}\\p{N}_.:/=+\ \-]*)$"). Values do not have to be unique in a tag set and can be null. For example, you can have a key-value pair in a tag set of project/Trinity and cost-center/ Trinity. Working with Amazon Resource Names (ARNs) in Amazon RDS Resources created in Amazon Web Services are each uniquely identified with an Amazon Resource Name (ARN). For certain Amazon Relational Database Service (Amazon RDS) operations, you need to uniquely identify an RDS resource by specifying its ARN. For example, to add metadata to an Amazon RDS resource, you must supply the ARN for that Amazon RDS resource. Similarly, when you create an RDS DB instance Read Replica, you need to supply the ARN for the source DB instance. The following sections describe how you can construct a new ARN or get an existing ARN. Constructing a New Amazon RDS ARN Resources created in Amazon Web Services are each uniquely identified with an Amazon Resource Name (ARN). You can construct an ARN for an Amazon RDS resource using the following syntax. arn:aws:rds:::: In this syntax, the indicated items have these meanings: • is the ID of the AWS Region where the Amazon RDS resource was created, such as uswest-2. API Version 2014-10-31 217 Amazon Relational Database Service User Guide Working with Amazon Resource Names (ARNs) in Amazon RDS • is your account number with dashes omitted. To find your account number, sign in to your AWS account at http:///aws.amazon.com, choose My Account/Console, and then My Account. • is the type of Amazon RDS resource, for example a DB instance or cluster. • is the resource identifier for the Amazon RDS resource. The following table shows AWS Region names, the Region ID name you should use when constructing an ARN, and the region endpoints for reference. Region Name Endpoint US East (N. Virginia) Region us-east-1 https://rds.us-east-1.amazonaws.com US West (N. California) Region us-west-1 https://rds.us-west-1.amazonaws.com US West (Oregon) Region us-west-2 https://rds.us-west-2.amazonaws.com EU (Ireland) Region eu-west-1 https://rds.eu-west-1.amazonaws.com EU (Frankfurt) Region eu-central-1 https://rds.eu-central-1.amazonaws.com Asia Pacific (Tokyo) Region ap-northeast-1 https://rds.ap-northeast-1.amazonaws.com Asia Pacific (Seoul) Region ap-northeast-2 https://rds.ap-northeast-2.amazonaws.com Asia Pacific (Singapore) Region ap-southeast-1 https://rds.ap-southeast-1.amazonaws.com Asia Pacific (Sydney) Region ap-southeast-2 https://rds.ap-southeast-2.amazonaws.com South America (Sao Paulo) Region sa-east-1 https://rds.sa-east-1.amazonaws.com China (Beijing) Region cn-north-1 https://rds.cn-north-1.amazonaws.com.cn AWS GovCloud (US) Region us-gov-west-1 https://rds.us-gov-west-1.amazonaws.com The following table shows the format you should use when constructing an ARN for a particular Amazon RDS resource type. Resource Type ARN Format DB instance arn:aws:rds:::db: DB cluster arn:aws:rds:::cluster: Event subscription arn:aws:rds:::es: DB option group arn:aws:rds:::og: