Monday, April 25, 2016

Convert RAC to NON-RAC database in ORACLE 12C (Applicable to any version)

Convert RAC  to NON-RAC database in ORACLE 12C

1) Delete all instance
[oracle@rac1 ~]$ srvctl stop database -d testdb -o immediate
[oracle@rac1 ~]$ srvctl remove instance  -d testdb -i testdb1
Remove instance from the database testdb? (y/[n]) y
[oracle@rac1 ~]$ srvctl remove instance  -d testdb -i testdb2
Remove instance from the database testdb? (y/[n]) y
[oracle@rac1 ~]$ srvctl remove database -d testdb
Remove the database testdb? (y/[n]) y

2)Change the parameters to NON RAC database
[oracle@rac1 ~]$ sqlplus -version

SQL*Plus: Release 12.1.0.1.0 Production

[oracle@rac1 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 25 13:05:38 2016

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  772472832 bytes
Fixed Size                  2855328 bytes
Variable Size             373296736 bytes
Database Buffers          390070272 bytes
Redo Buffers                6250496 bytes
Database mounted.
Database opened.
SQL> alter system set cluster_database=false scope=spfile;

System altered.

SQL> alter system set cluster_database_instances=1 scope=spfile;

System altered.

SQL> alter database disable thread 2;

Database altered.

SQL> select thread#, group# from v$log;

   THREAD#     GROUP#
---------- ----------
         1          1
         1          2
         2          3
         2          4

SQL> alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01567: dropping log 2 would leave less than 2 log files for instance
testdb1 (thread 1)
ORA-00312: online log 2 thread 1:
'+DATA/TESTDB/ONLINELOG/group_2.277.908822623'
ORA-00312: online log 2 thread 1:
'+DATA/TESTDB/ONLINELOG/group_2.278.908822629'


SQL> alter database drop logfile group 3;

Database altered.

SQL> alter database drop logfile group 4;

Database altered.

SQL>  select thread#, group# from v$log;

   THREAD#     GROUP#
---------- ----------
         1          1
         1          2

SQL>  drop tablespace UNDOTBS2 including contents and datafiles;

Tablespace dropped.
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  772472832 bytes
Fixed Size                  2855328 bytes
Variable Size             310382176 bytes
Database Buffers          452984832 bytes
Redo Buffers                6250496 bytes
Database mounted.
Database opened.
SQL> select inst_id from gv$instance;

   INST_ID
----------
         1

SQL> show parameter cluster

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean     FALSE
cluster_database_instances           integer     1
cluster_interconnects                string
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options



3)Copy the Password file and spfile to local disk (its not mandatory)
SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SQL> create spfile from pfile;

File created.

SQL> ! ls -lrth
total 532K
-rw-r--r-- 1 oracle oinstall 3.0K Feb  3  2012 init.ora
-rw-r----- 1 oracle oinstall 1.6K Apr 25 13:07 inittestdb1.ora
-rw-rw---- 1 oracle dba      512K Apr 25 13:08 id_testdb1.dat
-rw-rw---- 1 oracle dba      1.6K Apr 25 13:08 hc_testdb1.dat
-rw-r----- 1 oracle dba      4.5K Apr 25 13:11 spfiletestdb1.ora

SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> startup force
ORACLE instance started.

Total System Global Area  772472832 bytes
Fixed Size                  2855328 bytes
Variable Size             310382176 bytes
Database Buffers          452984832 bytes
Redo Buffers                6250496 bytes
Database mounted.
Database opened.
SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/12.1.0
                                                 /dbhome_1/dbs/spfiletestdb1.or
                                                 a
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
ASMCMD> pwd
+DATA/TESTDB
ASMCMD> cp +DATA/TESTDB/PASSWORD/pwdtestdb.268.908822333 /u01/app/oracle/product/12.1.0/dbhome_1/dbs/
copying +DATA/TESTDB/PASSWORD/pwdtestdb.268.908822333 -> /u01/app/oracle/product/12.1.0/dbhome_1/dbs//pwdtestdb.268.908822333
ASMCMD> exit
[oracle@rac1 dbs]$ ls -lrth
total 540K
-rw-r--r-- 1 oracle oinstall 3.0K Feb  3  2012 init.ora
-rw-r----- 1 oracle oinstall 1.6K Apr 25 13:07 inittestdb1.ora
-rw-rw---- 1 oracle dba      512K Apr 25 13:08 id_testdb1.dat
-rw-rw---- 1 oracle dba      1.6K Apr 25 13:11 hc_testdb1.dat
-rw-r----- 1 oracle dba      4.5K Apr 25 13:12 spfiletestdb1.ora
-rw-r----- 1 oracle oinstall 7.5K Apr 25 13:14 pwdtestdb.268.908822333

4) Adding the database to grid(Not mandatory) (command from RDBMS home)

[oracle@rac1 dbs]$ srvctl add database -d testdb1 -o /u01/app/oracle/product/12.1.0/dbhome_1 -p /u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfiletestdb1.ora -s OPEN -t IMMEDIATE -y AUTOMATIC
[oracle@rac1 dbs]$ srvctl start database -d testdb1
PRKO-3119 : Database testdb1 cannot be started since it has no configured instances.
[oracle@rac1 dbs]$ srvctl remove database -d testdb1
Remove the database testdb1? (y/[n]) y
[oracle@rac1 dbs]$ srvctl add database -d testdb -o /u01/app/oracle/product/12.1.0/dbhome_1 -p /u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfiletestdb1.ora -s OPEN -t IMMEDIATE -y AUTOMATIC
[oracle@rac1 dbs]$ srvctl add instance -i testdb1 -n rac1
PRKO-2082 : Missing mandatory option -db
[oracle@rac1 dbs]$ srvctl add instance -d testdb -i testdb1 -n rac1
[oracle@rac1 dbs]$ srvctl start database -d testdb
[oracle@rac1 dbs]$ ps -ef | grep pmon
oracle    3016     1  0 11:01 ?        00:00:00 asm_pmon_+ASM1
oracle    8346     1  0 11:14 ?        00:00:00 mdb_pmon_-MGMTDB
oracle   14432     1  0 13:22 ?        00:00:00 ora_pmon_testdb1
oracle   14605 12423  0 13:23 pts/0    00:00:00 grep pmon
[oracle@rac1 dbs]$ crsctl stat res -t
-bash: crsctl: command not found
[oracle@rac1 dbs]$ . oraenv
ORACLE_SID = [testdb1] ? +ASM1
The /u01/app/12.1.0/grid/bin/orabase binary does not have execute privilege
for the current user, oracle.  Rerun the script after changing
the permission of the mentioned executable.
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@rac1 dbs]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       rac1                     STABLE
ora.FRA.dg
               ONLINE  ONLINE       rac1                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1                     STABLE
ora.OCRVOTE.dg
               ONLINE  ONLINE       rac1                     STABLE
ora.asm
               ONLINE  ONLINE       rac1                     Started,STABLE
ora.net1.network
               ONLINE  ONLINE       rac1                     STABLE
ora.ons
               ONLINE  ONLINE       rac1                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       rac1                     169.254.58.60 192.16
                                                             8.10.1,STABLE
ora.cvu
      1        ONLINE  ONLINE       rac1                     STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       rac1                     Open,STABLE
ora.oc4j
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac1.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac2.vip
      1        ONLINE  INTERMEDIATE rac1                     FAILED OVER,STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.testdb.db
      1        ONLINE  ONLINE       rac1                     Open,STABLE
--------------------------------------------------------------------------------
[oracle@rac1 dbs]$ . oraenv
ORACLE_SID = [+ASM1] ? testdb1
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/12.1.0/dbhome_1
The /u01/app/oracle/product/12.1.0/dbhome_1/bin/orabase binary does not have execute privilege
for the current user, oracle.  Rerun the script after changing
the permission of the mentioned executable.
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@rac1 dbs]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 25 13:23:49 2016

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> show parameter cluster

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean     FALSE
cluster_database_instances           integer     1
cluster_interconnects                string

SQL>

No comments:

Post a Comment