Oracle12c创建及删除PDB
在12C R1版本中只支持Global Shared Undo模式,所有container共享一个UNDO表空间;在12C R2引入了PDB Local Undo模式,每个container都有自己的UNDO 表空间,对于RAC是每
个实例每个container都有自己的UNDO表空间。在DBCA时会有Local Undo选项,且默认勾选。
在12c R1版本中clone PDB源库需要打开在read only只读模式 ,12c R2版本中引入了local undo mode, PDB源库在read write读写模式也可以clone。
克隆PDB要求:
1. Archive Log Enabled
2. Local Undo Enabled
3. destination CDB must have a public database link to the source CDB,have sufficient privileges to use the database link
可以通过图形化工具DBCA、命令行、em express等方式创建和删除PDB,该处只描述命令行方式操作。
一、创建PDB
1. 克隆种子容器
SQL> select * from v$dbfile; #查看路径
SQL> show parameter db_create_file_dest;
SQL> create pluggable database PDB3 admin user song identified by song file_name_convert=('/home/oracle/u01/app/oracle/oradata/orcl/pdbseed','/home/oracle/u01/app/oracle/oradata/orcl/PDB3');
2. 克隆本地PDB
1) 查看归档是否打开
SQL> archive log list;
2) local undo是否开启
SQL> col PROPERTY_NAME for a25;
SQL> col PROPERTY_VALUE for a25;
SQL> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where property_name='LOCAL_UNDO_ENABLED';
3) 开始克隆
SQL> show pdbs;
a)使用OMF功能创建,不推荐使用该功能创建PDB,路径和数据文件名不是常规的。
SQL> show parameter DB_CREATE_FILE_DEST; #OMF功能路径
SQL> show parameter pdb_file_name_convert; #设置初始化参数
SQL> alter system set db_create_file_dest='/home/oracle/u01/app/oracle/oradata/orcl';
SQL> alter session set pdb_file_name_convert='ORCLPDB','PDB5';
SQL> create pluggable database PDB5 from ORCLPDB;
报错:ORA-65005: 文件缺少文件名模式或其文件名模式无效,未设置DB_CREATE_FILE_DEST参数
b)使用file_name_convert创建
SQL> create pluggable database PDB4 from ORCLPDB file_name_convert=(
'/home/oracle/u01/app/oracle/oradata/orcl/orclpdb','/home/oracle/u01/app/oracle/oradata/orcl/pdb4');
SQL> alter pluggable database pdb4 open;
3. 克隆异地PDB
源端
SQL> create user c##sonny identified by sonny container=all;
SQL> grant dba to c##sonny container=all;
目标端
create database link clonepdb connect to c##sonny identified by sonny using '(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.208)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORCLPDB)))';
SQL> create pluggable database sonnypdb from ORCLPDB@clonepdb;
$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql脚本
二、删除PDB
PDB需要处于MOUNTED状态才可以删除
SQL> alter pluggable database pdb5 close immediate;
SQL> drop pluggable database pdb5 including datafiles;
SQL> show pdbs;
至此PDB的创建与删除就完成了,下面为PDB的开启与关闭操作:
SQL>alter pluggable database orclpdb open; #启动单个PDB
SQL>alter pluggable database all open; #启动所有PDB
SQL>alter pluggable database orclpdb close immediate; #关闭单个PDB
SQL>alter pluggable database all close immediate; #关闭所有PDB
自动启动所有PDB
数据库启动的时候所有的PDB的状态为MOUNTED,以下设置自动启动(CDB级别操作):
create or replace trigger sys.pdb_startup
after startup on database
begin
execute immediate 'alter pluggable database all open';
end pdb_startup;
/
克隆pdb文章
https://www.cnblogs.com/andy6/p/6867240.html
切换shared undo/local undo文章
https://blog.csdn.net/zhang123456456/article/details/71374528