Bo's Oracle Station

【博客文章2022】真实环境下创建pdb、在两个cdb之间迁移pdb和创建proxy pdb的操作汇总系列5

2022-3-10 17:12| 发布者: admin| 查看: 194| 评论: 0|原作者: Bo Tang

摘要: 真实环境下创建pdb、在两个cdb之间迁移pdb以及创建proxy pdb的操作汇总系列5
真实环境下创建pdb、在两个cdb之间迁移pdb和创建proxy pdb的操作汇总系列5

Author: Bo Tang

1. 跨根容器操作之——拔出和插入插件数据库(不建议拷贝源头数据文件,如果要使用拷贝方式创建,请使用本文第2节的方法):

    在本实验中,将cdb1中的pdb1_1拔出,并将其插入到cdb2中:
    pdb1_1如果处于打开状态是拔不出来的,必须将其关闭才能拔出来:
    在cdb1上操作:
    把pdb1_1插入cdb2之前,建议先使用dbms_pdb.check_plug_compatibility检测拔出来的pdb1_1兼容性,在cdb2上以sys身份操作:
 
   使用本节方法把pdb1_1插入cdb2时,不建议拷贝源头数据文件,如果要拷贝方式创建请使用本文第2节的方法:
   在cdb2上操作:

 
    在cdb1上删除unplugged的pdb1_1,在cdb1上操作:
2. 跨根容器操作之——拔出和插入插件数据库(使用Archive方法):

    在本实验中,将cdb1中的pdb1_2拔出,并将其插入到cdb2中:
    在cdb1上查看pdb的情况:
    pdb1_2如果处于打开状态是拔不出来的,必须将其关闭才能拔出来:
    在cdb1上操作,注意文件的扩展名.pdb很重要
    pdb1_2插入cdb2之前,建议使用dbms_pdb.check_plug_compatibility检测拔出来的pdb1_2兼容性,在cdb2上以sys身份操作:
 
    在cdb2上操作:

3. 跨根容器操作之——relocate插件数据库:

   
在本实验中,将cdb1中的pdb_cdb1_orcl2 relocate到cdb2中,不改名字,仍叫做pdb_cdb1_orcl2(如果换个名字,比如pdb_cdb2_orcl2,就无法实现relocate AVAILABILITY MAX,只能实现relocate AVAILABILITY NORMAL):
    1)在cdb2做连接到对方system用户的数据库链接:
    在cdb2上操作:

SQL>select  * from dba_db_links;
-----------------------------------------------
SYS    SYS_HUB        SEEDDATA    17-APR-19    NO    NO    YES    NO
SYS    LINK_ORCL2    SYSTEM    orcl2    06-MAR-22    NO    NO    YES    NO
PUBLIC    LINK_PDB1_1    SYSTEM    pdb1_1    09-MAR-22    NO    NO    YES    NO
PUBLIC    LINK_PDB1_2    SYSTEM    pdb1_2    11-MAR-22    NO    NO    YES    NO

SQL> create public database link link_cdb1 connect to system identified by cloud_4U using 'cdb1';
Database link created.
SQL> select  count(*) from dba_source@link_cdb1;
  COUNT(*)
----------
    291100

SQL>
select  * from dba_db_links;
-----------------------------------------------
SYS    SYS_HUB        SEEDDATA    17-APR-19    NO    NO    YES    NO
SYS    LINK_ORCL2    SYSTEM    orcl2    06-MAR-22    NO    NO    YES    NO
PUBLIC    LINK_PDB1_1    SYSTEM    pdb1_1    09-MAR-22    NO    NO    YES    NO
PUBLIC    LINK_PDB1_2    SYSTEM    pdb1_2    11-MAR-22    NO    NO    YES    NO
PUBLIC    LINK_CDB1    SYSTEM    cdb1    15-MAR-22    NO    NO    YES    NO
  
    2)源端cdb1上用于公共数据库链接的用户system需要授权:
    在源端需要一些特殊的权限(光光有dba不够),需要给sysoper的权限。请在cdb1上操作:

grant sysoper to system container=all;
 
    3)relocate cdb1上的pdb_cdb1_orcl2到cdb2
    relocate过程中自动发生的技术步骤大致有以下这些:
    a.  源端和目的地端CDB上记录和同步reloate操作的启动时刻SCN(这就是为何要互相做system的公共数据库链接的原因)
    b.  从源端把pdb的数据文件、undo文件和redo日志文件通过数据库链接拷贝到目的地端
    c.  在目的地端pdb打开之前,源端pdb进行transaction所产生的redo都将传送到目的地端
    d.  当目的地端pdb打开那一刻, 源端pdb上的活跃连接会在txn边界处被终结,新的连接将被导向目的地端,并等待目的地端完成打开操作
    e.  当目的地端pdb打开那一刻, 存在前滚和回滚以保持relocate过程中的数据完整性 
    让cdb1中的pdb_cdb1_orcl2处于高负载插入状态下,同时进行relocate操作:
    在cdb1中的pdb_cdb1_orcl2操作
  
SQL>alter session set nls_language=english;
Session altered.

SQL> create table hr.tbig as select  * from dba_source;

Table created.

SQL> select  count(*) from hr.tbig;

  COUNT(*)
-------------
     387567

注:在执行下面操作时(保证在commit前,插入过程中做relocate),同时在cdb2上操作(见下个代码框提示)!

SQL> insert into hr.tbig select  * from hr.tbig;

387567 rows created.

SQL>
insert into hr.tbig select  * from hr.tbig;

775134 rows created.


SQL> insert into hr.tbig select  * from hr.tbig;

1550268 rows created.

SQL> insert into hr.tbig select  * from hr.tbig;

3100536 rows created.

SQL> insert into hr.tbig select  * from hr.tbig;

6201072 rows created.

SQL> commit;

Commit complete.

SQL> select  count(*) from hr.tbig;

  COUNT(*)
--------------
    12402144

--此刻之后,relocate的目的地端的pdb_cdb1_orcl2已经手工打开

SQL>insert into hr.tbig select  * from hr.tbig;
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 3463959
Session ID: 300 Serial number: 26506


    在上面代码框标注红字处,同时在cdb2上操作:
使用AVAILABILITY MAX子句来执行relocate可以保证源头插件数据库上的工作负载以及会话连接可以被平顺地迁移到目的地插件数据库之上。在这个过程中源头插件数据库即使保持在mount状态,仍然能够通过监听器的forwarding可以把连接指向目的地插件数据库,保证relocate过程中连接还能被保持。 在本实验中,将cdb1中的pdb_cdb1_orcl2 relocate到cdb2中,不改名字,仍叫做pdb_cdb1_orcl2如果换个名字,比如pdb_cdb2_orcl2,就无法实现relocate AVAILABILITY MAX,只能实现relocate AVAILABILITY NORMAL。


[oracle@classroom ~]$ . oraenv
ORACLE_SID = [cdb2] ?
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@classroom ~]$ sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 1 16:21:06 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected.
SQL>create pluggable database pdb_cdb2_orcl2  from pdb_cdb1_orcl2@link_cdb1 relocate availability  max ; 
create pluggable database pdb_cdb2_orcl2  from pdb_cdb1_orcl2@link_cdb1 relocate availability max
*
ERROR at line 1:
ORA-65348: unable to create pluggable database


SQL>create pluggable database pdb_cdb1_orcl2  from pdb_cdb1_orcl2@link_cdb1 relocate availability  max ;
Pluggable database created.

   cdb2上查看:

SQL> select  pdb_id,pdb_name,status from cdb_pdbs where pdb_name=' PDB_CDB1_ORCL2 ';
----------------------------------------------------------------------
8    PDB_CDB1_ORCL2   RELOCATING  
       
    cdb1上查看:

SQL> select  pdb_id,pdb_name,status from cdb_pdbs where pdb_name=' PDB_CDB1_ORCL2 ';
----------------------------------------------------------------------
PDB_CDB1_ORCL2 NORMAL   

    cdb2上relocate的pdb_cdb1_orcl2打开之前,cdb1上的pdb_cdb1_orcl2状态正常,说明事务仍可以进行,将来这些事务会通过日志反映到relocate好的插件数据上(不管是AVAILABILITY NORMAL还是AVAILABILITY MAX。AVAILABILITY MAX时,此刻的事务实际上已经直接连接到relocate中的插件数据库了
    在cdb2打开relocate的pdb_cdb1_orcl2

[oracle@classroom admin]$ tnsping pdb_cdb1_orcl2

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 01-MAR-2022 17:13:28

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = classroom.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb_cdb1_orcl2)))
OK (0 msec)
[oracle@classroom admin]$ sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 1 17:13:39 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

SQL> conn hr/cloud_4U@pdb_cdb1_orcl2
ERROR:
ORA-01109: database not open

SQL> conn / as sysdba
Connected.
SQL> alter pluggable database pdb_cdb1_orcl2 open;

SQL> conn sys/cloud_4U@pdb_cdb1_orcl2 as sysdba
????
SQL> select  count(*) from hr.tbig;

  COUNT(*)
--------------
   12402144


    说明relocate操作成功完成,并且维持了读一致
    /u01/app/oracle/diag/rdbms/cdb2/cdb2/trace

PDB_CDB1_ORCL2(9):Database Characterset for PDB_CDB1_ORCL2 is AL32UTF8
Violations: Type: 2, Count: 3
PDB_CDB1_ORCL2(9):***************************************************************
PDB_CDB1_ORCL2(9):WARNING: Pluggable Database PDB_CDB1_ORCL2 with pdb id - 9 is
PDB_CDB1_ORCL2(9):         altered with errors or warnings. Please look into
PDB_CDB1_ORCL2(9):         PDB_PLUG_IN_VIOLATIONS view for more details.
PDB_CDB1_ORCL2(9):***************************************************************
2022-03-23T04:57:39.453972+08:00
PDB_CDB1_ORCL2(9):Opening pdb with no Resource Manager plan active
2022-03-23T04:58:13.574552+08:00
PDB_CDB1_ORCL2(9):JIT: pid 2730472 requesting stop
PDB_CDB1_ORCL2(9):Buffer Cache flush started: 9
PDB_CDB1_ORCL2(9):Buffer Cache flush finished: 9
2022-03-23T04:59:01.746577+08:00
Applying media recovery for pdb-4099 from SCN 4424810 to SCN 4425130
Remote log information: count-1
thr-1, seq-30, logfile-+FRA/CDB1/partial_archivelog/2022_03_23/thread_1_seq_30.361.1100062733, los-4423838, nxs-18446744073709551615
PDB_CDB1_ORCL2(9):Media Recovery Start
2022-03-23T04:59:01.772925+08:00
PDB_CDB1_ORCL2(9):Serial Media Recovery started
PDB_CDB1_ORCL2(9):max_pdb is 9
2022-03-23T04:59:02.065248+08:00
PDB_CDB1_ORCL2(9):Media Recovery Log +FRA/CDB1/partial_archivelog/2022_03_23/thread_1_seq_30.361.1100062733
2022-03-23T04:59:04.656813+08:00
PDB_CDB1_ORCL2(9):Incomplete Recovery applied until change 4425130 time 03/23/2022 04:58:55
2022-03-23T04:59:04.708457+08:00
PDB_CDB1_ORCL2(9):Media Recovery Complete (cdb2)
PDB_CDB1_ORCL2(9):Undo initialization recovery: err:0 start: 459146681 end: 459146690 diff: 9 ms (0.0 seconds)
2022-03-23T04:59:05.914940+08:00
PDB_CDB1_ORCL2(9):[2730472] Successfully onlined Undo Tablespace 2.
PDB_CDB1_ORCL2(9):Undo initialization online undo segments: err:0 start: 459146691 end: 459147425 diff: 734 ms (0.7 seconds)
PDB_CDB1_ORCL2(9):Undo initialization finished serial:0 start:459146681 end:459147435 diff:754 ms (0.8 seconds)
PDB_CDB1_ORCL2(9):Database Characterset for PDB_CDB1_ORCL2 is AL32UTF8
PDB_CDB1_ORCL2(9):Buffer Cache flush started: 9
PDB_CDB1_ORCL2(9):Buffer Cache flush finished: 9
2022-03-23T04:59:08.395240+08:00
PDB_CDB1_ORCL2(9):Undo initialization recovery: err:0 start: 459149898 end: 459149904 diff: 6 ms (0.0 seconds)
PDB_CDB1_ORCL2(9):[2730472] Successfully onlined Undo Tablespace 2.
PDB_CDB1_ORCL2(9):Undo initialization online undo segments: err:0 start: 459149905 end: 459150077 diff: 172 ms (0.2 seconds)
PDB_CDB1_ORCL2(9):Undo initialization finished serial:0 start:459149898 end:459150080 diff:182 ms (0.2 seconds)
PDB_CDB1_ORCL2(9):Deleting old file#17 from file$ 
PDB_CDB1_ORCL2(9):Deleting old file#18 from file$ 
PDB_CDB1_ORCL2(9):Deleting old file#19 from file$ 
PDB_CDB1_ORCL2(9):Deleting old file#20 from file$ 
PDB_CDB1_ORCL2(9):Adding new file#41 to file$(old file#17).             fopr-1, newblks-116480, oldblks-64000
PDB_CDB1_ORCL2(9):Adding new file#42 to file$(old file#18).             fopr-1, newblks-185600, oldblks-51200
PDB_CDB1_ORCL2(9):Adding new file#43 to file$(old file#19).             fopr-1, newblks-70400, oldblks-3200
PDB_CDB1_ORCL2(9):Adding new file#44 to file$(old file#20).             fopr-1, newblks-640, oldblks-640
PDB_CDB1_ORCL2(9):Successfully created internal service PDB_CDB1_ORCL2 at open
****************************************************************
Post plug operations are now complete.
Pluggable database PDB_CDB1_ORCL2 with pdb id - 9 is now marked as NEW.
****************************************************************
PDB_CDB1_ORCL2(9):Pluggable database PDB_CDB1_ORCL2 dictionary check beginning
2022-03-23T04:59:09.475531+08:00
PDB_CDB1_ORCL2(9):Pluggable Database PDB_CDB1_ORCL2 Dictionary check complete
PDB_CDB1_ORCL2(9):Database Characterset for PDB_CDB1_ORCL2 is AL32UTF8
PDB_CDB1_ORCL2(9):JIT: pid 2730472 requesting full stop
2022-03-23T04:59:10.892665+08:00
Violations: Type: 2, Count: 5
PDB_CDB1_ORCL2(9):***************************************************************
PDB_CDB1_ORCL2(9):WARNING: Pluggable Database PDB_CDB1_ORCL2 with pdb id - 9 is
PDB_CDB1_ORCL2(9):         altered with errors or warnings. Please look into
PDB_CDB1_ORCL2(9):         PDB_PLUG_IN_VIOLATIONS view for more details.
PDB_CDB1_ORCL2(9):***************************************************************
PDB_CDB1_ORCL2(9):Opening pdb with no Resource Manager plan active
PDB_CDB1_ORCL2(9):joxcsys_required_dirobj_exists: directory object exists with required path /u01/app/oracle/product/19.3.0/dbhome_1/javavm/admin/, pid 2730472 cid 9
Pluggable database PDB_CDB1_ORCL2 opened read write
Completed: alter pluggable database pdb_cdb1_orcl2 open   

    在cdb1上查看 cdb2打开relocate的pdb_cdb1_orcl2后,AVAILABILITY MAX时,源头插件数据库得由用户自己删除;AVAILABILITY NORMAL时,源头插件数据库会被自动删除掉)
   
   cdb1上操作:
 
4. 跨根容器操作之——relocate插件数据库(使用dbca方法):

    在本实验中,将cdb1中的新建的pdb1_3 relocate到cdb2中:
    1)在cdb1中,创建c##remote这个common user,并授予create session权限和create pluggable database权限(在真实环境下创建pdb、在两个cdb之间迁移pdb以及创建proxy pdb的操作汇总系列4》中已创建
  
[oracle@classroom ~]$ . oraenv
ORACLE_SID = [cdb1] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@classroom ~]$ sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 11 16:08:03 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected.
SQL> create user c##remote identified by cloud_4U;

User created.

SQL> grant create session to c##remote;

Grant succeeded.

SQL> grant create pluggable database to c##remote container=all;

Grant succeeded.
   
    在源端需要一些特殊的权限(光光有dba不够),需要给sysoper的权限。请在cdb1上操作:

grant sysoper to c##remote  container=all;
 
    2)准备源头插件数据库:
    在cdb1上操作:

 create pluggable database pdb1_3  admin user pdb1_3_admin identified by clould_4U roles=(connect);
   
   3)relocate cdb1上的pdb1_3到cdb2
    relocate过程中自动发生的技术步骤大致有以下这些:
    a.  源端和目的地端CDB上记录和同步reloate操作的启动时刻SCN
    b.  从源端把pdb的数据文件、undo文件和redo日志文件通过数据库链接拷贝到目的地端
    c.  在目的地端pdb打开之前,源端pdb进行transaction所产生的redo都将传送到目的地端
    d.  当目的地端pdb打开那一刻, 源端pdb上的活跃连接会在txn边界处被终结,新的连接将被导向目的地端,并等待目的地端完成打开操作
    e.  当目的地端pdb打开那一刻, 存在前滚和回滚以保持relocate过程中的数据完整性 
    让cdb1中的pdb1_3处于高负载插入状态下,同时进行relocate操作:
   在cdb1pdb1_3操作

[oracle@classroom ~]$ . oraenv
ORACLE_SID = [cdb1] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@classroom ~]$ tnsping  pdb1_3

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 01-MAR-2022 16:02:56

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = classroom.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb1_3)))
OK (10 msec)
[oracle@classroom ~]$ sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 1 16:08:24 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

SQL> conn sys/cloud_4U@pdb1_3 as sysdba
Connected.
SQL> create user hr identified by cloud_4U account unlock;

User created.

SQL> alter user hr default tablespace users quota unlimited on users;

User altered.

SQL> grant resource to hr;

Grant succeeded.

SQL> grant create session to hr;

Grant succeeded.

    让pdb1_3处于高负载插入状态下,同时进行relocate:
    在pdb1_3

SQL> create table hr.tbig as select  * from dba_source;

Table created.

SQL> select  count(*) from hr.tbig;

  COUNT(*)
----------
   304875

注:在执行下面操作时(保证在commit前,插入过程中做relocate),同时在cdb2上操作(见下个代码框提示)!

SQL> insert into tbig select * from tbig;

304875 rows created.

SQL>  insert into tbig select * from tbig;

609750 rows created.

SQL> commit;

Commit complete.

SQL> select  count(*) from hr.tbig;

  COUNT(*)
--------------
     1219500

--此刻之后,relocate的目的地端的pdb1_3_relocate已经被dbca自动打开;由于dbca只能执行AVAILABILTY NORMAL,所以本插件数据库pdb1_3会被删除

SQL>insert into hr.tbig select  * from hr.tbig;
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 3463959
Session ID: 300 Serial number: 26506

 

    在上面代码框标注红字处,同时在cdb2上操作:在本实验中,将cdb1中的pdb1_3 relocate到cdb2中,叫做pdb1_3_relocate如果换个名字,比如pdb1_3_relocate,就无法实现relocate AVAILABILITY MAX,只能实现relocate AVAILABILITY NORMAL,而dbca不管改不改名字都只能进行relocate AVAILABILITY NORMAL
    先查看dbca -relocatePDB的帮助:


[oracle@classroom ~]$ . oraenv
ORACLE_SID = [cdb2] ?
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@classroom ~]$ dbca -silent -relocatePDB -remotePDBName pdb1_3 -remoteDBConnString cdb1 -sysDBAUserName sys -sysDBAPassword cloud_4U -remoteDBSYSDBAUserName sys -remoteDBSYSDBAUserPassword cloud_4U -dbLinkUsername c##remote -dbLinkUserPassword cloud_4U -sourceDB cdb2 -pdbName pdb1_3_relocate
Prepare for db operation
50% complete
Create pluggable database using relocate PDB operation
100% complete
Pluggable database "pdb1_3_relocate" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/pdb1_3_relocate/cdb2.log" for further details.
  
    以上的dbca命令中请特别注意“ -remoteDBConnString cdb1”的tns串大小写,这是一个bug:tns串是大写就在这里大写;小写就在这里小写。cdb2上relocate的pdb_cdb1_orcl2打开之前,cdb1上的pdb1_3状态正常,说明事务仍可以进行,将来这些事务会通过日志反映到relocate好的插件数据上(不管是AVAILABILITY NORMAL还是AVAILABILITY MAX
    在pdb1_3_relocate操作:

[oracle@classroom admin]$ tnsping pdb1_3_relocate

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 01-MAR-2022 17:13:28

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = classroom.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb1_3_relocate)))
OK (0 msec)
[oracle@classroom admin]$ sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 1 17:13:39 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

SQL> conn hr/cloud_4U@pdb1_3_relocate
Connected.
SQL> select  count(*) from hr.tbig;

  COUNT(*)
------------
  1219500


    说明relocate操作成功完成,并且维持了读一致
    /u01/app/oracle/diag/rdbms/cdb2/cdb2/trace

2022-03-25T03:41:08.039551+08:00
CREATE PLUGGABLE DATABASE pdb1_3_relocate FROM pdb1_3@pdb1_3_relocate_CLONE_LINK RELOCATE file_name_convert=NONE
2022-03-25T03:43:35.034602+08:00
PDB1_3_RELOCATE(8):Endian type of dictionary set to little
2022-03-25T03:43:36.981540+08:00
****************************************************************
Pluggable Database PDB1_3_RELOCATE with pdb id - 8 is created as UNUSABLE.
If any errors are encountered before the pdb is marked as NEW,
then the pdb must be dropped
local undo-1, localundoscn-0x000000000000011b
****************************************************************
2022-03-25T03:43:41.655980+08:00
Applying media recovery for pdb-4099 from SCN 5167970 to SCN 5168753
Remote log information: count-2
thr-1, seq-39, logfile-+FRA/CDB1/ARCHIVELOG/2022_03_25/thread_1_seq_39.293.1100230881, los-4652567, nxs-5168145
thr-1, seq-40, logfile-+FRA/CDB1/partial_archivelog/2022_03_25/thread_1_seq_40.292.1100231019, los-5168145, nxs-18446744073709551615
PDB1_3_RELOCATE(8):Media Recovery Start
2022-03-25T03:43:41.657785+08:00
PDB1_3_RELOCATE(8):Serial Media Recovery started
PDB1_3_RELOCATE(8):max_pdb is 11
2022-03-25T03:43:42.107763+08:00
PDB1_3_RELOCATE(8):Media Recovery Log +FRA/CDB1/ARCHIVELOG/2022_03_25/thread_1_seq_39.293.1100230881
2022-03-25T03:43:45.858285+08:00
PDB1_3_RELOCATE(8):Media Recovery Log +FRA/CDB1/partial_archivelog/2022_03_25/thread_1_seq_40.292.1100231019
2022-03-25T03:43:48.202161+08:00
PDB1_3_RELOCATE(8):Resize operation completed for file# 48, old size 4300800K, new size 4403200K
2022-03-25T03:43:49.745341+08:00
PDB1_3_RELOCATE(8):Resize operation completed for file# 48, old size 4403200K, new size 4505600K
PDB1_3_RELOCATE(8):Resize operation completed for file# 48, old size 4505600K, new size 4608000K
2022-03-25T03:43:55.209404+08:00
PDB1_3_RELOCATE(8):Incomplete Recovery applied until change 5168753 time 03/25/2022 03:43:37
2022-03-25T03:43:55.345325+08:00
PDB1_3_RELOCATE(8):Media Recovery Complete (cdb2)
2022-03-25T03:43:58.526866+08:00
Completed: CREATE PLUGGABLE DATABASE pdb1_3_relocate FROM pdb1_3@pdb1_3_relocate_CLONE_LINK RELOCATE file_name_convert=NONE
2022-03-25T03:43:59.674347+08:00
ALTER PLUGGABLE DATABASE pdb1_3_relocate OPEN
2022-03-25T03:44:06.848857+08:00
Applying media recovery for pdb-4099 from SCN 5168753 to SCN 5168775
Remote log information: count-1
thr-1, seq-40, logfile-+FRA/CDB1/partial_archivelog/2022_03_25/thread_1_seq_40.292.1100231045, los-5168145, nxs-18446744073709551615
PDB1_3_RELOCATE(8):Media Recovery Start
2022-03-25T03:44:06.877574+08:00
PDB1_3_RELOCATE(8):Serial Media Recovery started
PDB1_3_RELOCATE(8):max_pdb is 11
2022-03-25T03:44:07.167563+08:00
PDB1_3_RELOCATE(8):Media Recovery Log +FRA/CDB1/partial_archivelog/2022_03_25/thread_1_seq_40.292.1100231045
2022-03-25T03:44:08.596648+08:00
PDB1_3_RELOCATE(8):Incomplete Recovery applied until change 5168775 time 03/25/2022 03:44:00
2022-03-25T03:44:08.659133+08:00
PDB1_3_RELOCATE(8):Media Recovery Complete (cdb2)
PDB1_3_RELOCATE(8):Autotune of undo retention is turned on.
2022-03-25T03:44:09.837864+08:00
PDB1_3_RELOCATE(8):Undo initialization finished serial:0 start:42045495 end:42045495 diff:0 ms (0.0 seconds)
PDB1_3_RELOCATE(8):Database Characterset for PDB1_3_RELOCATE is AL32UTF8
Violations: Type: 2, Count: 10
PDB1_3_RELOCATE(8):***************************************************************
PDB1_3_RELOCATE(8):WARNING: Pluggable Database PDB1_3_RELOCATE with pdb id - 8 is
PDB1_3_RELOCATE(8):         altered with errors or warnings. Please look into
PDB1_3_RELOCATE(8):         PDB_PLUG_IN_VIOLATIONS view for more details.
PDB1_3_RELOCATE(8):***************************************************************
2022-03-25T03:44:10.971601+08:00
PDB1_3_RELOCATE(8):Opening pdb with no Resource Manager plan active
2022-03-25T03:44:17.395932+08:00
PDB1_3_RELOCATE(8):JIT: pid 142352 requesting stop
PDB1_3_RELOCATE(8):Buffer Cache flush started: 8
PDB1_3_RELOCATE(8):Buffer Cache flush finished: 8
2022-03-25T03:44:24.456126+08:00
Applying media recovery for pdb-4099 from SCN 5168775 to SCN 5168953
Remote log information: count-1
thr-1, seq-40, logfile-+FRA/CDB1/partial_archivelog/2022_03_25/thread_1_seq_40.292.1100231063, los-5168145, nxs-18446744073709551615
PDB1_3_RELOCATE(8):Media Recovery Start
2022-03-25T03:44:24.459541+08:00
PDB1_3_RELOCATE(8):Serial Media Recovery started
PDB1_3_RELOCATE(8):max_pdb is 11
2022-03-25T03:44:24.750452+08:00
PDB1_3_RELOCATE(8):Media Recovery Log +FRA/CDB1/partial_archivelog/2022_03_25/thread_1_seq_40.292.1100231063
2022-03-25T03:44:26.896671+08:00
PDB1_3_RELOCATE(8):Incomplete Recovery applied until change 5168953 time 03/25/2022 03:44:18
2022-03-25T03:44:26.955527+08:00
PDB1_3_RELOCATE(8):Media Recovery Complete (cdb2)
PDB1_3_RELOCATE(8):Undo initialization recovery: err:0 start: 42063247 end: 42063251 diff: 4 ms (0.0 seconds)
PDB1_3_RELOCATE(8):[142352] Successfully onlined Undo Tablespace 2.
PDB1_3_RELOCATE(8):Undo initialization online undo segments: err:0 start: 42063251 end: 42063433 diff: 182 ms (0.2 seconds)
PDB1_3_RELOCATE(8):Undo initialization finished serial:0 start:42063247 end:42063436 diff:189 ms (0.2 seconds)
PDB1_3_RELOCATE(8):Database Characterset for PDB1_3_RELOCATE is AL32UTF8
2022-03-25T03:44:27.927938+08:00
PDB1_3_RELOCATE(8):Buffer Cache flush started: 8
PDB1_3_RELOCATE(8):Buffer Cache flush finished: 8
2022-03-25T03:44:30.973899+08:00
PDB1_3_RELOCATE(8):Undo initialization recovery: err:0 start: 42066627 end: 42066631 diff: 4 ms (0.0 seconds)
PDB1_3_RELOCATE(8):[142352] Successfully onlined Undo Tablespace 2.
PDB1_3_RELOCATE(8):Undo initialization online undo segments: err:0 start: 42066631 end: 42066806 diff: 175 ms (0.2 seconds)
PDB1_3_RELOCATE(8):Undo initialization finished serial:0 start:42066627 end:42066808 diff:181 ms (0.2 seconds)
PDB1_3_RELOCATE(8):Deleting old file#25 from file$
PDB1_3_RELOCATE(8):Deleting old file#26 from file$
PDB1_3_RELOCATE(8):Deleting old file#27 from file$
PDB1_3_RELOCATE(8):Deleting old file#28 from file$
PDB1_3_RELOCATE(8):Adding new file#45 to file$(old file#25).             fopr-1, newblks-30720, oldblks-30720
PDB1_3_RELOCATE(8):Adding new file#46 to file$(old file#26).             fopr-1, newblks-26880, oldblks-26880
PDB1_3_RELOCATE(8):Adding new file#47 to file$(old file#27).             fopr-1, newblks-26880, oldblks-1280
PDB1_3_RELOCATE(8):Adding new file#48 to file$(old file#28).             fopr-1, newblks-576000, oldblks-12800
PDB1_3_RELOCATE(8):Successfully created internal service PDB1_3_RELOCATE at open
****************************************************************
Post plug operations are now complete.
Pluggable database PDB1_3_RELOCATE with pdb id - 8 is now marked as NEW.
****************************************************************
PDB1_3_RELOCATE(8):Pluggable database PDB1_3_RELOCATE dictionary check beginning
PDB1_3_RELOCATE(8):Pluggable Database PDB1_3_RELOCATE Dictionary check complete
PDB1_3_RELOCATE(8):Database Characterset for PDB1_3_RELOCATE is AL32UTF8
2022-03-25T03:44:32.291919+08:00
PDB1_3_RELOCATE(8):JIT: pid 142352 requesting full stop
Violations: Type: 2, Count: 12
PDB1_3_RELOCATE(8):***************************************************************
PDB1_3_RELOCATE(8):WARNING: Pluggable Database PDB1_3_RELOCATE with pdb id - 8 is
PDB1_3_RELOCATE(8):         altered with errors or warnings. Please look into
PDB1_3_RELOCATE(8):         PDB_PLUG_IN_VIOLATIONS view for more details.
PDB1_3_RELOCATE(8):***************************************************************
2022-03-25T03:44:33.714692+08:00
PDB1_3_RELOCATE(8):Opening pdb with no Resource Manager plan active
PDB1_3_RELOCATE(8):joxcsys_required_dirobj_exists: directory object exists with required path /u01/app/oracle/product/19.3.0/dbhome_1/javavm/admin/, pid 142352 cid 8
Pluggable database PDB1_3_RELOCATE opened read write
Completed: ALTER PLUGGABLE DATABASE pdb1_3_relocate OPEN

    在cdb1上查看 cdb2打开relocate的pdb1_3_relocate后,AVAILABILITY NORMAL时,源头插件数据库会被自动删除掉
   
5. 跨根容器操作之——proxy插件数据库:

    在本实验中,将为cdb2中的pdb2_1cdb1中生成它的proxy插件数据库pdb2_1_proxy
    1)在cdb1做连接到对方system用户的数据库链接:
    在cdb1上操作:

SQL>select  * from dba_db_links;
-----------------------------------------------
SYS    SYS_HUB        SEEDDATA    17-APR-19    NO    NO    YES    NO

SQL> create public database link link_cdb2 connect to system identified by cloud_4U using 'cdb2';
Database link created.
SQL> select  count(*) from dba_source@link_cdb2;

  COUNT(*)
------------
    291100

SQL>
select  * from dba_db_links;
-----------------------------------------------
SYS    SYS_HUB        SEEDDATA    17-APR-19    NO    NO    YES    NO
PUBLIC    LINK_CDB2    SYSTEM    cdb2    15-MAR-22    NO    NO    YES    NO
  
    2)创建proxy插件数据库:
    在cdb1上操作:

 
    3)验证proxy插件数据库的同步操作:
    在pdb2_1上操作:

[oracle@classroom ~]$ sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 18 22:08:30 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
SQL> conn hr/cloud_4U@pdb2_1
Connected.
SQL> select  count(*) from tbig;
 COUNT(*)
-------------
     411096
 
   pdb2_1_proxy上操作:

[oracle@classroom ~]$ sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 18 22:08:50 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
SQL> conn hr/cloud_4U@pdb2_1_proxy
Connected.
SQL> select  count(*) from tbig;
 COUNT(*)
------------
    411096
    
    pdb2_1_proxy上操作:

SQL> insert into tbig select  * from tbig;
411096 rows created.
SQL> commit;
SQL> select  count(*) from tbig;
COUNT(*)
-----------
    822192
     
     在pdb2_1上验证:

[oracle@classroom ~]$ sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 18 22:08:30 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
SQL> conn hr/cloud_4U@pdb2_1
Connected.
SQL> select  count(*) from tbig;
 COUNT(*)
------------
     822192

路过

雷人

握手

鲜花

鸡蛋

QQ|手机版|Bo's Oracle Station   

GMT+8, 2022-3-24 20:13 , Processed in 0.049247 second(s), 21 queries .

返回顶部