Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Article 4

$
0
0

    Step by step Clone PDB within CDB in Oracle Database 12c


Step by step Clone PDB within CDB in Oracle Database 12c

Oracle database 12c is providing new feature to clone database in very simple steps.
It is very easy and simple to clone database in Oracle version 12c.

Here, I am listing step by step to clone PDB (Plug-able Database ) database within it's CDB (Container Database).

Example shows, clone database from pdborcl to new database pbduporcl. 

Below are the Steps,
Step 1:- Setting the Source PDB to READ ONLY Mode
Step 2:- Create directory for new clone PDB.
Step 3:- Configure OMF to the directory of the Clone PDB
Step 4:- Clone the PDB within CDB
Step 5:- Set source PDB back to open mode.
Step 6:- Check status of all PDBs

Step 1:- Setting the Source PDB to READ ONLY Mode


Connect with SYS user and make pdborcl database to read only mode.
linux]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:28:40 2018
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, OLAP, Advanced Analytics and Real Application Testing options

SQL> alter pluggable database pdborcl close immediate;
Pluggable database altered.

SQL> alter pluggable database pdborcl open read only;
Pluggable database altered.

SQL>
SQL> exit


Step 2:- Create directory for new clone PDB

Now Create directory structure for new pdbduporcl database.

linux]$ pwd
/mnt/devops_0/Oracle/oracle/oracledat


linux]$ mkdir pdbduporcl
linux]$ ls -ltr
total 2080842
drwxr-x---+ 2 oracle oinstall         5 May  8 14:19 pdbseed
-rw-r-----+ 1 oracle oinstall  52429312 May  9 01:31 redo02.log
-rw-r-----+ 1 oracle oinstall  52429312 May  9 11:30 redo03.log
-rw-r-----+ 1 oracle oinstall 206577664 May  9 11:31 temp01.dbf
-rw-r-----+ 1 oracle oinstall   5251072 May  9 11:35 users01.dbf
-rw-r-----+ 1 oracle oinstall 361766912 May  9 11:45 undotbs01.dbf
-rw-r-----+ 1 oracle oinstall 838868992 May  9 11:45 system01.dbf
-rw-r-----+ 1 oracle oinstall 744497152 May  9 11:45 sysaux01.dbf
-rw-r-----+ 1 oracle oinstall  52429312 May  9 11:45 redo01.log
drwxr-x---+ 2 oracle oinstall         7 May  9 11:45 pdborcl
-rw-r-----+ 1 oracle oinstall  17973248 May  9 11:45 control01.ctl
drwxr-xr-x+ 2 oracle oinstall         2 May  9 11:45 pdbduporcl



Step 3:- Configure OMF to the directory of the Clone PDB (Optional)

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:48:01 2018
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, OLAP, Advanced Analytics and Real Application Testing options

SQL> alter system set db_create_file_dest='/u01/Oracle/oracle/oracledat/pdbduporcl';
System altered.
SQL>



Step 4:- Clone the PDB within CDB

Now below steps will clone database from pdborcl to pdbduporcl.

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:49:53 2018
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, OLAP, Advanced Analytics and Real Application Testing options

SQL>
SQL> create pluggable database pdbduporcl from pdborcl;
Pluggable database created.


Open new PDB database

SQL> alter pluggable database pdbduporcl open;
Pluggable database altered.


Add TNS Entery in tnsnames.ora file.

pdbduporcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Doyenltp0025)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdbduporcl)
    )
  )

Connect to new PDB database

linux]$ sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:35:18 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> conn sys/sysdba123@pdbduporcl as sysdba
Connected.
SQL>
SQL> show con_name
CON_NAME
------------------------------
PDBDUPORCL
SQL>



Step 5:- Set source PDB back to open mode.

Now, set Source PDB back to open mode and make it available to users.

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:37:41 2018
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, OLAP, Advanced Analytics and Real Application Testing options

SQL>
SQL> alter pluggable database pdborcl close immediate;
Pluggable database altered.

SQL>
SQL> alter pluggable database pdborcl open;
Pluggable database altered.



Step 6:- Check status of all PDBs


Now check the status of all PDBs as below.

linux]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:37:41 2018
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, OLAP, Advanced Analytics and Real Application Testing options
SQL> select con_id, dbid, name, open_mode from v$pdbs;

    CON_ID  DBID          NAME                          OPEN_MODE
-------------- --------------  ---------------------------  ------------------
         2         3707469898 PDB$SEED                  READ ONLY
         3         1332221668 PDBORCL                   READ WRITE
         4         1313681298 PDBDUPORCL                READ WRITE

SQL>

Viewing all articles
Browse latest Browse all 1640

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>