Thursday, June 20, 2024

Manually Drop RAC database using command line

Manually Drop RAC database using command line


We have 2 RAC database called DEVCDB and TESTCDB
DEVCBD (DEVCBD1 & DEVCBD2)
TESTCDB (TESTCDB1 & TESTCDB2)

We will drop these RAC databases using manual method in command line.

1. Check RAC database instance status

[root@hostnode1 ~]# ps -ef|grep smon
root      2047  1865  0 20:24 pts/2    00:00:00 grep --color=auto smon
oracle    2622     1  0 May10 ?        00:00:26 ora_smon_DEVDB1
oracle   15043     1  0 May12 ?        00:00:29 ora_smon_TESTCDB1
root     16358     1  1 May05 ?        07:15:10 /u01/app/19.0.0.0/grid/bin/osysmond.bin
oracle   17256     1  0 May05 ?        00:00:26 asm_smon_+ASM1
oracle   20885     1  0 May12 ?        00:00:24 ora_smon_DEVCDB1
[root@hostnode1 ~]#

2. login to oracle user and stop the RAC database

[root@hostnode1 ~]# su - oracle
Last login: Fri May 24 20:13:08 IST 2024

[oracle@hostnode1 ~]$ . oraenv
ORACLE_SID = [oracle] ? DEVCDB1
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/19.0.0.0/dbhome_1
The Oracle base has been set to /u01/app/oracle
[oracle@hostnode1 ~]$

[oracle@hostnode1 ~]$ srvctl stop database -d DEVCDB

3. Start the database in nomount and set cluster_database=false so that we can start the RAC database instance in exclusive mode

[oracle@hostnode1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Fri May 24 20:27:15 2024
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 3690986544 bytes
Fixed Size                  9141296 bytes
Variable Size            1644167168 bytes
Database Buffers         2030043136 bytes
Redo Buffers                7634944 bytes
SQL> alter system set cluster_database=false scope=spfile sid='*';

System altered.

SQL> shut immediate;
ORA-01507: database not mounted


ORACLE instance shut down.

4. Start database in mount exclusive restrict mode 

SQL> startup mount exclusive restrict;
ORACLE instance started.

Total System Global Area 3690986544 bytes
Fixed Size                  9141296 bytes
Variable Size            1644167168 bytes
Database Buffers         2030043136 bytes
Redo Buffers                7634944 bytes
Database mounted.

5. Drop database

SQL> drop database;

Database dropped.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@hostnode1 ~]$

6. Remove database from the cluster configuration

[oracle@hostnode1 ~]$ srvctl status database -d DEVCDB
Instance DEVCDB1 is not running on node hostnode1
Instance DEVCDB2 is not running on node hostnode2

[oracle@hostnode1 ~]$ srvctl remove database -d DEVCDB
Remove the database DEVCDB? (y/[n]) y
[oracle@hostnode1 ~]$

7. Similarly follow the above step #1 to step #6 for dropping the TESTCDB database.

[root@hostnode2 ~]# ps -ef|grep smon
root      3673     1  1 May01 ?        08:49:44 /u01/app/19.0.0.0/grid/bin/osysmond.bin
oracle    4112     1  0 May01 ?        00:00:33 asm_smon_+ASM2
oracle    7539     1  0 May12 ?        00:00:33 ora_smon_TESTCDB2
oracle   10041     1  0 May10 ?        00:00:31 ora_smon_DEVDB2
oracle   18734     1  0 May12 ?        00:00:26 ora_smon_DEVCDB2
root     32313 32171  0 20:24 pts/0    00:00:00 grep --color=auto smon
[root@hostnode2 ~]#

[root@hostnode2 ~]# su - oracle
Last login: Fri May 24 18:03:45 IST 2024
[oracle@hostnode2 ~]$

[oracle@hostnode2 ~]$ . oraenv
ORACLE_SID = [oracle] ? TESTCDB2
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/19.0.0.0/dbhome_1
The Oracle base has been set to /u01/app/oracle

[oracle@hostnode2 ~]$ srvctl stop database -d TESTCDB
[oracle@hostnode2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Fri May 24 20:27:15 2024
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 3690986544 bytes
Fixed Size                  9141296 bytes
Variable Size            1073741824 bytes
Database Buffers         2600468480 bytes
Redo Buffers                7634944 bytes
SQL> alter system set cluster_database=false scope=spfile sid='*';

System altered.

SQL> shut immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount exclusive restrict;
ORACLE instance started.

Total System Global Area 3690986544 bytes
Fixed Size                  9141296 bytes
Variable Size            1073741824 bytes
Database Buffers         2600468480 bytes
Redo Buffers                7634944 bytes
Database mounted.
SQL> drop database;

Database dropped.

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> exit
^[[A^[[A[oracle@hostnode2 ~]$ srvctl status database -d TESTCDB
Instance TESTCDB1 is not running on node hostnode1
Instance TESTCDB2 is not running on node hostnode2

[oracle@hostnode2 ~]$ srvctl remove database -d TESTCDB
Remove the database TESTCDB? (y/[n]) y
[oracle@hostnode2 ~]$

Regards,
Mallik

No comments:

Post a Comment

Running SQL and O/S Commands Within RMAN

Running SQL and O/S Commands Within RMAN Sometimes you may want to run an SQL statement from within RMAN. Use RMAN’s sql command to do this....