Migrate RAC 1 Node NON-CDB to RAC 1 Node CDB

Rac 1 Node:

nr1cdb1 - OK
nr1cdb2 - OK

Container: cdbr1

[oracle@odasys11:/home/oracle]srvctl config database -d nr1cdb1
Database unique name: nr1cdb1
Database name: nr1cdb1
Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_1
Oracle user: oracle
Spfile: +DATA/NR1CDB1/PARAMETERFILE/spfile.843.942944503
Password file: +DATA/NR1CDB1/PASSWORD/pwdnr1cdb1.1067.942943723
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA,REDO
Mount point paths:
Services: nr1cdb1_racone
Type: RACOneNode
Online relocation timeout: 30
Instance name prefix: nr1cdb1
Candidate servers: odasys11,odasys12
OSDBA group: dba
OSOPER group: racoper
Database instances:
Database is administrator managed

1.) Clear Shutdown on NON-CDB

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

2.) Describe

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

shut immediate
exit

. oraenv
cdbr1_1

sqlplus / as sysdba

set serveroutput on
 
DECLARE
   compatible BOOLEAN := FALSE;
BEGIN  
   compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/home/oracle/pdbs/nr1cdb1.xml', pdb_name=>'nr1cdb1');
   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';

4.) Connect into the CDB Database, if not connected: cdbst

. oraenv
cdbr1_1

sqlplus / as sysdba

SQL> show pdbs

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

         
5.) Create the new PDB:

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

Pluggable database created.

select con_id, name, open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 NR1CDB1                        MOUNTED

6.) Catalog

alter session set container=NR1CDB1;    

SQL> show pdbs

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

@?/rdbms/admin/noncdb_to_pdb.sql         

SQL> show pdbs

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


SQL> alter database open;

Database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 NR1CDB1                        READ WRITE NO
         
SELECT TABLESPACE_NAME, FILE_NAME FROM DBA_DATA_FILES;

TABLESPACE_NAME                FILE_NAME
------------------------------ --------------------------------------------------
USERS                          +DATA/NR1CDB1/DATAFILE/users.730.942943793
SYSAUX                         +DATA/NR1CDB1/DATAFILE/sysaux.673.942943779
SYSTEM                         +DATA/NR1CDB1/DATAFILE/system.1122.942943773

7.) Droping the OLD UNDO

as grid user:

[grid@odasys12:/home/grid]asmcmd lsof | grep -i NR1CDB1
cdbr1    cdbr1_1        +DATA/NR1CDB1/DATAFILE/sysaux.673.942943779                                                   
cdbr1    cdbr1_1        +DATA/NR1CDB1/DATAFILE/system.1122.942943773                                                  
cdbr1    cdbr1_1        +DATA/NR1CDB1/DATAFILE/users.730.942943793

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

[grid@odasys12:/home/grid]asmcmd
ASMCMD> cd  +DATA/NR1CDB1/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 15:00:00  Y    SYSAUX.673.942943779
DATAFILE  MIRROR  COARSE   MAY 03 15:00:00  Y    SYSTEM.1122.942943773
DATAFILE  MIRROR  COARSE   MAY 03 15:00:00  Y    UNDOTBS1.781.942943781
DATAFILE  MIRROR  COARSE   MAY 03 15:00:00  Y    UNDOTBS2.995.942943791
DATAFILE  MIRROR  COARSE   MAY 03 15:00:00  Y    USERS.730.942943793

rm UNDOTBS1.781.942943781
rm UNDOTBS2.995.942943791

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

Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   MAY 03 15:00:00  Y    SYSAUX.673.942943779
DATAFILE  MIRROR  COARSE   MAY 03 15:00:00  Y    SYSTEM.1122.942943773
DATAFILE  MIRROR  COARSE   MAY 03 15:00:00  Y    USERS.730.942943793

8.) Remove the Service from the Cluster

. oraenv

nr1cdb1_1

[oracle@odasys11:/home/oracle]srvctl remove database -d  nr1cdb1
Remove the database nr1cdb1? (y/[n]) y

9) Checking the service inside of the CDB

. oraenv

cdbr1_1

sqlplus / as sysdba

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

NAME                 NETWORK_NAME         PDB
-------------------- -------------------- ------------------------------
nr1cdb1              nr1cdb1              NR1CDB1
cdbr1_racone         cdbr1_racone         CDB$ROOT
cdbr1XDB             cdbr1XDB             CDB$ROOT
cdbr1                cdbr1                CDB$ROOT
SYS$BACKGROUND                            CDB$ROOT
SYS$USERS                                 CDB$ROOT

alter pluggable database all save state;

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

10.) Check ODA repository :

oakcli show databases | grep -i nr1cdb1

cat /etc/oratab | grep -i nr1cdb1

11.) Cleaning Files both nodes:

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

-rw-r----- 1 oracle oinstall       41 May  2 17:02 initnr1cdb1_1.ora
-rw-rw---- 1 oracle asmadmin     1544 May  3 15:02 hc_nr1cdb1_1.dat
-rw-rw---- 1 oracle asmadmin   524288 May  3 15:02 id_nr1cdb1_1.dat

rm initnr1cdb1_1.ora hc_nr1cdb1_1.dat id_nr1cdb1_1.dat
rm initnr1cdb1_2.ora

12.) TNS

NR1CDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = odasys1-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = nr1cdb1)
    )
  )
  
13.) Connection Test

from both nodes

sqlplus system/welcome1@NR1CDB1

SQL*Plus: Release 12.1.0.2.0 Production on Wed May 3 15:22:52 2017

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

Last Successful login time: Tue May 02 2017 12:55:23 +02:00

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
----------------
cdbr1_1

14.) Testing thye failover:

as oracle:

srvctl relocate database -d cdbr1 -n odasys12

sqlplus sys/welcome1@NR1CDB1 as sysdba

INSTANCE_NAME
----------------
cdbr1_2

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 NR1CDB1                        READ WRITE NO

Note: If at the very first time the  failover for the  PDB is in MOUNT state,
is needed execute a manual failover with srvctl relocate database and
execute:
sqlplus / as sysdba
alter pluggable database <PDB> open;
alter pluggable database <PDB> save state;
on the next time the PDB will be opened as READ WRITE;

srvctl relocate database -d cdbr1 -n odasys11

sqlplus sys/welcome1@NR1CDB1 as sysdba

INSTANCE_NAME
----------------
cdbr1_1

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 NR1CDB1                        READ WRITE NO


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