前言

可以使用多种技术创建 pdb、应用程序容器并且迁移

【德哥说库系列】-Oracle 19C PDB创建大全-LMLPHP

📣 1.Scratch方式

【德哥说库系列】-Oracle 19C PDB创建大全-LMLPHP

3 : Creating a Pdb Using The Storage, Default Tablespace, Path_Prefix, And
File_Name_Convert Clauses

create pluggable database pdb3 admin user saladm identified by oracle storage (maxsize 3g)
default tablespace wl
datafile '/u01/app/oracle/oradata/ORADB/pdb3/wl01.dbf' size 200m autoextend on
path_prefix = '/u01/app/oracle/oradata/ORADB/pdb3/'
file_name_convert = ('/u01/app/oracle/oradata/ORADB/pdbseed',
'/u01/app/oracle/oradata/ORADB/pdb3');

alter pluggable database PDB4 open;

📣 2.Cloning方式

✨ 2.1 Cloning from Local

✨ 2.2 Cloning Remote PDB

【德哥说库系列】-Oracle 19C PDB创建大全-LMLPHP

确保字节序一致
select d.inst_id, t.platform_id, t.platform_name, t.endian_format, d.name from
v$transportable_platform t, gv$database d
where t.platform_name = d.platform_name;

【德哥说库系列】-Oracle 19C PDB创建大全-LMLPHP

目标端创建 dblink
source =
 (DESCRIPTION =
 (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.31)(PORT = 1521))
 )
 (CONNECT_DATA =
 (SERVICE_NAME =prod)
 )
)

create database link mydb connect to system identified by oracle using 'source';

✨ 2.3 Cloning Remote Non-CDB

确保字节序一致
select d.inst_id, t.platform_id, t.platform_name, t.endian_format, d.name from
v$transportable_platform t, gv$database d
where t.platform_name = d.platform_name;
目标端创建 dblink
nocdb =
 (DESCRIPTION =
 (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.31)(PORT = 1521))
 )
 (CONNECT_DATA =
 (SERVICE_NAME =oradb)
 )
)

create database link orcl_link connect to system identified by beijing using 'nocdb';

📣 3. Relocating

📣 4. PDB热插拔

1.非 CDB 处于事务一致状态,并将其置于只读模式
startup open read only

ORA-00845: MEMORY_TARGET not supported on this system
tmpfs /dev/shm tmpfs defaults,size=3G 0 0
mount -o remount,size=3G /dev/shm


2.非 CDB 的 XML 文件
begin
dbms_pdb.describe(
pdb_descr_file => '/tmp/ncdb.xml');
end;
/

3.兼容性检查,CDB中确认
SET SERVEROUTPUT ON
declare
compatible constant varchar2(3) :=
case dbms_pdb.check_plug_compatibility(pdb_descr_file =>
'/tmp/ncdb.xml',pdb_name => 'NCDB')
when true then 'yes'
else 'no'
end;
begin
dbms_output.put_line(compatible);
end;
/

4.关闭非 CDB
shutdown immediate


5.创建目录
mkdir /u01/app/oracle/oradata/ORADB/ncdb


6.插入非 CDB,将文件复制到新位置
create pluggable database ncdb using '/tmp/ncdb.xml' copy 
file_name_convert = ('/u01/app/oracle/oradata/ORCL/','/u01/app/oracle/oradata/ORADB/ncdb/');


7.必须先运行脚本,才能首次打开 PDB
alter session set container=ncdb;
@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

01-10 15:14