How to drop a RAC database manually

The easiest way to create or drop a RAC database should be using DBCA GUI. However, sometime we prefer to do it on command line. In this case we can use DBCA -silent option with a response file in 12.2 version of Oracle RDBMS. Recently I have tested the syntax for both creating and droping a RAC db. i.e.

dbca -silent -createDatabase -responseFile /path/to/dbca.rsp -ignorePrereqFailure
dbca -deleteDatabase -sourceDB db1tst -silent -responseFile /path/to/dbca.rsp

When we use DBCA GUI to create a database, we can save a response file, this file can be used as a template for us to create other databases with silent mode.

However, today I encountered a situation that I was unable to drop a testing db because I cannot enter the correct sys passowrd

$ dbca -deleteDatabase -sourceDB db1tst -silent -responseFile /opt/oracle/stage/dbca.rsp
Enter SYS user password:

Connecting to database
9% complete
14% complete
DBCA Operation failed.

Look at the log file "/opt/oracle/product/cfgtoollogs/dbca/db1tst2.log" for further details.

In the log, it can be seen:

[ 2018-02-10 22:24:43.093 GMT ] ORA-01017: invalid username/password; logon denied

[ 2018-02-10 22:24:43.095 GMT ] Connection to the database failed, verify the user name and password and try again.
[ 2018-02-10 22:24:43.199 GMT ] DBCA_PROGRESS : DBCA Operation failed.

I was unable to get the password right, so I have to drop the db manually. Below I describe the steps I went through for future reference:

1. check the db configuration and status

$ srvctl config database -d db1tst

Database unique name: db1tst
Database name: db1tst
Oracle home: /opt/oracle/product/12.2.0/db_1
Oracle user: oracle
Spfile: +DATA_DB1TST/DB1TST/PARAMETERFILE/spfile.321.967756369
Password file: +DATA_DB1TST/DB1TST/PASSWORD/pwddb1tst.295.967753731
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Mount point paths:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group:
Database instances: db1tst1,db1tst2,db1tst3,db1tst4
Configured nodes: racnode01,racnode04,racnode03,racnode02
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

$ srvctl status database -d db1tst

Instance db1tst1 is running on node racnode01
Instance db1tst2 is running on node racnode04
Instance db1tst3 is running on node racnode03
Instance db1tst4 is running on node racnode02

2. Stop db and start in node 1 with mount

srvctl stop database -d db1tst

srvctl start instance -d db1tst -n racnode01 -o mount

3. Try to drop database, receiving “ORA-01586”

SQL> drop database;
drop database
ERROR at line 1:
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation

4. set cluster_database=false, restart db and drop again

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

System altered.

SQL> shutdown immediate;
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.

SQL> startup mount restrict;
ORACLE instance started.

Total System Global Area 8388608000 bytes
Fixed Size 8622144 bytes
Variable Size 3439333312 bytes
Database Buffers 4513071104 bytes
Redo Buffers 427581440 bytes

Database mounted.
SQL> drop database;

Database dropped.

5. Remove the db from GI

$ srvctl remove database -d db1tst
Remove the database db1tst? (y/[n]) y

$ srvctl config database -d db1tst
PRCD-1120 : The resource for database db1tst could not be found.
PRCR-1001 : Resource ora.db1tst.db does not exist

6. Delete the directory from the ASMCMD command line

ASMCMD> cd ..
ASMCMD> rm -rf db1tst

Leave a Reply

Your email address will not be published. Required fields are marked *