Wednesday, November 27, 2013

Speaker @Oracle Technology Network (OTN) Yathra 2014 @Chennai, India on 1st March 2014 On "Oracle 12c Flex ASM and Flex Cluster" & "Oracle Exadata"


http://otnyatra.com/using-joomla/extensions/components/content-component/article-category-list/73-chennai

Speaker @Oracle Technology Network (OTN) Yathra 2014 @Bangalore, India on 27th Feb 2014 On "Oracle 12c Flex ASM and Flex Cluster"


http://otnyatra.com/using-joomla/extensions/components/content-component/article-category-list/71-bangalore

Wednesday, November 20, 2013

Technical Facts On Oracle Data Guard 12c - Far Sync Method


1. A lightweight Oracle database instance
2. Only a standby controlfile (created from primary database like phyical standby database controlfile process)
3. Password file, Standby Redo Log files & archive log files will have in Far Sync Instance
4. NO Data files & NO database to open for access
5. Far Sync database will deployed near distance to Primary Database to tolerate the impact of network latency
6. Far Sync instance will receive from redo synchronsly from primary database
7. Far Sync instance will forwards redo asynchronsly from physical standby database
8. Far Sync instance can compress redo transport
9. Best data protection and least performance impact on Primary Database
10. No changes in application.

Configuring Active Data Guard (ADG) using Oracle Database 12c (With Container Database and Pluggable Databases) - Part-3


Switchover and Switchback using DGMGRL utility

1. Login to the Primary Database (cdb)

[oracle@dbnode]$ export ORACLE_SID=cdb
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> show database cdb;

Database - cdb

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdb

  Database Error(s):
    ORA-16820: fast-start failover observer is no longer observing this database

Database Status:
ERROR

2. Start 'Observer' (from separate terminal) and check the status of 'Database'
DGMGRL> show database cdb;

Database - cdb

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdb

Database Status:
SUCCESS

DGMGRL> show database cdbstby;

Database - cdbstby

  Role:              PHYSICAL STANDBY
  Intended State:    APPLY-ON
  Transport Lag:     0 seconds (computed 0 seconds ago)
  Apply Lag:         0 seconds (computed 0 seconds ago)
  Apply Rate:        0 Byte/s
  Real Time Query:   OFF
  Instance(s):
    cdbstby

Database Status:
SUCCESS

DGMGRL> show configuration;

Configuration - DGCONFIG

  Protection Mode: MaxPerformance
  Databases:
  cdb     - Primary database
    cdbstby - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS

3. Switchover to Physical Standby Database (cdbstby)
DGMGRL> switchover to cdbstby;
Performing switchover NOW, please wait...
Operation requires a connection to instance "cdbstby" on database "cdbstby"
Connecting to instance "cdbstby"...
Connected as SYSDBA.
New primary database "cdbstby" is opening...
Operation requires startup of instance "cdb" on database "cdb"
Starting instance "cdb"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "cdbstby"

DGMGRL> exit

4. Login to the New Physical Standby Database (cdb)
[oracle@dbnode]$ export ORACLE_SID=cdb
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 21:29:59 2013

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

SQL> connect sys/oracle as sysdba
Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1386283008 bytes
Fixed Size                  2288248 bytes
Variable Size             469763464 bytes
Database Buffers          905969664 bytes
Redo Buffers                8261632 bytes
Database mounted.

SQL> alter database recover managed standby database cancel;
Database altered.

SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     47
Next log sequence to archive   0
Current log sequence           47
SQL>

4. Login to the New Primary Database (cdbstby)
[oracle@dbnode]$ export ORACLE_SID=cdbstby
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 21:30:25 2013

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

SQL> connect sys/oracle@192.168.56.111:1521/cdbstby as sysdba
Connected.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     44
Next log sequence to archive   46
Current log sequence           46

5. Login to the DGMGRL for Switchback to Old Primary Database (cdb)
[oracle@dbnode]$ export ORACLE_SID=cdbstby
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ dgmgrl

DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> show database cdbstby;

Database - cdbstby

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdbstby

Database Status:
SUCCESS

DGMGRL> show database cdb;

Database - cdb

  Role:              PHYSICAL STANDBY
  Intended State:    APPLY-ON
  Transport Lag:     0 seconds (computed 1 second ago)
  Apply Lag:         0 seconds (computed 1 second ago)
  Apply Rate:        0 Byte/s
  Real Time Query:   OFF
  Instance(s):
    cdb

Database Status:
SUCCESS

6. Login to the DGMGRL for Switchback to Old Primary Database (cdb)
DGMGRL> switchover to cdb;
Performing switchover NOW, please wait...
Operation requires a connection to instance "cdb" on database "cdb"
Connecting to instance "cdb"...
Connected as SYSDBA.
New primary database "cdb" is opening...
Operation requires startup of instance "cdbstby" on database "cdbstby"
Starting instance "cdbstby"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "cdb"
DGMGRL> exit

7. Check the status of Primary Database (cdb)
[oracle@dbnode]$ export ORACLE_SID=cdb
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> show database cdb;

Database - cdb

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdb

Database Status:
SUCCESS

DGMGRL> show database cdbstby

Database - cdbstby

  Role:              PHYSICAL STANDBY
  Intended State:    APPLY-ON
  Transport Lag:     0 seconds (computed 0 seconds ago)
  Apply Lag:         0 seconds (computed 0 seconds ago)
  Apply Rate:        0 Byte/s
  Real Time Query:   OFF
  Instance(s):
    cdbstby

Database Status:
SUCCESS

DGMGRL>

Configuring Active Data Guard (ADG) using Oracle Database 12c (With Container Database and Pluggable Databases) - Part -2

1. Login to the Primary Database (cdb)
[oracle@dbnode ~]$ export ORACLE_SID=cdb
[oracle@dbnode ~]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode ~]$ cd /u01/app/oracle/product/12.1.0/dbhome/bin
[oracle@dbnode bin]$ ./sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 20:55:33 2013
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> connect sys/oracle as sysdba
Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area 1386283008 bytes
Fixed Size                  2288248 bytes
Variable Size             469763464 bytes
Database Buffers          905969664 bytes
Redo Buffers                8261632 bytes
Database mounted.
Database opened.

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED

SQL> connect sys/oracle@192.168.56.111:1521/pdb1 as sysdba
Connected.

SQL> alter database open;
Database altered.

SQL> connect sys/oracle@192.168.56.111:1521/pdb2 as sysdba
Connected.

SQL> alter database open;
Database altered.

SQL> connect sys/oracle@192.168.56.111:1521/pdb3 as sysdba
Connected.

SQL> alter database open;
Database altered.

SQL> connect sys/oracle@192.168.56.111:1521/cdb as sysdba
Connected.

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 PDB1                           READ WRITE
         4 PDB2                           READ WRITE
         5 PDB3                           READ WRITE

2. Login to the Pluggable Database (pdb1) in Primary Database (cdb) and create user and insert rows.
SQL> connect sys/oracle@192.168.56.111:1521/pdb1 as sysdba
Connected.

SQL> show con_name

CON_NAME
------------------------------
PDB1

SQL> create user user1 identified by user1;
User created.

SQL> grant connect,resource to user1;
Grant succeeded.

SQL> connect user1/user1@192.168.56.111:1521/pdb1
Connected.

SQL> create table user1_pdb1 (no number, name varchar2(20));
Table created.

SQL> insert into user1_pdb1 values (1, 'ORACLE');
1 row created.

SQL> commit;
Commit complete.

SQL> connect sys/oracle@192.168.56.111:1521/cdb as sysdba
Connected.

SQL> alter system switch logfile;
System altered.

SQL> alter system switch logfile;
System altered.

3. Login to the Physical Standby Database (cdbstby) and check Pluggable Database.

[oracle@dbnode ~]$ export ORACLE_SID=cdbstby
[oracle@dbnode ~]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode ~]$ cd /u01/app/oracle/product/12.1.0/dbhome/bin
[oracle@dbnode bin]$ ./sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 20:56:39 2013

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

SQL> connect sys/oracle as sysdba
Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1386283008 bytes
Fixed Size                  2288248 bytes
Variable Size             469763464 bytes
Database Buffers          905969664 bytes
Redo Buffers                8261632 bytes
Database mounted.

SQL> alter database recover managed standby database cancel;
Database altered.

SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.

SQL> connect user1/user1@192.168.56.111:1521/pdb1
Connected.

SQL> select * from user1_pdb1;

        NO NAME
---------- --------------------
         1 ORACLE

Note: User1 created with user1_pdb1 table with inserted rows from Primary Database.

Configuring Active Data Guard (ADG) using Oracle Database 12c (With Container Database and Pluggable Databases) - Part-1

Configuring Active Data Guard (ADG) using Oracle Database 12c (With Container Database and Pluggable Databases)

Environment Info:

Oracle Software                : Oracle Database 12c (Release 12.1.0.1.0)
Primary Database (cdb)     : Contains one container database (cdb) and
                                           three pluggable databases (pdb1, pdb2 & pdb3)
Standby Database (cdbstby) : Physical Standby database

1. Enable force logging mode in Primary Database:

[oracle@dbnode]$export ORACLE_SID=cdb
[oracle@dbnode]$export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$sqlplus /nolog
SQL>connect sys/oracle@192.168.56.111:1521/cdb as sysdba
SQL>alter database force logging;

2. Configure the primary database to receive redo data, by adding the standby logfiles to the primary

SQL>alter database add standby logfile '/u01/app/oracle/oradata/CDB/standbylog/srl01.log' size 50M;
SQL>alter database add standby logfile '/u01/app/oracle/oradata/CDB/standbylog/srl02.log' size 50M;
SQL>alter database add standby logfile '/u01/app/oracle/oradata/CDB/standbylog/srl03.log' size 50M;
SQL>alter database add standby logfile '/u01/app/oracle/oradata/CDB/standbylog/srl04.log' size 50M;

3. Set LOG_ARCHIVE_CONFIG and LOG_ARCHIVE_DEST_2 parameters
SQL>alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST';
SQL>alter system set log_archive_config='dg_config=(cdb,cdbstby)';
SQL>alter system set log_archive_dest_2='service=cdbstby async valid_for=(online_logfile,primary_role) db_unique_name=cdbstby';
SQL>alter system set db_recovery_file_dest_size=5G;

4. Put the primary database in ARCHIVELOG mode to enable automatic archiving
SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database archivelog;
SQL>alter database open;

5. Open all Pluggable Databases (pdb1, pdb2 & pdb3)
SQL>connect sys/oracle@192.168.56.111:1521/pdb1 as sysdba
SQL>alter database open

SQL>connect sys/oracle@192.168.56.111:1521/pdb2 as sysdba
SQL>alter database open

SQL>connect sys/oracle@192.168.56.111:1521/pdb3 as sysdba
SQL>alter database open

6. Check the Database Parameters before taking RMAN backup for Physical Standby Database
SQL>connect sys/oracle@192.168.56.111:1521/cdb as sysdba
SQL>show parameter

7. Backup database plus archivelog Create a copy of the primary database using RMAN
[oracle@dbnode]$export ORACLE_SID=cdb
[oracle@dbnode]$export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$rman
rman>connect target /
rman>backup database plus archivelog;

8. Create the needed folders and start the database in nomount and Copying the password file and
required parameters for pfile for Physical Standby Database (cdbstby)
a. mkdir cdbstby
b. mkdir /u01/app/oracle/admin/cdbstby/adump
c. mkdir /u01/app/oracle/admin/cdbstby/dpdump
d. mkdir /u01/app/oracle/admin/cdbstby/pfile
e. mkdir /u01/app/oracle/oradata/cdbstby
f. mkdir /u01/app/oracle/recovery_area/cdbstby
g. mkdir /u01/app/oracle/oradata/orclstby/cdb_pdb
h. mkdir /u01/app/oracle/oradata/orclstby/pdbseed
i. chmod -R 777 /u01/app/oracle/oradata/cdbstby
j. chmod -R 777 /u01/app/oracle/fast_recovery_area/cdbstby

[oracle@dbnode]$cp /u01/app/oracle/product/12.1.0/dbhome/dbs/orapwcdb /u01/app/oracle/product/12.1.0/dbhome/dbs/orapwcdbstby
[oracle@dbnode]$export ORACLE_SID=cdbstby
[oracle@dbnode]$export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$sqlplus /nolog
SQL> connect sys/oracle as sysdba
SQL> startup nomount pfile='/u01/app/oracle/product/12.1.0/dbhome/dbs/initcdbstby.ora'

9. RMAN - Create standby database
[oracle@dbnode]$export ORACLE_SID=cdb
[oracle@dbnode]$export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode bin]$ ./rman

Recovery Manager: Release 12.1.0.1.0 - Production on Mon Nov 18 15:31:22 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target sys/oracle@cdb
connected to target database: CDB (DBID=1947832183)

RMAN> connect auxiliary sys/oracle@cdbstby
connected to auxiliary database: CDBSTBY (not mounted)

RMAN> run {
2> duplicate target database for standby from active database
3> spfile
4> parameter_value_convert 'cdb','cdbstby'
5> set db_unique_name='cdbstby'
6> set db_create_file_dest='/u01/app/oracle/oradata/cdbstby'
7> set db_recovery_file_dest='/u01/app/oracle/oradata/cdbstby'
8> set control_files='/u01/app/oracle/oradata/cdbstby/cdbstby.ctl'
9> set db_file_name_convert='/u01/app/oracle/oradata/CDB/datafile/','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/EAF5D9665BD920EDE0436F38A8C0925F/datafile/','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/EAF567FA97681A8CE0436F38A8C0EAC5/datafile','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/EAE60779AFDD1833E0436F38A8C00627/datafile','/u01/app/oracle/oradata/cdbstby/'
10> set log_file_name_convert='/u01/app/oracle/oradata/CDB/onlinelog/','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/standbylog','/u01/app/oracle/oradata/cdbstby/'
11> set log_archive_max_processes='5'
12> set fal_client='cdbstby'
set fal_server='cdb'
13> 14> set log_archive_config='dg_config=(cdb,cdbstby)'
15> set log_archive_dest_2='service=cdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=cdb'
16> ;
17> }

Starting Duplicate Db at 18-NOV-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=22 device type=DISK

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/12.1.0/dbhome/dbs/orapwcdb' auxiliary format
 '/u01/app/oracle/product/12.1.0/dbhome/dbs/orapwcdbstby'   ;
   restore clone from service  'cdb' spfile to
 '/u01/app/oracle/product/12.1.0/dbhome/dbs/spfilecdbstby.ora';
   sql clone "alter system set spfile= ''/u01/app/oracle/product/12.1.0/dbhome/dbs/spfilecdbstby.ora''";
}
executing Memory Script

Starting backup at 18-NOV-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=53 device type=DISK
Finished backup at 18-NOV-13

Starting restore at 18-NOV-13
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: restoring SPFILE
output file name=/u01/app/oracle/product/12.1.0/dbhome/dbs/spfilecdbstby.ora
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 18-NOV-13

sql statement: alter system set spfile= ''/u01/app/oracle/product/12.1.0/dbhome/dbs/spfilecdbstby.ora''

contents of Memory Script:
{
   sql clone "alter system set  audit_file_dest =
 ''/u01/app/oracle/admin/cdbstby/adump'' comment=
 '''' scope=spfile";
   sql clone "alter system set  dispatchers =
 ''(PROTOCOL=TCP) (SERVICE=cdbstbyXDB)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''cdbstby'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_create_file_dest =
 ''/u01/app/oracle/oradata/cdbstby'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_recovery_file_dest =
 ''/u01/app/oracle/oradata/cdbstby'' comment=
 '''' scope=spfile";
   sql clone "alter system set  control_files =
 ''/u01/app/oracle/oradata/cdbstby/cdbstby.ctl'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_file_name_convert =
 ''/u01/app/oracle/oradata/CDB/datafile/'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/EAF5D9665BD920EDE0436F38A8C0925F/datafile/'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/EAF567FA97681A8CE0436F38A8C0EAC5/datafile'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/EAE60779AFDD1833E0436F38A8C00627/datafile'', ''/u01/app/oracle/oradata/cdbstby/'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_file_name_convert =
 ''/u01/app/oracle/oradata/CDB/onlinelog/'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/standbylog'', ''/u01/app/oracle/oradata/cdbstby/'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_max_processes =
 5 comment=
 '''' scope=spfile";
   sql clone "alter system set  fal_client =
 ''cdbstby'' comment=
 '''' scope=spfile";
   sql clone "alter system set  fal_server =
 ''cdb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_config =
 ''dg_config=(cdb,cdbstby)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_2 =
 ''service=cdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=cdb'' comment=
 '''' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  audit_file_dest =  ''/u01/app/oracle/admin/cdbstby/adump'' comment= '''' scope=spfile
sql statement: alter system set  dispatchers =  ''(PROTOCOL=TCP) (SERVICE=cdbstbyXDB)'' comment= '''' scope=spfile
sql statement: alter system set  db_unique_name =  ''cdbstby'' comment= '''' scope=spfile
sql statement: alter system set  db_create_file_dest =  ''/u01/app/oracle/oradata/cdbstby'' comment= '''' scope=spfile
sql statement: alter system set  db_recovery_file_dest =  ''/u01/app/oracle/oradata/cdbstby'' comment= '''' scope=spfile
sql statement: alter system set  control_files =  ''/u01/app/oracle/oradata/cdbstby/cdbstby.ctl'' comment= '''' scope=spfile
sql statement: alter system set  db_file_name_convert =  ''/u01/app/oracle/oradata/CDB/datafile/'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/EAF5D9665BD920EDE0436F38A8C0925F/datafile/'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/EAF567FA97681A8CE0436F38A8C0EAC5/datafile'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/EAE60779AFDD1833E0436F38A8C00627/datafile'', ''/u01/app/oracle/oradata/cdbstby/'' comment= '''' scope=spfile
sql statement: alter system set  log_file_name_convert =  ''/u01/app/oracle/oradata/CDB/onlinelog/'', ''/u01/app/oracle/oradata/cdbstby/'', ''/u01/app/oracle/oradata/CDB/standbylog'', ''/u01/app/oracle/oradata/cdbstby/'' comment= '''' scope=spfile
sql statement: alter system set  log_archive_max_processes =  5 comment= '''' scope=spfile
sql statement: alter system set  fal_client =  ''cdbstby'' comment= '''' scope=spfile
sql statement: alter system set  fal_server =  ''cdb'' comment= '''' scope=spfile
sql statement: alter system set  log_archive_config =  ''dg_config=(cdb,cdbstby)'' comment= '''' scope=spfile
sql statement: alter system set  log_archive_dest_2 =  ''service=cdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=cdb'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1386283008 bytes

Fixed Size                     2288248 bytes
Variable Size                469763464 bytes
Database Buffers             905969664 bytes
Redo Buffers                   8261632 bytes

contents of Memory Script:
{
   restore clone from service  'cdb' standby controlfile;
}
executing Memory Script

Starting restore at 18-NOV-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=7 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
output file name=/u01/app/oracle/oradata/cdbstby/cdbstby.ctl
Finished restore at 18-NOV-13

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
   set newname for tempfile  1 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_temp_981hg1cb_.tmp";
   set newname for tempfile  2 to
 "/u01/app/oracle/oradata/cdbstby/pdbseed_temp01.dbf";
   set newname for tempfile  3 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_temp_981hwh9j_.dbf";
   set newname for tempfile  4 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_temp_983jdkw5_.dbf";
   set newname for tempfile  5 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_temp_983l8f5w_.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_system_981h995g_.dbf";
   set newname for datafile  3 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_sysaux_981h6mvg_.dbf";
   set newname for datafile  4 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_undotbs1_981hccop_.dbf";
   set newname for datafile  5 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_system_981hg83d_.dbf";
   set newname for datafile  6 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_users_981hcbl7_.dbf";
   set newname for datafile  7 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_sysaux_981hg839_.dbf";
   set newname for datafile  8 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_system_981htofg_.dbf";
   set newname for datafile  9 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_sysaux_981htog9_.dbf";
   set newname for datafile  10 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_users_981hwyh5_.dbf";
   set newname for datafile  11 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_system_983jbk2m_.dbf";
   set newname for datafile  12 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_sysaux_983jbk65_.dbf";
   set newname for datafile  13 to
 "/u01/app/oracle/oradata/cdbstby//o1_mf_users_983jf6w8_.dbf";
   set newname for datafile  14 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_system_983l5zj2_.dbf";
   set newname for datafile  15 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_sysaux_983l6pxq_.dbf";
   set newname for datafile  16 to
 "/u01/app/oracle/oradata/cdbstby/o1_mf_users_983l912g_.dbf";
   restore
   from service  'cdb'   clone database
   ;
   sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/cdbstby/o1_mf_temp_981hg1cb_.tmp in control file
renamed tempfile 2 to /u01/app/oracle/oradata/cdbstby/pdbseed_temp01.dbf in control file
renamed tempfile 3 to /u01/app/oracle/oradata/cdbstby//o1_mf_temp_981hwh9j_.dbf in control file
renamed tempfile 4 to /u01/app/oracle/oradata/cdbstby//o1_mf_temp_983jdkw5_.dbf in control file
renamed tempfile 5 to /u01/app/oracle/oradata/cdbstby/o1_mf_temp_983l8f5w_.dbf in control file

executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting restore at 18-NOV-13
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/cdbstby/o1_mf_system_981h995g_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/cdbstby/o1_mf_sysaux_981h6mvg_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/cdbstby/o1_mf_undotbs1_981hccop_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/cdbstby/o1_mf_system_981hg83d_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/cdbstby/o1_mf_users_981hcbl7_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/cdbstby/o1_mf_sysaux_981hg839_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/cdbstby//o1_mf_system_981htofg_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/cdbstby//o1_mf_sysaux_981htog9_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/cdbstby//o1_mf_users_981hwyh5_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/cdbstby//o1_mf_system_983jbk2m_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/cdbstby//o1_mf_sysaux_983jbk65_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00013 to /u01/app/oracle/oradata/cdbstby//o1_mf_users_983jf6w8_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00014 to /u01/app/oracle/oradata/cdbstby/o1_mf_system_983l5zj2_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00015 to /u01/app/oracle/oradata/cdbstby/o1_mf_sysaux_983l6pxq_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00016 to /u01/app/oracle/oradata/cdbstby/o1_mf_users_983l912g_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 18-NOV-13

sql statement: alter system archive log current

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_system_98msfwwz_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_sysaux_98msj0o7_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_undotbs1_98msmb7s_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=12 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_system_98msmpz1_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=13 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_users_98msnj2v_.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=14 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_sysaux_98msnlkh_.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=15 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_system_98mspcq8_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=16 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_sysaux_98msq3km_.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=17 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_users_98msrtlp_.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=18 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_system_98msrx23_.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=19 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_sysaux_98msspsx_.dbf
datafile 13 switched to datafile copy
input datafile copy RECID=20 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_users_98msvf7v_.dbf
datafile 14 switched to datafile copy
input datafile copy RECID=21 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_system_98msvjkx_.dbf
datafile 15 switched to datafile copy
input datafile copy RECID=22 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_sysaux_98mswn1c_.dbf
datafile 16 switched to datafile copy
input datafile copy RECID=23 STAMP=831829284 file name=/u01/app/oracle/oradata/cdbstby/CDBSTBY/datafile/o1_mf_users_98msybc9_.dbf
Finished Duplicate Db at 18-NOV-13

RMAN>

Script :
--------
run {
duplicate target database for standby from active database
spfile
parameter_value_convert 'cdb','cdbstby'
set db_unique_name='cdbstby'
set db_create_file_dest='/u01/app/oracle/oradata/cdbstby'
set db_recovery_file_dest='/u01/app/oracle/oradata/cdbstby'
set control_files='/u01/app/oracle/oradata/cdbstby/cdbstby.ctl'
set db_file_name_convert='/u01/app/oracle/oradata/CDB/datafile/','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/EAF5D9665BD920EDE0436F38A8C0925F/datafile/','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/EAF567FA97681A8CE0436F38A8C0EAC5/datafile','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/EAE60779AFDD1833E0436F38A8C00627/datafile','/u01/app/oracle/oradata/cdbstby/'
set log_file_name_convert='/u01/app/oracle/oradata/CDB/onlinelog/','/u01/app/oracle/oradata/cdbstby/','/u01/app/oracle/oradata/CDB/standbylog','/u01/app/oracle/oradata/cdbstby/'
set log_archive_max_processes='5'
set fal_client='cdbstby'
set fal_server='cdb'
set log_archive_config='dg_config=(cdb,cdbstby)'
set log_archive_dest_2='service=cdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=cdb'
;
}

10. Perform a log switch on the primary database and redo will start being sent to the standby
[oracle@dbnode bin]$ export ORACLE_SID=cdb
[oracle@dbnode bin]$ ./sqlplus /nolog
SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 16:03:00 2013
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> connect sys/oracle@192.168.56.111:1521/cdb as sysdba
Connected.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     30
Next log sequence to archive   32
Current log sequence           32

SQL> alter system switch logfile;
System altered.

SQL> alter system switch logfile;
System altered.

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED

11. Start the managed recovery process in Physical Standby Database (cdbstby)
[oracle@dbnode bin]$ export ORACLE_SID=cdbstby
[oracle@dbnode bin]$ ./sqlplus "/ as sysdba"
SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 16:04:05 2013
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, OLAP, Advanced Analytics and Real Application Testing options

SQL> connect sys/oracle@192.168.56.111:1521/cdbstby as sysdba
Connected.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     32
Next log sequence to archive   0
Current log sequence           34

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       MOUNTED
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED

SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.

SQL> select con_id,name,open_mode from v$database;

    CON_ID NAME      OPEN_MODE
---------- --------- --------------------
         0 CDB       MOUNTED

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       MOUNTED
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED

12. Switch archive logs in primary database (cdb)
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     32
Next log sequence to archive   34
Current log sequence           34

SQL> alter system switch logfile;
System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     33
Next log sequence to archive   35
Current log sequence           35

13. Check in Physical Standby database (cdbstby)
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     33
Next log sequence to archive   0
Current log sequence           35

14. Start Data Guard Broker on Primary Database (cdb)
SQL> alter system set dg_broker_start=true;
System altered.

SQL> show parameter dg_

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name               string
dg_broker_config_file1               string      /u01/app/oracle/product/12.1.0/dbhome/dbs/dr1cdb.dat
dg_broker_config_file2               string      /u01/app/oracle/product/12.1.0/dbhome/dbs/dr2cdb.dat
dg_broker_start                      boolean     TRUE

15. Start Data Guard Broker on Physical Standby Database (cdb)
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     33
Next log sequence to archive   0
Current log sequence           35

SQL> alter system set dg_broker_start=true;
System altered.

SQL> show parameter dg_

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name               string
dg_broker_config_file1               string      /u01/app/oracle/product/12.1.0/dbhome/dbs/dr1cdbstby.dat
dg_broker_config_file2               string      /u01/app/oracle/product/12.1.0/dbhome/dbs/dr2cdbstby.dat
dg_broker_start                      boolean     TRUE

16. Enable Database Flashback on Primary Database (cdb)

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> connect sys/oracle as sysdba
Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1386283008 bytes
Fixed Size                  2288248 bytes
Variable Size             469763464 bytes
Database Buffers          905969664 bytes
Redo Buffers                8261632 bytes
Database mounted.

SQL> alter database flashback on;
Database altered.

SQL> alter database open;
Database altered.

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED

17. Enable Database Flashback on Physical Database (cdbstby)

SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

SQL> connect sys/oracle as sysdba
Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1386283008 bytes
Fixed Size                  2288248 bytes
Variable Size             469763464 bytes
Database Buffers          905969664 bytes
Redo Buffers                8261632 bytes
Database mounted.

SQL> alter database flashback on;
Database altered.

SQL> alter database open read only;
Database altered.

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED

Primary database:
============
SQL> alter system set log_archive_dest_2='';
System altered.

Standby Database:
=============
SQL> alter system set log_archive_dest_2='';
System altered.

18. Complete Data Guard configuration

[oracle@dbnode bin]$ export ORACLE_SID=cdb
[oracle@dbnode bin]$ ./dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> create configuration 'DGCONFIG' as primary database is 'cdb' connect identifier is cdb;
Configuration "DGCONFIG" created with primary database "cdb"

DGMGRL> add database 'cdbstby' as connect identifier is cdbstby;
Database "cdbstby" added

DGMGRL> enable configuration;
Enabled.

DGMGRL> show configuration;
Configuration - DGCONFIG

  Protection Mode: MaxPerformance
  Databases:
  cdb     - Primary database
    cdbstby - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> exit
[oracle@dbnode bin]$ ./sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 16:25:19 2013
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> connect sys/oracle@192.168.56.111:1521/cdb as sysdba
Connected.

SQL> alter system set log_archive_dest_2='service=cdbstby async valid_for=(online_logfile,primary_role) db_unique_name=cdbstby';
System altered.

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

19. Enabling Fast-Start Failover

[oracle@dbnode bin]$ export ORACLE_SID=cdb
[oracle@dbnode bin]$ ./dgmgrl

DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> edit database cdb set property FastStartFailoverTarget=cdbstby;
Property "faststartfailovertarget" updated

DGMGRL> edit database cdbstby set property FastStartFailoverTarget=cdb;
Property "faststartfailovertarget" updated

DGMGRL> enable fast_start failover;
Enabled.

DGMGRL> show configuration;

Configuration - DGCONFIG

  Protection Mode: MaxPerformance
  Databases:
  cdb     - Primary database
    Warning: ORA-16819: fast-start failover observer not started

    cdbstby - (*) Physical standby database
      Warning: ORA-16819: fast-start failover observer not started

Fast-Start Failover: ENABLED

Configuration Status:
WARNING

20. Using Active Data Guard - edit database 'cdbstby' set state='apply-on'

[oracle@dbnode bin]$ export ORACLE_SID=cdbstby
[oracle@dbnode bin]$ ./dgmgrl

DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> edit database 'cdbstby' set state='apply-off';
Succeeded.

DGMGRL> exit

[oracle@dbnode bin]$ export ORACLE_SID=cdbstby
[oracle@dbnode bin]$ ./sqlplus "/ as sysdba"

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 16:30:58 2013
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, OLAP, Advanced Analytics and Real Application Testing options

SQL> connect sys/oracle@192.168.56.111:1521/cdbstby as sysdba
Connected.

SQL> select con_id,name,open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

[oracle@dbnode bin]$ export ORACLE_SID=cdbstby
[oracle@dbnode bin]$ ./dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production

Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> edit database 'cdbstby' set state='apply-on';
Succeeded.

DGMGRL> exit
[oracle@dbnode bin]$

21. Starting the Observer & Open One More Terminal:

[oracle@dbnode datafile]$ export ORACLE_SID=cdb
[oracle@dbnode datafile]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode datafile]$ cd /u01/app/oracle/product/12.1.0/dbhome/bin
[oracle@dbnode bin]$ ./dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production

Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> start observer;
Observer started

22. After strating Observer check the status

[oracle@dbnode bin]$ ./dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production

Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> show configuration;

Configuration - DGCONFIG

  Protection Mode: MaxPerformance
  Databases:
  cdb     - Primary database
    cdbstby - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS

DGMGRL>

23. Shutting Down Of Physical Standby database (cdbstby) & Primary Database (cdb)

[oracle@dbnode bin]$ ps -ef | grep pmon
oracle    3749     1  0 10:36 ?        00:00:03 asm_pmon_+ASM
oracle    4483     1  0 16:15 ?        00:00:00 ora_pmon_cdb
oracle    4845     1  0 16:17 ?        00:00:00 ora_pmon_cdbstby
oracle    5636 27269  0 16:37 pts/3    00:00:00 grep pmon

[oracle@dbnode bin]$ export ORACLE_SID=cdbstby
[oracle@dbnode bin]$ ./sqlplus "/ as sysdba"
SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 16:37:11 2013
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, OLAP, Advanced Analytics and Real Application Testing options

SQL> connect sys/oracle@192.168.56.111:1521/cdbstby as sysdba
Connected.

SQL> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

[oracle@dbnode bin]$ export ORACLE_SID=cdb
[oracle@dbnode bin]$ ./sqlplus /nolog
SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 16:37:40 2013
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> connect sys/oracle@192.168.56.111:1521/cdb as sysdba
Connected.

SQL> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

Saturday, November 9, 2013

Oracle Database 12c – Container Database & Pluggable Databases (Part-4)

Plugging an Unplugged Pluggable Databases (PDBs) in Container Databases (CDBs):



Useful Scenario: If you want to upgrade to the Oracle latest version, but you do not want to apply for all PDBs in Container Database. Unplug PDB from Container Database and plug them into newly created Container Database of higher Oracle version.


Connect to Container Database (CDB1)
SQL> conn sys/oracle@localhost:1521/cdb1 as sysdba
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

SQL> select name,open_mode from v$pdbs;

NAME                                                  OPEN_MODE
------------------------------                ------------------
PDB1                                                    READ WRITE
PDB2                                                    MOUNTED

Close Pluggable Database (PDB2) in Container Database (CDB1)
SQL> alter pluggable database pdb2 close immediate;
SQL> alter pluggable database pdb2 unplug into '/u01/app/oracle/oradata/cdb1/pdb1/pdb1.xml';

Drop Pluggable database and keep datafiles
SQL> drop pluggable database pdb2 keep datafiles;

[oracle@localhost bin]$ cd /u01/app/oracle/oradata/cdb1/pdb2
[oracle@localhost pdb2]$ ls -lrth
-rw-r--r--. 1 oracle oinstall 3.5K Jul  4 09:09 pdb2.xml

Connect to Container Database (CDB2)
SQL> connect sys/oracle@localhost:1521/cdb2 as sysdba
SQL> create pluggable database pdb2_plug_nocopy
using '/u01/app/oracle/oradata/cdb1/pdb2/pdb2.xml'
nocopy
tempfile reuse;

SQL> select pdb_name, status from cdb_pdbs where pdb_name='PDB2_PLUG_NOCOPY';
SQL> select open_mode from v$pdbs where name='PDB2_PLUG_NOCOPY';
 


Connect Container Database (CDB1) and close Pluggable Database (PDB1)
SQL> alter pluggable database pdb1 close immediate;
SQL> select name,open_mode from v$pdbs;

NAME                                                  OPEN_MODE
------------------------------                 ------------------
PDB$SEED                                          READ ONLY
PDB1                                                    MOUNTED

SQL> alter pluggable database pdb1 unplug into '/u01/app/oracle/oradata/cdb1/pdb1/pdb1.xml';
SQL> drop pluggable database pdb1 keep datafiles;

Connect Container Database (CDB2) and Create required directories
[oracle@localhost bin]$ cd /u01/app/oracle/oradata/cdb2
[oracle@localhost cdb2]$ mkdir pdb2_plug_copy

Plug Unplugged PDB in Container Database (CDB2)
SQL> create pluggable database pdb_plug_copy using '/u01/app/oracle/oradata/cdb1/pdb1/pdb1.xml'
COPY
FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdb1','/u01/app/oracle/oradata/cdb2/pdb1_plug_copy');



SQL> select pdb_name, status from cdb_pdbs where pdb_name='PDB_PLUG_COPY';
SQL> select open_mode from v$pdbs where name='PDB_PLUG_COPY';