Skip to content

TEST DG

github-actions edited this page Feb 27, 2024 · 3 revisions

Testing the final configuration for Data Guard installation

  1. From the compute source, ssh into the primary DB (the default name is "vm-primary-0"):
$ ssh -i ~/.ssh/lza-oracle-data-guard  oracle@<PUBLIC_IP_ADDRESS_OF_VM_PRIMARY_0>

Primary Server ssh

  1. Check the Oracle related environment variables:
$ env | grep -i oracle

Primary Server Env

  1. Connect to the database:
$ sqlplus / as sysdba
show user

Primary Server Show User

  1. You can display configuration parameters related to Data Guard as follows:
set linesize 500 pages 100
col name format a30
col value format a100

select name, value from v$parameter
where name in ('db_name', 'db_unique_name', 'log_archive_config',
'log_archive_dest_1', 'log_archive_dest_2', 
'log_archive_dest_state_1', 'log_archive_dest_state_2', 
'remote_login_password_file', 'log_archive_format',
'log_archive_max_processes', 'fal_server',
'log_file_name_convert', 'db_file_name_convert', 'db_recovery_file_dest', 'standby_file_management')
order by 1;

Primary Server Config Params

  1. Check the current status of Data Guard configuration:
select status,instance_name,database_role, protection_mode from v$database,v$instance;

Primary Server Check Config

  1. On the primary server, confirm that synchronization is ready to perform a switchover:
select dest_name,status,error from v$archive_dest where dest_name='LOG_ARCHIVE_DEST_2';
select name,value from v$parameter where name='log_archive_dest_2';

Primary Server Confirm Synch

  1. Check for gaps:
select status, gap_status  from v$archive_dest_status  where dest_id = 2;

Primary Server Check Gap

  1. Verify switch over configuration:
alter database switchover to orcldg1 verify;

Primary Server Verify

  1. Perform the actual switchover:
alter database switchover to orcldg1;

Primary Server Switchover

  1. Next, ssh into the old standby server ("vm-secondary-0") and start the database:
$ ssh -i ~/.ssh/lza-oracle-data-guard  oracle@<PUBLIC_IP_ADDRESS_OF_VM_SECONDARY_0>
$ sqplus / as sysdba
alter database open;

Secondary Server Open

Now "vm-secodary-0" has become the primary server. You can check its new role as follows:

select status,instance_name,database_role, protection_mode from v$database,v$instance;

Secondary Server Status

  1. Finally, switch back to "vm-primary-0" and start the DB in MOUNT mode and initiate the Redo Apply:
$ ssh -i ~/.ssh/lza-oracle-data-guard  oracle@<PUBLIC_IP_ADDRESS_OF_VM_PRIMARY_0>
$ sqplus / as sysdba
startup mount;
alter database recover managed standby database disconnect;
select status,instance_name,database_role, protection_mode from v$database,v$instance;

Primary Server Redo Apply

Congratulations!!! Now, you have a functional Oracle DBs running on the Azure VM with Data Guard replication.

You can follow the same procedure as above to switch back the roles.