Cross-Platform Data Transport in CDBs and PDBs

You can transport a whole multitenant container database (CDB), the root only, or one or more pluggable databases (PDBs) across platforms. The cross-platform transport can be performed using images copies or backup sets.

About Cross-Platform Transport of PDBs

To transport an entire PDB to a different platform, the source platform and destination platform must use the same endian format. The COMPATIBLE parameter on the source and destination CDB must be set to 12.1 or higher.

Use one of the following techniques to transport PDBs across platforms:

  1. Connect to the root and use the BACKUP FOR TRANSPORT ... PLUGGABLE DATABASE or BACKUP TO PLATFORM ... PLUGGABLE DATABASE command to create a cross-platform backup of one or more PDBs. The PDBs must be read-only mode before the cross-platform backup is created.

BACKUP FOR TRANSPORT

PLUGGABLE DATABASE hr_pdb, sales_pdb FORMAT '/tmp/backups/pdb_%U';

  1. Connect to the PDB and use the BACKUP FOR TRANSPORT or BACKUP TO PLATFORM commands to create backup sets that can be used to transport the PDB data to another platform.

Note: Performing cross-platform data transport of one or more PDBs by using the CONVERT command is not supported.

Performing Cross-Platform Transport of a Whole CDB

In a CDB, the steps to transport data across platforms are similar to the ones used for non-CDBs. The only difference is that, on both the source and destination databases, you must connect to the root as a common user with the common SYSBACKUP or SYSDBA privilege.

To transport an entire CDB, the source platform and the destination platform must use the same endian format.

The BACKUP FOR TRANSPORT or BACKUP TO PLATFORM command creates a cross-platform backup of the whole CDB. The CONVERT command creates image copies of the CDB that can be transported to a different platform.

The following command, when connected to the root, creates a cross-platform backup of the whole CDB:

BACKUP

TO PLATFORM 'Linux x86 64-bit'

DATABASE FORMAT '/tmp/backups/cdb_%U;

While restoring the cross-platform backup on the destination database, the RESTORE DATABASE command restores the whole CDB.

Performing Cross-Platform Transport of a Closed PDB

Pluggable database (PDBs) can be transported and plugged in to a destination multitenant container database (CDB) which is on a different platform than the source CDB. In addition to an RMAN backup of the PDB, you need the metadata required to plug the PDB into the destination CDB.

The COMPATIBLE parameter on the source CDB and destination CDB must be set to 12.2. The source CDB and the destination CDB must use the same endian format.

To perform cross-platform transport of a closed PDB into a destination CDB:

  1. Perform the following steps on the source CDB:
  1. Connect to the root as a common user with the SYSDBA or SYSBACKUP privilege.
  2. Close the PDB that needs to be transported.

RMAN> ALTER PLUGGABLE DATABASE hr_pdb CLOSE IMMEDIATE;

  1. Create a cross-platform full backup of the PDB that must be transported by using the BACKUP PLUGGABLE DATABASE command. To create a cross-platform backup, include either the FOR TRANSPORT or TO PLATFORM clause.

BACKUP TO PLATFORM= 'Linux x86 64-bit'

   UNPLUG INTO '/u01/oradata/backups/metadata_hrpdb.xml'

   PLUGGABLE DATABASE hr_pdb

   FORMAT '/u01/oradata/backups/transport_hrpdb.bck';

  1. Transport the backup sets and the XML file created in Step 1c to the destination CDB.
  2. Perform the following steps on the destination CDB:
  1. Connect to the root as a common user with the SYSDBA or SYSBACKUP privilege.
  2. Ensure that the CDB is open in read-write mode.

The following command displays the current mode of the CDB.

RMAN> SELECT open_mode FROM V$DATABASE;

  1. Determine if the source PDB that is being transported is compatible with the destination CDB by using the DBMS_PDB.CHECK_PLUG_COMPATIBILITY procedure.

SQL> declare

  2     c boolean;

  3  begin

  4     c:=dbms_pdb.check_plug_compatibility('/u02/backup_restore/metadata_hrpdb.xml','HR_PDB');

  5     if (c) then dbms_output.put_line('True');

  6       else dbms_output.put_line('False');

  7     end if;

  8  end;

  9  /

PL/SQL procedure successfully completed.

  1. Restore the PDB backup that was created on the source CDB.

The USING clause specifies the name of the XML file that contains the metadata required to plug the source PDB into the destination CDB. To copy data files to a different location than described in the XML file, use the FILE_NAME_CONVERT clause.

RESTORE        

   USING '/u02/backup_restore/metadata_hrpdb.xml'

   FOREIGN PLUGGABLE DATABASE hr_pdb FORMAT '/u02/oracle/oradata/%U'       

   FROM BACKUPSET '/u02/backup_restore/transport_hrpdb.bck';

  1. Open the restored PDB.

RMAN> ALTER PLUGGABLE DATABASE hr_pdb OPEN;

Note: If a PDB with the same name as the one being transported exists on the destination database, then the restore operation fails.

Performing Cross-Platform Transport of a PDB Using Inconsistent Backups

You can use a combination of inconsistent and consistent backups to transport a PDB and plug it into a CDB that is on a different platform. Inconsistent backups enable you to reduce application downtime because the PDB can be open while the backup is performed

When the PDB is open, you create cross-platform inconsistent backups. The first backup is an incremental level 0 backup. Subsequent backups are incremental level 1 backups that contain changes made to the PDB since the last incremental backup. There is no restriction on the number of inconsistent level 1 backups. Finally, close the PDB, create the last consistent incremental level 1 backup and the XML file containing the metadata required to plug the source PDB into a destination CDB.

The COMPATIBLE parameter on the source CDB and destination CDB must be set to 12.2. The source CDB and the destination CDB must use the same endian format.

  1. Perform the following steps on the source CDB:
  1. Connect to the root as a common user with the SYSDBA or SYSBACKUP privilege.
  2. Ensure that the PDB that must be transported is in read-write mode.
  3. Note the database SCN before a level 0 backup is created.

SELECT CHECKPOINT_CHANGE# FROM V$DATABASE;

  1. Create a cross-platform incremental level 0 backup of the PDB that must be transported by using the BACKUP ... PLUGGABLE DATABASE command.

Use either the FOR TRANSPORT or TO PLATFORM clause to specify a cross-platform backup. Include the ALLOW INCONSISTENT clause to indicate that the PDB is not in a consistent state.

BACKUP INCREMENTAL LEVEL 0

   FOR TRANSPORT  

   ALLOW INCONSISTENT

   PLUGGABLE DATABASE hr_pdb FORMAT '/u01/backups/hr_pdb_level0.bck';

Because the PDB is in read-write mode, an inconsistent backup is created.

  1. Close the PDB being transported.

RMAN> ALTER PLUGGABLE DATABASE hr_pdb CLOSE IMMEDIATE;

  1. Create a consistent cross-platform incremental backup. The point-in-time for the incremental backup must be from the SCN noted in Step 1c.

Include the UNPLUG INTO clause to specify the name of the XML that stores the metadata required to plug this PDB into the destination CDB.

BACKUP INCREMENTAL FROM SCN 36462

   FOR TRANSPORT

   UNPLUG INTO '/u01/backups/metadata_hr_pdb.xml'

   PLUGGABLE DATABASE hr_pdb FORMAT '/u01/backups/hr_pdb_level1_con.bck';

  1. Transport all the PDB backups and the XML file containing the PDB metadata to the destination database.

Note: Typically, you would transport the inconsistent backups as they are created and then restore them on the destination CDB.

  1. Perform the following steps on the destination CDB:
  1. Connect to the root as a common user with the SYSDBA or SYSBACKUP privilege.
  2. Ensure that the destination CDB is open in read-write mode.
  3. Restore the cross-platform inconsistent level 0 backup of the PDB that was created on the source CDB.

RESTORE

   FOREIGN PLUGGABLE DATABASE hr_pdb FORMAT '/u02/oradata/%U'

   FROM BACKUPSET '/u02/backup_restore/hr_pdb_level0.bck';

  1. Apply the cross-platform level 1 incremental backup created when the source PDB was closed to the data files restored in Step 3c. Use the XML file containing the source PDB metadata to plug the PDB into the destination CDB.

RECOVER

USING '/u02/backup_restore/metadata_hr_pdb.xml'

FOREIGN DATAFILECOPY '/u2/oradata/09qurbdp_1_1','/u2/oradata/03bcdqrv_2_5'

FROM BACKUPSET '/u02/backup_restore/hr_pdb_level1_con.bck';

  1. Determine the name of the transported PDB in the destination CDB.

The source PDB is plugged in to the destination using a different name. Typically, the name is the unique name of the CDB followed by a randomly-generated number.

SELECT name FROM V$PDBS;

  1. Open the recovered PDB.

RMAN> ALTER PLUGGABLE DATABASE mycdb_72346 OPEN;

Note: If a PDB with the same name as the one being transported exists on the destination database, then the restore operation fails.

Performing Cross-Platform Transport of Tablespaces in a PDB

RMAN enables you to transport user tablespaces contained in a PDB to a different platform by using either the CONVERT or BACKUP command. In this case, the source platform and the destination platform can use different endian formats.

Use one of the following techniques to transport a tablespace in a PDB:

  1. Connect to the PDB as TARGET and use the BACKUP TABLESPACE command to create a cross-platform backup of the selected tablespaces.
  2. Connect to the PDB as TARGET and use the CONVERT TABLESPACE command to transport a read-only tablespace.

The following command, when connected to the PDB, converts the read-only tablespace my_tbs:

CONVERT TABLESPACE my_tbs

    TO PLATFORM 'Solaris[tm] OE (64-bit)'

    FORMAT '/tmp/xplat_backups/my_tbs_%U.bck';

  1. Connect to the PDB as TARGET and use the CONVERT DATAFILE command.

CONVERT

    FROM PLATFORM 'Solaris[tm] OE (64-bit)'

    DATAFILE '/u01/app/oracle/oradata/orcl/sales.df'

    FORMAT '/tmp/xplat_backups/sales_df_solaris.dat'

However, when connected as TARGET to a PDB, you cannot use the CONVERT DATAFILE command to convert a tablespace that contains undo segments.

  1. Example: Transporting a Tablespace in a PDB

This example used the CONVERT command to transport the tablespace sales_tbs from the PDB pdb5 to the destination PDB pdb3. The source PDB is on a Sun Solaris platform and the destination PDB is on a Linux x86 64-bit platform.

  1. Ensure that the required prerequisites are met.
  2. Start SQL*Plus and connect to the source PDB as a user who is granted the SYSDBA or SYSBACKUP privilege.

% sqlplus sbu@pdb5 AS SYSBACKUP

  1. Query the name for the destination platform in the V$TRANSPORTABLE_PLATFORM view.
  2. Verify that the tablespace that is to be transported is self-contained.
  3. Place the tablespace to be transported in read-only mode.

SQL> ALTER TABLESPACE sales_tbs READ ONLY;

  1. Create the directory object that is used to store the files generated by the DataPump export and import utilities.

SQL> CREATE OR REPLACE DIRECTORY xtt_dir AS '/scratch/xtt';

  1. Start RMAN and connect to the source PDB as a user with the SYSDBA or SYSBACKUP privilege.

% rman

RMAN> CONNECT TARGET "sbu@pdb5 as sysbackup"

  1. Convert the tablespace on the source database using the CONVERT command.

The following command converts the tablespace sales_tbs to the destination platform Linux x86-64 bit. The converted data files are stored in /tmp/xplat_convert/sales_tbs_conv.bck.

RMAN> CONVERT TABLESPACE 'SALES_TBS'

TO PLATFORM 'Linux x86 64-bit'

FORMAT  '/tmp/xplat_convert/sales_tbs_conv.bck';

  1. Exit RMAN.
  2. On the source database, use the DataPump export utility to create an export dump file containing the metadata for tablespace sales_tbs. Use the credentials of the SYS user to perform the export.

# expdp "'"sys@pdb5 as sysdba"'" directory=xtt_dir dumpfile=sales_tbs_conv.dmp logfile=sales_tbs_conv.log transport_tablespaces=sales_tbs

  1. Copy the converted data files created in Step 8 and the export dump file created in Step 10 to the destination PDB. You can use operating system commands to copy the files.
  2. On the destination PDB, plug the tablespace into the PDB by using the DataPump import utility. Use the credentials of the SYS user to perform the import.

#impdp "'"sys@pdb3 as sysdba"'" directory=xtt_dir dumpfile=sales_tbs_conv.dmp datafiles=/tmp/xplat_convert/sales_tbs_conv.bck

  1. Start SQL*Plus and connect to the destination PDB as a user with the SYSDBA or SYSBACKUP privilege.

%sqlplus sbu@pdb3 as sysbackup

  1. Verify the status of the converted tablespace on the destination PDB.

SQL> SELECT status FROM dba_tablespaces

     WHERE tablespace_name LIKE 'SALES_TBS';

STATUS

---------

READ ONLY

  1. Make the tablespace sales_tbs in the destination PDB pdb3 online.

SQL> ALTER TABLESPACE sales_tbs READ WRITE;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值