oracle 12c 學習之三 pdb 的可拔插測試,12cpdb

來源:互聯網
上載者:User

oracle 12c 學習之三 pdb 的可拔插測試,12cpdb

DECLAREl_result BOOLEAN;BEGINl_result := DBMS_PDB.check_plug_compatibility(pdb_descr_file => '/u02/pdb/pdb3.xml',pdb_name       => 'pdb3');IF l_result THENDBMS_OUTPUT.PUT_LINE('compatible');ELSEDBMS_OUTPUT.PUT_LINE('incompatible');END IF;END;/1、當前庫的可拔插測試21:06:51 sys@stldb> alter pluggable database prod unplug into '/u02/pdb/prod.xml'; Pluggable database altered. Elapsed: 00:00:04.88 21:07:48 sys@stldb> drop pluggable database prod; Pluggable database dropped. Elapsed: 00:00:04.46 21:09:35 sys@stldb> select con_id, dbid, guid, name , open_mode from v$pdbs; CON_ID DBID GUID NAME OPEN_MODE ------------- ------------- -------------------------------- ------------------------------ ---------- 2 4117202806 117BCA51FD151564E0536506A8C0D708 PDB$SEED READ ONLY 3 3382304421 117C1A2739A394A2E0536506A8C0E86A PDB1 READ WRITE 4 3940876746 117C20359794C040E0536506A8C0B458 PDB2 READ WRITE 6 3885367953 118F19327FCC760FE0536506A8C05BDF PDB4 READ ONLY Elapsed: 00:00:00.01 21:09:50 sys@stldb> DECLARE 21:12:41 2 l_result BOOLEAN; 21:12:42 3 BEGIN 21:12:42 4 l_result := DBMS_PDB.check_plug_compatibility( 21:12:42 5 pdb_descr_file => '/u02/pdb/prod.xml', 21:12:42 6 pdb_name => 'prod'); 21:12:42 7 IF l_result THEN 21:12:42 8 DBMS_OUTPUT.PUT_LINE('compatible'); 21:12:42 9 ELSE 21:12:42 10 DBMS_OUTPUT.PUT_LINE('incompatible'); 21:12:42 11 END IF; 21:12:42 12 END; 21:12:42 13 / compatible PL/SQL procedure successfully completed. Elapsed: 00:00:00.10 21:12:43 sys@stldb> create pluggable database prod using '/u02/pdb/prod.xml' nocopy tempfile reuse;當然,我們在這一步還是可以進行改名的不一定使用原來的名字21:14:17 sys@stldb> alter session set container=prod; Session altered. Elapsed: 00:00:00.09 21:14:37 sys@stldb> select name from v$datafile; NAME ---------------------------------------------------------------------------------------------------------------------------------- +DATA/STLDB/DATAFILE/undotbs1.261.874613095 +DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/system.294.874633201 +DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/sysaux.293.874633187 +DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/users.296.874633293 +DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/kiwi.339.874702947 Elapsed: 00:00:00.08 21:14:45 sys@stldb> select name from v$tempfile; NAME ---------------------------------------------------------------------------------------------------------------------------------- +DATA/STLDB/118073E7A685F068E0536506A8C0A25E/TEMPFILE/temp.295.8747036272 跨庫的可拔插測試21:48:28 sys@stldb> alter pluggable database pdb3 close; Pluggable database altered. Elapsed: 00:00:03.97 21:48:53 sys@stldb> alter pluggable database pdb3 unplug into '/u02/pdb/pdb3.xml'; Pluggable database altered. Elapsed: 00:00:05.15 21:49:34 sys@stldb> quit Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options [21:50:07 oracle(db)@rac1 ~]$ rman target / Recovery Manager: Release 12.1.0.1.0 - Production on Wed Mar 18 21:50:11 2015 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. connected to target database: STLDB (DBID=3188959514) RMAN> BACKUP FOR TRANSPORT AS COMPRESSED BACKUPSET PLUGGABLE DATABASE 'PDB3' FORMAT '/u02/pdb/pdb3.dfb'; Starting backup at 18-MAR-15 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=258 instance=stldb1 device type=DISK channel ORA_DISK_1: starting compressed full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00049 name=+DATA/pdb3/pdb3_sysaux01.dbf input datafile file number=00048 name=+DATA/pdb3/pdb3_system01.dbf input datafile file number=00051 name=+DATA/pdb3/pdb3_kiwi01.dbf input datafile file number=00050 name=+DATA/pdb3/pdb3_users01.dbf channel ORA_DISK_1: starting piece 1 at 18-MAR-15 channel ORA_DISK_1: finished piece 1 at 18-MAR-15 piece handle=/u02/pdb/pdb3.dfb tag=TAG20150318T215139 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15 Finished backup at 18-MAR-15 然後在另外的庫上轉儲進行恢複這個資料庫RMAN> run2> {3> set command id  to 'pdb3';4> RESTORE FOREIGN DATAFILE  48 TO NEW ,49 TO NEW ,50 TO NEW,51 TO NEW  FROM BACKUPSET  5> '/u02/pdb/pdb3.dfb' ;6>  };executing command: SET COMMAND IDStarting restore at 19-MAR-15using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=142 instance=prod1 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring foreign file 00048channel ORA_DISK_1: restoring foreign file 00049channel ORA_DISK_1: restoring foreign file 00050channel ORA_DISK_1: restoring foreign file 00051channel ORA_DISK_1: reading from backup piece /u02/pdb/pdb3.dfbchannel ORA_DISK_1: restoring foreign file 48 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/system.351.874714735channel ORA_DISK_1: restoring foreign file 49 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/sysaux.350.874714735channel ORA_DISK_1: restoring foreign file 50 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/users.353.874714735channel ORA_DISK_1: restoring foreign file 51 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/kiwi.352.874714735channel ORA_DISK_1: foreign piece handle=/u02/pdb/pdb3.dfbchannel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:01:06Finished restore at 19-MAR-15建立pdbcreate pluggable database pdb3 as clone  using '/u02/pdb/pdb3.xml'     source_file_name_convert = ( '+DATA/pdb3/pdb3_system01.dbf','+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/system.351.874714735', '+DATA/pdb3/pdb3_sysaux01.dbf','+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/sysaux.350.874714735','+DATA/pdb3/pdb3_users01.dbf','+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/users.353.874714735','+DATA/pdb3/pdb3_temp01.dbf','+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/temp01.dbf','+DATA/pdb3/pdb3_kiwi01.dbf','+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/kiwi.352.874714735')file_name_convert=NONE  NOCOPY;00:45:17 sys@prod> select con_id, dbid, guid, name , open_mode from v$pdbs; CON_ID DBID GUID NAME OPEN_MODE ------------- ------------- -------------------------------- ------------------------------ ---------- 2 4117299261 11900B6E18D984BAE0536506A8C0B9FE PDB$SEED READ ONLY 3 3990814677 1193C11BCCBCAD60E0536506A8C0ABA9 PDB3 MOUNTED Elapsed: 00:00:00.01 00:46:04 sys@prod> alter pluggable database pdb3 open; Pluggable database altered. Elapsed: 00:00:20.39 00:46:35 sys@prod> alter session set container=pdb3 00:46:55 2 ; Session altered. Elapsed: 00:00:00.11 00:46:56 sys@prod> select name from v$tablespace; NAME ------------------------------ UNDOTBS1 SYSTEM SYSAUX TEMP USERS KIWI 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.