【新炬網路名師大講堂】clone oracle 12c pluggable databases

shsnchyw發表於2014-12-18

PDB(pluggable databases)是Oracle 12c 引入的一個新特性,如其名,在oracle 12c 中PDB可以在CDB(container database)中進行“插拔”,除此之外PDB還有很多吸引人的東西,如更簡單快捷建立一個PDB的副本。
    以下內容介紹如何在同一個CDB中克隆PDB。
1.將需要克隆的PDB設定為READ ONLY 模式

[oracle@oracle12c ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Jun 20 23:29:38 2014

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> set line 300

SQL> select NAME,OPEN_MODE from v$pdbs where name=’PDBORCL12C’;

NAME OPEN_MODE

——————- ——————

PDBORCL12C READ WRITE

SQL> alter pluggable database pdborcl12c close immediate;

Pluggable database altered.

SQL> select NAME,OPEN_MODE from v$pdbs where name=’PDBORCL12C’;

NAME OPEN_MODE

——————— ——————-

PDBORCL12C MOUNTED

SQL> alter pluggable database pdborcl12c open read only;

Pluggable database altered.

SQL> select NAME,OPEN_MODE from v$pdbs where name=’PDBORCL12C’;

NAME OPEN_MODE

———————- —————–

PDBORCL12C READ ONLY

SQL> exit

2.確定空間需求

SQL> alter session set container=pdborcl12c;

Session altered.

SQL> set line 300

SQL> col tablespace_name for a32

SQL> col file_name for a128

SQL> select tablespace_name,file_name,bytes/1024/1024 MB from dba_data_files;

TABLESPACE_NAME FILE_NAME MB

—————– ——————————————————————————————————————————– ———-

SYSTEM /oracle/12c/oradata/ORCL12C/F8BDD749BE6A231CE043230A0A0A7F5C/datafile/o1_mf_system_9pkzo0vz_.dbf 270

SYSAUX /oracle/12c/oradata/ORCL12C/F8BDD749BE6A231CE043230A0A0A7F5C/datafile/o1_mf_sysaux_9pkzo118_.dbf 680

USERS /oracle/12c/oradata/ORCL12C/F8BDD749BE6A231CE043230A0A0A7F5C/datafile/o1_mf_users_9pkzp768_.dbf 512

SQL> select tablespace_name,file_name,bytes/1024/1024 MB from dba_temp_files

TABLESPACE_NAME          FILE_NAME                                                                 MB

——————————– ——————————————————————————————————————————– ———-

TEMP                 /oracle/12c/oradata/ORCL12C/F8BDD749BE6A231CE043230A0A0A7F5C/datafile/o1_mf_temp_9pkzoz5y_.dbf                      507

空間需求2593MB,需保證 /oracle/12c/oradata可以空間大於2593MB。

3.為克隆PDB建立目錄

 [oracle@oracle12c ORCL12C]$ pwd

/oracle/12c/oradata/ORCL12C

[oracle@oracle12c ORCL12C]$ mkdir pdborcl12c_clone

[oracle@oracle12c ORCL12C]$ ls -l

total 20

drwxr-x—. 2 oracle oinstall 4096 May 6 23:13 controlfile

drwxr-x—. 2 oracle oinstall 4096 May 6 23:14 datafile

drwxr-x—. 3 oracle oinstall 4096 May 6 23:24 F8BDD749BE6A231CE043230A0A0A7F5C

drwxr-x—. 2 oracle oinstall 4096 May 6 23:41 onlinelog

drwxr-xr-x. 2 oracle oinstall 4096 Jun 21 00:02 pdborcl12c_clone

4.配置db_create_file_dest引數

 SQL> alter system set db_create_file_dest=’/oracle/12c/oradata/ORCL12C/pdborcl12c_clone’ ;

System altered.

5.克隆PDB

SQL> create pluggable database pdborcl12c_clone from pdborcl12c;

Pluggable database created.

SQL> alter pluggable database pdborcl12c_clone open;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME             OPEN_MODE

—————————— ———-

PDB$SEED         READ ONLY

PDBORCL12C         READ ONLY

PDBORCL12C_CLONE     READ WRITE

SQL> conn system/oracle@localhost:1521/pdborcl12c_clone

Connected.

SQL> show con_name

CON_NAME

——————————

PDBORCL12C_CLONE

6.將源PDB改為OPEN模式

SQL> alter session set container=cdb$root;

Session altered.

SQL> alter pluggable database pdborcl12c close immediate;

Pluggable database altered.

SQL> alter pluggable database pdborcl12c open;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME             OPEN_MODE

—————————— ———-

PDB$SEED         READ ONLY

PDBORCL12C         READ WRITE

PDBORCL12C_CLONE     READ WRIT

    至此,克隆PDB完成。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29960155/viewspace-1372534/,如需轉載,請註明出處,否則將追究法律責任。

相關文章