Home Dataguard Safely remove primary and standby databases in a Dataguard configuration

Safely remove primary and standby databases in a Dataguard configuration

In this article, we will see how we can safely remove a clustered primary and standby databases that are in an Active Dataguard configuration.

Environment

  • Primary (PRMY) is a RAC database with 2 instances.
  • Standby (STBY) is a RAC database with 2 instances.
  • Dataguard broker is used to manage the primary and physical standby (Active Dataguard).
  • The database version is 12.2.0.1.
  • The operating system is OEL Linux 6.6 – 64bit.

Steps

Stop and remove services

It is assumed that no applications should be connecting to the databases at this point. We begin by removing the database services.

> srvctl stop service -d PRMY
> srvctl stop service -d STBY

> srvctl remove service -d PRMY -s APP_SVC
> srvctl remove service -d STBY -s APP_SVC

Remove Dataguard broker configuration

Set the database environment and connect to the dataguard broker.

> dgmgrl
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Thu Feb 27 18:27:18 2020

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@prmy
Password:
Connected to "PRMY"
Connected as SYSDBA.

Verify configuration.

DGMGRL> show configuration

Configuration - PRMY

  Protection Mode: MaxPerformance
  Members:
  PRMY   - Primary database
    STBY - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 25 seconds ago)

Remove configuration.

DGMGRL> remove configuration
Removed configuration

DGMGRL> show configuration
ORA-16532: Oracle Data Guard broker configuration does not exist

Configuration details cannot be determined by DGMGRL

The broker will reset the remote archive log configuration in the databases. Upon successful removal of the DG config, the database alert log will show these parameter resets.

-- alert log
2020-02-27T18:39:11.030806+00:00
ALTER SYSTEM SET log_archive_dest_2='' SCOPE=BOTH;
2020-02-27T18:39:11.078479+00:00
ALTER SYSTEM SET log_archive_config='nodg_config' SCOPE=BOTH;
2020-02-27T18:39:11.087407+00:00
ALTER SYSTEM SET fal_server='' SCOPE=BOTH;

Disable Dataguard broker

Do this step on both the primary and standby databases.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show parameter dg_broker_start

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start 		     boolean	 TRUE

SQL> alter system set dg_broker_start=false scope=both;

System altered.

SQL> show parameter dg_broker_

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1		     string	 +DATA/PRMY/dr1prmy.dat
dg_broker_config_file2		     string	 +RECO/PRMY/dr2prmy.dat
dg_broker_start 		     boolean	 FALSE

On both systems, remove the dg_broker_config_files.

Drop databases

Do this on standby first. After completion, repeat the steps on the primary.

We will use RMAN to drop the databases. In order to drop a RAC database, the database must be started in a single-instance mode, in a restricted session. So set the cluster_database parameter to ‘false’.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> alter system set cluster_database=false scope=spfile;

System altered.

Stop the RAC database using SRVCTL.

> srvctl stop database -d STBY

Start a single instance using RMAN.

> rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Feb 27 19:54:03 2020

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> STARTUP FORCE MOUNT;

Oracle instance started
database mounted

Total System Global Area   17179869184 bytes

Fixed Size                    19430160 bytes
Variable Size               8594224368 bytes
Database Buffers            8556380160 bytes
Redo Buffers                   9834496 bytes

RMAN> SQL 'ALTER SYSTEM ENABLE RESTRICTED SESSION';

using target database control file instead of recovery catalog
sql statement: ALTER SYSTEM ENABLE RESTRICTED SESSION

RMAN> DROP DATABASE INCLUDING BACKUPS;

database name is "PRMY" and DBID is 1202231209

Do you really want to drop all backups and the database (enter YES or NO)? YES

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1263 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=1474 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=1684 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=4 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=2838 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=215 device type=DISK
allocated channel: ORA_DISK_7
channel ORA_DISK_7: SID=3469 device type=DISK
allocated channel: ORA_DISK_8
channel ORA_DISK_8: SID=425 device type=DISK
...
...

Repeat the above steps on the primary database.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> alter system set cluster_database=false scope=spfile;

System altered.


> srvctl stop database -d PRMY


> rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Feb 27 20:33:34 2020

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> STARTUP FORCE MOUNT;

Oracle instance started
database mounted

Total System Global Area   34359738368 bytes

Fixed Size                    30046992 bytes
Variable Size               9758012656 bytes
Database Buffers           24561844224 bytes
Redo Buffers                   9834496 bytes

RMAN> SQL 'ALTER SYSTEM ENABLE RESTRICTED SESSION';

using target database control file instead of recovery catalog
sql statement: ALTER SYSTEM ENABLE RESTRICTED SESSION

RMAN> DROP DATABASE INCLUDING BACKUPS;

database name is "PRMY" and DBID is 1202231209

Do you really want to drop all backups and the database (enter YES or NO)? YES

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2838 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=3469 device type=DISK
allocated channel: ORA_DISK_3
...
...

At this point, we have safely removed the databases. Cleanup leftover password and parameter files. These may be on the local file system or ASM diskgroup depending on your configuration.

Remove the database from CRS

Remove the database configurations that are stored in CRS. These do not go away automatically when dropping a database.

> srvctl remove database -d STBY
Remove the database STBY? (y/[n]) y

Diag, adump, oratab, etc.

As a final step clean up the following.

  • Diagnostic destination containing the logs.
  • The adump directory. This is stored outside the diagnostic destination.
  • Delete entries for the database in oratab.
  • Remove any cron jobs.
  • Remove the database from monitoring tools such as OEM.
# diag
> rm -rf /u01/app/oracle/diag/rdbms/prmy
> rm -rf /u01/app/oracle/diag/rdbms/stby

# adump
> rm -rf /u01/app/oracle/admin/PRMY
> rm -rf /u01/app/oracle/admin/STBY

# oratab
> vi /etc/oratab

Has this post helped you? I’d love to hear your comments.

References

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest posts

Steps to remove OEM Agent

Recently I migrated all targets (Cluster, Databases, Instances, ASM, etc) and their jobs to a 13c OEM...

DBCA fails with ORA-27125 on 19c

Issue I recently encountered an issue where DBCA failed with ORA-27125 when creating a...

How to rename a PDB in 19c

Let's look at how to rename a PDB in 19c. The steps are the same as 12c....

How to change the ethernet switch password on Exadata

Let's look at how to log in and change the ethernet switch (adm) password on an Exadata...

You might also likeRELATED
Recommended to you