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.确定空间需求
-
sqlplus / as sysdba
-
SQL*Plus: Release 12.1.0.1.0 Production on Fri Jun 20 23:46:08 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> 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
-
SQL> exit
空间需求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参数
-
sqlplus / as sysdba
-
-
SQL*Plus: Release 12.1.0.1.0 Production on Sat Jun 21 00:07:50 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> alter system set db_create_file_dest='/oracle/12c/oradata/ORCL12C/pdborcl12c_clone' ;
-
-
System altered.
5.克隆PDB
-
sqlplus / as sysdba
-
-
SQL*Plus: Release 12.1.0.1.0 Production on Sat Jun 21 00:19:45 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> 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> connect / as sysdba
-
Connected.
-
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
本文乃付义原创文章,请勿转载。如须转载请详细标明转载出处。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7243689/viewspace-1190449/
,如需转载,请注明出处,否则将追究法律责任。