Migrate RAC NON-CDB to RAC CDB

RAC --> nrccdb1
RAC --> nrccdb2

***** 1.) Check the Config

[oracle@odasys11:/home/oracle]srvctl config database -d nrccdb1
Database unique name: nrccdb1
Database name: nrccdb1
Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_1
Oracle user: oracle
Spfile: +DATA/NRCCDB1/PARAMETERFILE/spfile.1064.942947307
Password file: +DATA/NRCCDB1/PASSWORD/pwdnrccdb1.1004.942946507
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA,REDO
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: racoper
Database instances: nrccdb11,nrccdb12
Configured nodes: odasys11,odasys12
Database is administrator managed

***** 2.) Stop Node 2

srvctl stop instance -i nrccdb12 -d nrccdb1

***** 3.) Restart Node 1 

. oraenv
nrccdb11

shut immediate;
startup open read only;
select open_mode from v$database;

***** 4.) Describe and Compatibility

BEGIN
  DBMS_PDB.DESCRIBE(
    pdb_descr_file => '/home/oracle/pdbs/nrccdb1.xml');
END;
/

shut immediate;
exit;

. oraenv
cdbtst11

sqlplus / as sysdba

set serveroutput on
 
DECLARE
   compatible BOOLEAN := FALSE;
BEGIN  
   compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/home/oracle/pdbs/nrccdb1.xml', pdb_name=>'nrccdb1');
   if compatible then
     DBMS_OUTPUT.PUT_LINE('The Pluggable database is Compatible !!!');
   else 
     DBMS_OUTPUT.PUT_LINE('ERROR - The Pluggable database is not compatible !!!');
   end if;
END;
/

Note: In case of issues:

col cause for a10
col name for a10
col message for a35 word_wrapped
select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='nrccdb1';

***** 6.) Connect into the CDB Database, if not connected: cdbtst1

sqlplus / as sysdba

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO

         
***** 7.) Create the new PDB:

CREATE PLUGGABLE DATABASE nrccdb1 USING '/home/oracle/pdbs/nrccdb1.xml'  NOCOPY TEMPFILE REUSE;         

Pluggable database created.

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 NRCCDB1                        MOUNTED


***** 8.) Catalog

alter session set container=NRCCDB1;    

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 NRCCDB1                        MOUNTED


select INST_ID,CON_ID,NAME,OPEN_MODE, open_time from gv$pdbs;

   INST_ID     CON_ID NAME                 OPEN_MODE  OPEN_TIME
---------- ---------- -------------------- ---------- ---------------------------------------------------------------------------
         1          3 NRCCDB1              MOUNTED    03-MAY-17 10.52.18.840 AM +02:00
         2          3 NRCCDB1              MOUNTED

@?/rdbms/admin/noncdb_to_pdb.sql         

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 NRCCDB1                        MOUNTED


SQL> alter database open;

Database altered.

select INST_ID,CON_ID,NAME,OPEN_MODE, open_time from gv$pdbs;

   INST_ID     CON_ID NAME                 OPEN_MODE  OPEN_TIME
---------- ---------- -------------------- ---------- ---------------------------------------------------------------------------
         1          3 NRCCDB1              READ WRITE 03-MAY-17 11.37.34.288 AM +02:00
         2          3 NRCCDB1              MOUNTED


SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
cdbtst11
cdbtst12
         
alter pluggable database open instances=('cdbtst12');

SQL> select INST_ID,CON_ID,NAME,OPEN_MODE, open_time from gv$pdbs;

   INST_ID     CON_ID NAME                 OPEN_MODE  OPEN_TIME
---------- ---------- -------------------- ---------- ---------------------------------------------------------------------------
         1          3 NRCCDB1              READ WRITE 03-MAY-17 11.37.34.288 AM +02:00
         2          3 NRCCDB1              READ WRITE 03-MAY-17 11.45.45.375 AM +02:00

SELECT TABLESPACE_NAME, FILE_NAME FROM DBA_DATA_FILES;

TABLESPACE_NAME                FILE_NAME
------------------------------ --------------------------------------------------
USERS                          +DATA/NRCCDB1/DATAFILE/users.1065.942946573
SYSAUX                         +DATA/NRCCDB1/DATAFILE/sysaux.857.942946559
SYSTEM                         +DATA/NRCCDB1/DATAFILE/system.782.942946555


***** 9.) Droping the OLD UNDO

as grid user:

asmcmd lsof | grep -i NRCCDB1
cdbtst1  cdbtst11       +DATA/NRCCDB1/DATAFILE/sysaux.857.942946559                                                   
cdbtst1  cdbtst11       +DATA/NRCCDB1/DATAFILE/system.782.942946555                                                   
cdbtst1  cdbtst11       +DATA/NRCCDB1/DATAFILE/users.1065.942946573  

--> If is not in use you can remove the file

[grid@odasys12:/home/grid]asmcmd
ASMCMD> cd +DATA/NRCCDB1/DATAFILE/

ASMCMD> ls -ltr
WARNING:option 'r' is deprecated for 'ls'
please use 'reverse'

Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   MAY 03 10:00:00  Y    UNDOTBS1.994.942946563
DATAFILE  MIRROR  COARSE   MAY 03 10:00:00  Y    UNDOTBS2.874.942946573
DATAFILE  MIRROR  COARSE   MAY 03 11:00:00  Y    SYSAUX.857.942946559
DATAFILE  MIRROR  COARSE   MAY 03 11:00:00  Y    SYSTEM.782.942946555
DATAFILE  MIRROR  COARSE   MAY 03 11:00:00  Y    USERS.1065.942946573


ASMCMD> rm UNDOTBS1.994.942946563
ASMCMD> rm UNDOTBS2.874.942946573

ASMCMD> ls -ltr
WARNING:option 'r' is deprecated for 'ls'
please use 'reverse'

Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   MAY 03 11:00:00  Y    SYSAUX.857.942946559
DATAFILE  MIRROR  COARSE   MAY 03 11:00:00  Y    SYSTEM.782.942946555
DATAFILE  MIRROR  COARSE   MAY 03 11:00:00  Y    USERS.1065.942946573


***** 10.) Remove the Service from the Cluster

. oraenv

nrccdb11

[oracle@odasys12:/home/oracle/pdbs]srvctl remove database -d nrccdb1
Remove the database nrccdb1? (y/[n]) y

***** 11) Checking the service inside of the CDB

. oraenv

cdbtst11

sqlplus / as sysdba

col NETWORK_NAME format a20
col NAME format a20
select name, NETWORK_NAME, PDB from v$services;

NAME                           NETWORK_NAME         PDB
------------------------------ -------------------- ------------------------------
nscdb1                         nscdb1               NSCDB1
cdbstXDB                       cdbstXDB             CDB$ROOT
cdbst                          cdbst                CDB$ROOT
SYS$BACKGROUND                                      CDB$ROOT
SYS$USERS                                           CDB$ROOT

[oracle@odasys11:/home/oracle]lsnrctl status listener | grep nrccdb1
Service "nrccdb1" has 1 instance(s).

[oracle@odasys11:/home/oracle]tnsping nrccdb1

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-MAY-2017 11:53:46

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = odasys1-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = nrccdb1)))
OK (10 msec)

[oracle@odasys11:/home/oracle]sqlplus sys/welcome1@nrccdb1 as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed May 3 11:55:05 2017

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


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


INSTANCE_NAME
----------------
cdbtst11

[oracle@odasys12:/u01/app/oracle/product/12.1.0.2/dbhome_1/dbs]sqlplus sys/welcome1@nrccdb1 as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed May 3 11:55:41 2017

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


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


INSTANCE_NAME
----------------
cdbtst12

Note: According with MOS 1998112.1, is not a good practice use the PDB Name as a service name to connect,
so lets create a new service to be used:

. oraenv
cdbtst11

srvctl add service -database cdbtst1 -pdb NRCCDB1 -s pdb_NRCCDB1 -preferred "cdbtst11,cdbtst12"
srvctl config service -db cdbtst1 -service pdb_NRCCDB1
srvctl start service -db cdbtst1 -service pdb_NRCCDB1

sqlplus / as sysdba
select name, NETWORK_NAME, PDB from v$services;

alter pluggable database all save state;

alter session set container=NRCCDB1;

NAME                 NETWORK_NAME         PDB
-------------------- -------------------- ------------------------------
pdb_NRCCDB1          pdb_NRCCDB1          NRCCDB1
nrccdb1              nrccdb1              NRCCDB1



***** 12.) Change the TNSNAMES Entry both Nodes

cd /u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin
vi tnsnames.ora

NRCCDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = odasys1-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb_NRCCDB1)
    )
  )

from node1:
sqlplus system/welcome1@NRCCDB1

from node2:
sqlplus system/welcome1@NRCCDB1

***** 13.) Check ODA repository :

oakcli show databases | grep -i NRCCDB1


***** 14.) Clean ORATAB both nodes
cat /etc/oratab | grep -i NRCCDB1

***** 15.) Cleaning Files both nodes:

cd /u01/app/oracle/product/12.1.0.2/dbhome_1/dbs
ls -ltr | grep -i NRCCDB1

-rw-r----- 1 oracle oinstall       41 May  2 17:49 initnrccdb11.ora
-rw-rw---- 1 oracle asmadmin   524288 May  3 10:48 id_nrccdb11.dat
-rw-rw---- 1 oracle asmadmin     1544 May  3 10:49 hc_nrccdb11.dat

rm initnrccdb11.ora id_nrccdb11.dat hc_nrccdb11.dat
rm initnrccdb12.ora hc_nrccdb12.dat id_nrccdb12.dat
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s