Enabling High Availability With Data Guard On Amazon RDS Custom For Oracle
Enabling High Availability With Data Guard On Amazon RDS Custom For Oracle
© 2021 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Contents
Before you begin/considerations.........................................................................................2
Procedural sections .............................................................................................................3
Step 1: Create and pre-configure the RDS Custom instances .......................................3
Step 2: Fetch the SYS user password of primary_instance .......................................4
Step 3: Drop the database on standby_instance.........................................................7
Step 4: Note the private IP addresses of the Amazon Elastic Compute Cloud (Amazon
EC2) instances .................................................................................................................8
Step 5: Configure the Oracle Data Guard listeners ........................................................9
Step 6: Configure the tnsnames.ora files.....................................................................11
Step 7: Configure the primary_instance in force logging mode ................................13
Security ..............................................................................................................................45
Considerations for security groups ................................................................................45
Conclusion .........................................................................................................................48
Appendix - Handling instance storage full caused by redo logs ......................................49
Contributors .......................................................................................................................48
Document revisions ...........................................................................................................49
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
This guide also explains how to encrypt your HA instances with a VPN tunnel, configure
Oracle Fast-Failover Observer (FSFO) to monitor your HA instances, and allow the
observer to perform automatic failover when the necessary conditions are met.
1
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Overview
Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate,
and scale a relational database in the AWS Cloud. Amazon RDS Custom is a new
deployment type that provides granular control capabilities which enable customers to
access and customize the database environment, and provides an operating system
which allows customers to run third-party software on AWS.
Like Amazon RDS, Amazon RDS Custom automates the undifferentiated heavy lifting,
such as database provisioning, patching, and backups. Amazon RDS Custom gives you
privileged access to the database and underlying operating system in order to support
legacy applications, manually install OS patches and packages, apply custom database
patches, and install third-party security and diagnostic software. You can also configure
database settings and Network File System (NFS) on Amazon RDS Custom.
Oracle Data Guard is a feature of Oracle Database, and it allows you to create and
maintain standby databases as transactionally consistent copies of a production
database. If the production database becomes unavailable, Oracle Data Guard can
promote any standby database to be the production database. This technique
minimizes downtime of the production database. Oracle Data Guard ensures HA, data
protection, and disaster recovery for your production database.
This guide presents one approach to enable HA on your RDS Custom Oracle instances
using Oracle Data Guard. While there are other approaches that are possible, this guide
outlines the supported configuration.
2
2
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Procedural sections
Note: The examples below are described in rds-preview stage in us-east-
2 region. Choose your own AWS regions as appropriate.
a. You can find the subnet group name of the primary_instance with the
following commands:
3
3
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
4
4
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Note: If you have changed the password for the SYS user in the past,
please use the updated password in future steps when the SYS password
is needed, and still go through the steps below to make sure the password
in Secrets Manager is the same between the primary_instance and the
standby_instance.
1. Sign in to the AWS Management Console (the Console) and open the Amazon
RDS console at https://console.aws.amazon.com/rds/.
2. In the navigation pane, choose Databases, and then choose the
primary_instance.
3. Choose Configuration.
4. Note the resource ID for the primary_instance (it will be in this format: db-
ABCDEFGHIJKLMNOPQRS0123456). This paper refers to the resource ID as
primary_resource_id in this section.
To find the DB resource ID of your RDS Custom DB instance, use the describe-db-
instances command.
5
5
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
The following sample output shows the resource ID for your RDS Custom instance. The
prefix is db-.
db-ABCDEFGHIJKLMNOPQRS0123456
To find the secret name of the instance’s SYS user’s secret, use aws secretsmanager
list-secrets. The following example uses db-ABCDEFGHIJKLMNOPQRS0123456 for
the resource ID.
do-not-delete-custom-db-ABCDEFGHIJKLMNOPQRS0123456-7af9e5
You can run the commands in the preceding examples to get the secret name of the
primary_instance and the standby_instance.
To find the secret value of the secret, use aws secretsmanager get-secret-value.
The following example uses do-not-delete-custom-db-
ABCDEFGHIJKLMNOPQRS0123456-7af9e5 as the secret name.
6
6
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
The following sample output shows the secret value. The secret value is the password
this section is trying to retrieve.
hTeudjeijndFDFQLZXwyNDKbKUoJtf1233_9
You can update the secret value for the standby_instance with the
primary_instance's secret value using the preceding examples if they are different.
$ sudo su - rdsdb
b. Start SQL*Plus, shut down the database, and then drop the database.
$ sqlplus / as sysdba
SQL> SHUTDOWN IMMEDIATE
7
7
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
AWS CLI
Example:
To find the DB resource ID of your RDS Custom DB instance, use aws rds
describe-db-instances.
8
8
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
--query 'DBInstances[*].[DBInstanceIdentifier,DbiResourceId]' \
--output text
The following sample output shows the resource ID for your RDS Custom instance. The
prefix is db-.
db-ABCDEFGHIJKLMNOPQRS0123456.
To find the private IP address of the corresponding Amazon EC2 instance, use aws
ec2 describe-instances.
$ sudo su - rdsdb
9
9
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
$ cd /rdsdbbin/oracle/network/admin/
$ ln -s /rdsdbdata/config/listener.ora
4. Append the following entry in a new line without changing the existing entries in
the file:
ADR_BASE_L_ORCL_DG=/rdsdbdata/log
SID_LIST_L_ORCL_DG=(SID_LIST = (SID_DESC = (SID_NAME =
ORCL)(GLOBAL_DBNAME = ORCL) (ORACLE_HOME = /rdsdbbin/oracle)))
L_ORCL_DG=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(PORT =
1140)(HOST = <primary_instance_ipv4>)))
SUBSCRIBE_FOR_NODE_DOWN_EVENT_L_ORCL_DG=OFF
5. Start the new Oracle Data Guard listener with the following command. Make
sure you see the message “The command completed successfully” in the
output.
6. It is also recommended to check the status of the Oracle Data Guard listener
with the command below.
$ sudo su - rdsdb
10
10
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
$ cd /rdsdbbin/oracle/network/admin/
$ ln -s /rdsdbdata/config/listener.ora
10. Append the following entry in a new line without changing the existing entries in
the file:
ADR_BASE_L_ORCL_DG=/rdsdbdata/log
SID_LIST_L_ORCL_DG=(SID_LIST = (SID_DESC = (SID_NAME =
ORCL)(GLOBAL_DBNAME = ORCL) (ORACLE_HOME = /rdsdbbin/oracle)))
L_ORCL_DG=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(PORT =
1140)(HOST = <standby_instance_ipv4>)))
SUBSCRIBE_FOR_NODE_DOWN_EVENT_L_ORCL_DG=OFF
11. Start the new Oracle Data Guard listener. Make sure you see message “The
command completed successfully” in the output.
12. It is also recommended to check the status of the Oracle Data Guard listener
with the command below:
11
11
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
$ sudo su - rdsdb
$ cd /rdsdbbin/oracle/network/admin/
$ ln -s /rdsdbdata/config/tnsnames.ora
4. Define the Transparent Network Substrate (TNS) address names for the
primary_instance and the standby_instance. To allow better identification
for the Oracle Data Guard instances, the TNS address name is usually the
same as the database unique name. In this document, the TNS address name
and the database unique name for the primary_instance is ORCL_A, and for
the standby_instance is ORCL_B.
5. Put the following entry in the tnsnames.ora. Replace ORCL_A and ORCL_B with
the TNS address names you choose. Replace <primary_instance_ipv4>
and <standby_instance_ipv4> as the values obtained in the "Step 4: Note
the private IP addresses of the Amazon EC2 instances” section of the Amazon
RDS User Guide.
12
12
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
ORCL_A
=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<primar
y_instance_ipv4>)(PORT=1140)))(CONNECT_DATA=(SID=ORCL)))
ORCL_B
=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<standb
y_instance_ipv4>)(PORT=1140)))(CONNECT_DATA=(SID=ORCL)))
6. Verify the networking connection and TNS entries by performing the following
commands on both the primary_instance and the standby_instance. A
successful configuration will return OK.
$ tnsping ORCL_A
$ tnsping ORCL_B
Note: If you have multiple standbys then please make sure to add all members’
TNS entries in tnsnames.ora file of all the standbys and primary database
servers.
$ sudo su – rdsdb
3. Start SQL*Plus, and put the database into force logging mode.
$ sqlplus / as sysdba
SQL> ALTER DATABASE FORCE LOGGING;
13
13
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
$ sudo su - rdsdb
c. Start SQL*Plus, and then create the PFILE from the SPFILE.
$ sqlplus / as sysdba
SQL> create pfile='/tmp/initORCL.ora' from spfile;
(On primary_instance)
$ base64 /tmp/initORCL.ora
<copy the exact output of that command>
(On standby_instance)
$ base64 -d > $ORACLE_HOME/dbs/initORCL.ora
<paste the content copied above>
<press enter>
<press "ctrl + d">
3. Check the md5sum of the source and target file, and make sure the output is the
same by running the commands below:
14
14
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
15
15
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
ORCL.__data_transfer_cache_size=0
ORCL.__db_cache_size=6039797760
ORCL.__inmemory_ext_roarea=0
ORCL.__inmemory_ext_rwarea=0
ORCL.__java_pool_size=0
ORCL.__large_pool_size=33554432
ORCL.__oracle_base='/rdsdbbin'#ORACLE_BASE set from environment
ORCL.__pga_aggregate_target=4966055936
ORCL.__sga_target=7449083904
ORCL.__shared_io_pool_size=134217728
ORCL.__shared_pool_size=1207959552
ORCL.__streams_pool_size=0
ORCL.__unified_pga_pool_size=0
*.archive_lag_target=300
*.audit_file_dest='/rdsdbdata/admin/ORCL/adump'
*.compatible='19.0.0'
*.control_files='/rdsdbdata/db/ORCL_A/controlfile/control-
01.ctl'
*.db_block_checking='MEDIUM'
*.db_create_file_dest='/rdsdbdata/db'
*.db_name='ORCL'
*.db_recovery_file_dest_size=1073741824
*.db_unique_name='ORCL_A'
*.dbfips_140=FALSE
*.diagnostic_dest='/rdsdbdata/log'
*.filesystemio_options='setall'
*.heat_map='OFF'
*.job_queue_processes=50
*.local_listener='(address=(protocol=tcp)(host=)(port=8200))'
*.log_archive_dest_1='location="/rdsdbdata/db/ORCL_A/arch/redolo
g", valid_for=(ALL_LOGFILES,ALL_ROLES)'
*.log_archive_format='-%s-%t-%r.arc'
*.max_string_size='STANDARD'
*.memory_max_target=12385852416
*.memory_target=12385852416
*.open_cursors=300
*.pga_aggregate_target=0
*.processes=1673
*.recyclebin='OFF'
*.sga_target=0
*.spfile='/rdsdbbin/oracle/dbs/spfileORCL.ora'
*.undo_tablespace='UNDO_T1'
*.use_large_pages='FALSE'
b. Adjust the memory parameters to the values that are suitable for the
instance class of the standby_instance. The list of memory parameters is:
16
16
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
ORCL.__data_transfer_cache_size=0
ORCL.__db_cache_size=6039797760
ORCL.__inmemory_ext_roarea=0
ORCL.__inmemory_ext_rwarea=0
ORCL.__java_pool_size=0
ORCL.__large_pool_size=33554432
ORCL.__pga_aggregate_target=4966055936
ORCL.__sga_target=7449083904
ORCL.__shared_io_pool_size=134217728
ORCL.__shared_pool_size=1207959552
ORCL.__streams_pool_size=0
ORCL.__unified_pga_pool_size=0
*.memory_max_target=12385852416
*.memory_target=12385852416
*.open_cursors=300
*.pga_aggregate_target=0
*.processes=1673
*.sga_target=0
17
17
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
ORCL.__data_transfer_cache_size=0
ORCL.__db_cache_size=6039797760
ORCL.__inmemory_ext_roarea=0
ORCL.__inmemory_ext_rwarea=0
ORCL.__java_pool_size=0
ORCL.__large_pool_size=33554432
ORCL.__oracle_base='/rdsdbbin'#ORACLE_BASE set from environment
ORCL.__pga_aggregate_target=4966055936
ORCL.__sga_target=7449083904
ORCL.__shared_io_pool_size=134217728
ORCL.__shared_pool_size=1207959552
ORCL.__streams_pool_size=0
ORCL.__unified_pga_pool_size=0
*.archive_lag_target=300
*.audit_file_dest='/rdsdbdata/admin/ORCL/adump'
*.compatible='19.0.0'
*.control_files='/rdsdbdata/db/ORCL_B/controlfile/control-
01.ctl'
*.db_block_checking='MEDIUM'
*.db_create_file_dest='/rdsdbdata/db'
*.db_name='ORCL'
*.db_recovery_file_dest_size=1073741824
*.db_unique_name='ORCL_B'
*.dbfips_140=FALSE
*.diagnostic_dest='/rdsdbdata/log'
*.filesystemio_options='setall'
*.heat_map='OFF'
*.job_queue_processes=50
*.local_listener='(address=(protocol=tcp)(host=)(port=8200))'
*.log_archive_dest_1='location="/rdsdbdata/db/ORCL_B/arch/redolo
g", valid_for=(ALL_LOGFILES,ALL_ROLES)'
*.log_archive_format='-%s-%t-%r.arc'
*.max_string_size='STANDARD'
*.memory_max_target=12385852416
*.memory_target=12385852416
*.open_cursors=300
*.pga_aggregate_target=0
*.processes=1673
*.recyclebin='OFF'
*.sga_target=0
*.spfile='/rdsdbbin/oracle/dbs/spfileORCL.ora'
*.undo_tablespace='UNDO_T1'
*.use_large_pages='FALSE'
18
18
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
# paths
/rdsdbdata/admin/ORCL/adump
/rdsdbdata/db/ORCL_B/controlfile
/rdsdbdata/db
/rdsdbdata/log
/rdsdbdata/db/ORCL_B/arch/
$ mkdir -p /rdsdbdata/db/ORCL_B/controlfile
$ sudo su - rdsdb
$ sqlplus / as sysdba
SQL> create spfile =
'/rdsdbdata/admin/ORCL/pfile/spfileORCL.ora' from pfile;
8. Find the path and the symbolic link of the SPFILE on the primary_instance.
Use this path to create the symbolic link on the standby_instance.
a. Connect to the primary_instance by following the steps in the “Connecting
to your RDS Custom DB instance using AWS Systems Manager” section of
the Amazon RDS User Guide.
b. Switch your root user to rdsdb. RDS Custom uses the rdsdb user and
rdsdb group to run the database.
$ sudo su - rdsdb
19
19
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
$ sqlplus / as sysdba
SQL> show parameter pfile
d. Find the path of the SPFILE from the VALUE column. The following example
uses the path: /rdsdbbin/oracle/dbs/spfileORCL.ora.
e. Exit SQL*Plus.
f. Find out where the symbolic link
/rdsdbbin/oracle/dbs/spfileORCL.ora points to by running the
following commands:
cd /rdsdbbin/oracle/dbs
ls -lrt
g. Note down the path, as you’ll need it in the next step. The following example
uses the path: /rdsdbdata/admin/ORCL/pfile/spfileORCL.ora.
9. Create the same symbolic link on the standby_instance as follows:
a. Connect to the standby_instance by following the steps in the “Connecting
to your RDS Custom DB instance using AWS Systems Manager” section of
the Amazon RDS User Guide.
b. Switch your root user to rdsdb. RDS Custom uses the rdsdb user and
rdsdb group to run the database.
$ sudo su - rdsdb
cd $ORACLE_HOME/dbs
ln -s /rdsdbdata/admin/ORCL/pfile/spfileORCL.ora
20
20
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
mv initORCL.ora /tmp
$ sudo su - rdsdb
3. Start SQL*Plus, and then check the log mode of the database.
$ sqlplus / as sysdba
SQL> archive log list;
4. If the output shows that the database is in archive mode, then skip the following
step:
21
21
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
$ sudo su - rdsdb
$ $ORACLE_HOME/bin/orapwd file=/rdsdbdata/config/orapw
> Input password for SYS
3. On the primary_instance, create and set the dedicated user for Oracle Data
Guard replication. In this example, the name of the user is RDS_DATAGUARD,
and the password is dg_12345$. It is recommended to use the same username
here, but please choose a different password for this user.
$ sqlplus / as sysdba
SQL> CREATE USER RDS_DATAGUARD IDENTIFIED BY dg_12345$;
SQL> GRANT SYSOPER, SYSDG, ADMINISTER DATABASE TRIGGER TO
RDS_DATAGUARD;
SQL> ALTER SYSTEM SET REDO_TRANSPORT_USER=RDS_DATAGUARD
SCOPE=BOTH;
22
22
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
5. Check the md5sum of the source and target file, and make sure the output is the
same by running the commands below:
$ sqlplus / as sysdba
SQL> STARTUP NOMOUNT;
b. Connect RMAN to the target and auxiliary databases. Note: Both instances
of <syspwd> from the command below are the SYS password for the
primary_instance:
23
23
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
RMAN> run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database;
}
ln -sfn /rdsdbdata/log/diag/rdbms/orcl_b/ORCL/trace
/rdsdbbin/oracle/log/trace
ln -sfn /rdsdbdata/log/diag/rdbms/orcl_b/ORCL/incident
/rdsdbbin/oracle/log/incident
$ sudo su - rdsdb
$ sqlplus / as sysdba
SQL> ALTER SYSTEM SET dg_broker_start=true;
10. Enable the Oracle Data Guard configuration on the primary_instance, and
add the standby_instance to the configuration.
a. Connect to the primary_instance.
b. Switch to the rdsdb user: $ sudo su - rdsdb.
c. Start the Oracle Data Guard software by running: dgmgrl /.
24
24
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Members:
h. Set the static connect identifiers for both the primary database and the
standby database. Replace <primary_instance_ipv4> and
<standby_instance_ipv4> with the IP addresses fetched in Step 4: Note
the private IP addresses of the Amazon Elastic Compute Cloud (Amazon
EC2) instancesection.
25
25
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
iii. If the VALUE column for both fal_client and fal_server is null, then
set these values as follows:
$ sqlplus / as sysdba
SQL> show parameter local_listener
(address=(protocol=tcp)(host=)(port=8200))
26
26
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
27
27
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
4. Check the Oracle Data Guard configuration status, and wait for the
configuration status to become successful.
$ sudo su - rdsdb
$ dgmgrl /
DGMGRL> SHOW CONFIGURATION VERBOSE;
28
28
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
3. Start the Oracle Data Guard software by running the following commands:
dgmgrl /
DGMGRL> SHOW CONFIGURATION VERBOSE;
DGMGRL> EDIT DATABASE ORCL_B SET PROPERTY LOGXPTMODE='SYNC';
DGMGRL> EDIT DATABASE ORCL_A SET PROPERTY LOGXPTMODE='SYNC';
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS
MAXAVAILABILITY;
Manual switchover
29
29
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
4. Connect to the RDS_DATAGUARD user that was created in Step 10: Configure
Oracle Data Guard with the password you chose in that step. ORCL_A in the
command is the db_unique_name for the primary_instance.
5. Validate the databases to make sure they are ready for switchover. ORCL_A in
the command is the db_unique_name for the primary_instance. ORCL_B in
the command is the db_unique_name for the standby_instance.
7. Check the Oracle Data Guard configuration to make sure the role has changed
and the configuration is still SUCCESS.
30
30
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Manual failover
To perform the manual failover, you will need to have the Flashback Database turned
on and initiate a database restart for both the primary_instance and the
standby_instance.
$ mkdir -p /rdsdbdata/db/ORCL_B/flashback
31
31
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
b. Create the path for flashback files if it is not already created (replace ORCL_A
with the unique name you use for the primary_instance)
$ mkdir -p /rdsdbdata/db/ORCL_A/flashback
32
32
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
a. The role transition should be finished, but you will see an error message for
the new standby instance similar to the following:
33
33
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
c. Check the Oracle Data Guard configuration to make sure the role has
changed and the configuration is still SUCCESS.
1. Launch another Custom instance to serve as the observer host in the same
subnet group. This step is similar to the step where you launched the
standby_instance in the preceding Procedural sections. Launching the
instance in a different availability zone from the primary and standby instances
is highly recommended.
Note: You can also use an on-premises instance with either the Oracle
Client Administrator software or the full Oracle Database software stack.
34
34
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
b. Create the path for the flashback files if it is not already created (replace
ORCL_B with the unique name you use for the standby_instance).
$ mkdir -p /rdsdbdata/db/ORCL_B/flashback
$ mkdir -p /rdsdbdata/db/ORCL_A/flashback
35
35
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
5. On the primary_instance:
a. Switch to the rdsdb user: $ sudo su - rdsdb.
b. Start the Oracle Data Guard software and run the following commands
(replace ORCL_A and ORCL_B with the DB unique names you use for the
primary_instance and the standby_instance):
dgmgrl /
DGMGRL> EDIT DATABASE 'ORCL_B' SET PROPERTY
FASTSTARTFAILOVERTARGET='ORCL_A';
DGMGRL> EDIT DATABASE 'ORCL_A' SET PROPERTY
FASTSTARTFAILOVERTARGET='ORCL_B';
DGMGRL> ENABLE FAST_START FAILOVER;
6. Connect to the observer host. Follow the instructions in the “Connecting to your
RDS Custom DB instance using AWS Systems Manager” section of the
Amazon RDS User Guide.
7. On the observer, copy the
/rdsdbbin/oracle/network/admin/tnsnames.ora file from the
primary_instance either by scp or base64 encoding as in the example
below:
o Before executing the commands, switch to the rdsdb user: $ sudo su - rdsdb
(On primary_instance)
$ base64 /rdsdbdata/config/tnsnames.ora
<copy the exact output of that command>
36
36
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
8. Verify the networking connection and TNS entries by running the following
commands:
$ tnsping ORCL_A
$ tnsping ORCL_B
9. Start the Oracle Data Guard software and start the observer.
a. Switch to the rdsdb user: $ sudo su - rdsdb.
b. Run this command: $ nohup dgmgrl -silent
sys/<sys_password>@orcl_a "start observer" &.
10. Go to the primary_instance and switch to the rdsdb user: $ sudo su -
rdsdb.
11. Start the Oracle Data Guard software by running: dgmgrl /.
12. Check the Oracle Data Guard configuration by running the following command:
1. On the primary_instance:
a. Switch to rdsdb user: $ sudo su - rdsdb.
b. Start SQL*Plus: $ sqlplus / as sysdba.
c. Before you test the automatic failover with FSFO, make sure the Flashback
Database has at least 30 minutes of history.
37
37
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
2. On observer host, the log is captured in ~/nohup.out. The log should look
something like the following:
2021-05-20T01:12:33.855+00:00
Initiating Fast-Start Failover to database "orcl_b"...
[S005 2021-05-20T01:12:33.855+00:00] Initiating Fast-start
Failover.
Performing failover NOW, please wait...
Failover succeeded, new primary is "orcl_b"
a. If the output indicates the old primary/new standby is down, start it as follows:
$ sqlplus / as sysdba.
38
38
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
iii. After this, you will see the log on observer like below, which indicates the
FSFO failover is successful:
2021-05-20T01:19:39.978+00:00
Initiating reinstatement for database "orcl_a"...
Reinstating database "orcl_a", please wait...
[W000 2021-05-20T01:19:59.000+00:00] The standby orcl_a is ready
to be a FSFO target
Reinstatement of database "orcl_a" succeeded
4. Check the Oracle Data Guard configuration to make sure the role has changed
and the configuration is still SUCCESS.
Note: RDS Custom does not currently provide API based functionality to
promote a read replica to Primary. But you can choose to perform manual
promotion of read replica using following steps:
39
39
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
40
40
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
16. Final Step is to Stop and Remove DG Listener from the listener.ora and
remove the tnsnames.ora from the standby and primary host.
41
41
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
On standby_instance:
42
42
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
$ dgmgrl /
DGMGRL> show configuration verbose;
DGMGRL> disable database "ORCL_D";
DGMGRL> remove database "ORCL_D";
DGMGRL> show configuration verbose;
43
43
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
14. Stop and remove DG Listener from the listener.ora and tnsnames.ora
from ORCL_D and then remove TNS entry if ORCL_D from the
primary_instance, standby_instance, and ORCL_C.
a. On ORCL_D, stop the listener:
44
44
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Security
Considerations for security groups
Configure VPC:
To connect to your DB instance, the DB must be associated with a security group that
contains the necessary IP addresses and network configuration. If your DB instance
was assigned to a default, non-configured security group when it was created, the
firewall prevents connections.
To create a new security group, you’ll first want to identify the Amazon EC2 platform for
your DB instance. To determine your platform, see Determining whether you are using
the EC2-VPC or EC2-Classic platform.
45
45
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
b. Obtain the public key, which you need to create configuration. In the
following example, the primary_instance is left because in IPsec
parlance, left always refers to the device you are currently configuring,
and right refers to the device at the other end of the tunnel.
46
46
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
d. Obtain the public key, which you need to create the configuration. The
following uses the parameter right.
6. Based on the keys, generate the configuration. The configuration is identical for
both the primary_instance and the standby_instance. The
<primary_instance_ipv4> and <standby_instance_ipv4> values are the
private IP addresses you obtained in Step 4: Note the private IP addresses of
the Amazon Elastic Compute Cloud (Amazon EC2) instances.
conn custom-db-tunnel
type=transport
auto=add
authby=rsasig
left=<primary_instance_ipv4>
leftrsasigkey=0sAwEAAcKdo6n...[truncated]
right=<standby_instance_ipv4>
rightrsasigkey=0sAwEAAbx8m6...[truncated]
47
47
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Conclusion
This guide presents one of the approaches to configure a database for HA on your RDS
Custom Oracle instances using Oracle Data Guard. It also shares some of the best
practices to configure data guard to achieve HA.
Contributors
Contributors to this document include:
• Jeff (Wenjie) Zhou, Senior Software Engineer, Amazon Web Services – RDS
Oracle
• Nitin Saxena, Senior Database Engineer, Amazon Web Services – RDS Oracle
48
48
Amazon Web Services Enabling High Availability with Data Guard on Amazon RDS Custom for Oracle
Document revisions
Date Description
49
49