暂无图片
暂无图片
6
暂无图片
暂无图片
暂无图片

PDB拔插操作手册

文内导航

  1. 适用范围
  2. 环境信息
  3. 源端目标端一致性对比
  4. 源库拔出PDB
  5. 目标端插入PDB
  6. 参考文档

1. 适用范围

12.1.0.1之后,CDB环境

2. 环境信息

源端和目标端为同一套RAC上的两个CDB实例,PDB1,CON_ID 3为计划迁移的PDB
源端:
image.png
目标端:
image.png

set lines 200 
col name for a90
select CON_ID,FILE#,name from v$datafile;

源端:
image.png
目标端:
image.png

3. 源端目标端一致性对比

确保字符集一致

select userenv('language') from dual;

image.png

确保组件安装一致

set lines 200
set pages 99
col COMP_ID for a10
col COMP_NAME for a50
col status for a10
select COMP_ID,COMP_NAME,VERSION,VERSION_FULL,STATUS from dba_registry;

image.png
确保补丁一致

set lines 200
col ACTION_TIME for a40
col COMMENTS for a30
col ACTION for a10
col VERSION for a15
col BUNDLE_SERIES for a20
col NAMESPACE for a10
select * from dba_registry_history;

image.png

4. 源库拔出PDB

4.1 关闭所有实例上需要拔出的pdb

alter pluggable database pdb1 close immediate instances=all;

4.2 拔出PDB

拔出PDB,并指定生成XML文件;因为拔出后的pdb无法正常启动,只能执行插入或者删除操作。如需回退,注意做好备份或CDB还原点创建。

alter pluggable database pdb1 unplug into '/home/oracle/pdb1.xml';

4.3 源端删除PDB并保留数据文件

drop pluggable database pdb1 keep datafiles;

4.4 源端删除完验证

看不到删除的pdb

show pdbs
select pdb_name, status from cdb_pdbs where pdb_name in ('PDB1');

5. 目标端插入PDB

5.1 目标端兼容性检查

确保兼容性通过,查询pdb_plug_in_violations看有什么警告的地方

set serveroutput on
DECLARE
   compatible BOOLEAN := FALSE;
BEGIN  
   compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
        pdb_descr_file => '/home/oracle/pdb1.xml');
   if compatible then
      DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? YES');
   else DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? NO');
   end if;
END;
/

image.png

set lines 300
col name for a10
col type for a10
col message for a80
select con_id,name,type,message,status from pdb_plug_in_violations order by name,time;

5.2 目标端插入PDB

使用NOCOPY选项(除此之外,还有COPY,MOVE等选项,分别适用于不同场景)
此处如需修改pdb name,则可以直接指定新的pdb name即可。

create pluggable database pdb1 using '/home/oracle/pdb1.xml' NOCOPY TEMPFILE REUSE;

5.3 目标端检查PDB

使用NOCOPY方式,PDB的数据文件位置不变;临时文件在删除源库PDB时自动删除,新临时文件自动创建在目标端PDB的位置

select pdb_name, status from cdb_pdbs where pdb_name='PDB1';

image.png
image.png

set lines 200 
col name for a90
select CON_ID,FILE#,name from v$datafile;

image.png

select CON_ID,FILE#,name from v$tempfile;

image.png

5.4 目标端开启并检查PDB

确保状态为RESOLVED

alter pluggable database PDB1 open instances=all;
alter pluggable database PDB1 save state instances=all;


set lines 300
col name for a10
col type for a10
col message for a80
select con_id,name,type,message,status from pdb_plug_in_violations order by name,time;

image.png

6. 参考文档

Multitenant Unplug/Plug Best Practices (Doc ID 1935365.1)
How to Unplug and Plugin PDB (Doc ID 2728046.1)


订阅号:DongDB手记
墨天轮:https://www.modb.pro/u/231198
image.png

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论