Using RMAN in CDB or PDB

本文详细介绍了如何使用RMAN(恢复管理器)对Oracle数据库的CDB(容器数据库)和PDB(可插拔数据库)进行备份。包括通过连接到CDB$ROOT备份整个CDB、只备份根、单独备份PDB以及备份应用容器。同时,指出了直接连接到PDB备份的限制,如不能备份归档日志和执行某些恢复操作。此外,还涵盖了表空间和数据文件的备份方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • Connecting as Target to a CDB/PDB
  1. 连接CDB$ROOT可以备份root、其下单个或多个PDB以及整个CDB, 如

BACKUP PLUGGABLE DATABASE sales, hr;

There are three most comon ways to connect as target to the root:

  1. Connecting locally as a common user:

$ rman target sys

  1. Connecting with operating system authentication:

$ rman target /

  1. Connecting as a common user through Oracle Net Services, using a net service name:

$ rman target c##bkuser@sales

  1. 连接PDB备份与一般Non-CDB备份命令相同,但有诸多限制并且不能使用catalog

Certain restrictions apply when you connect directly to a pluggable database (PDB):

The following operations are not available when you connect as target directly to a PDB:

  1. Back up archived logs
  2. Delete archived logs
  3. Delete archived log backups
  4. Restore archived logs (RMAN does restore archived logs when required during media recovery.)
  5. Point-in-time recovery (PITR) when using shared undo mode
  6. TSPITR
  7. Table recovery
  8. Duplicate database
  9. Flashback operations when using shared undo mode
  10. Running Data Recovery Advisor
  11. Report/delete obsolete
  12. Register database
  13. Import catalog
  14. Reset database
  15. Configuring the RMAN environment (using the CONFIGURE command)

Note: When you connect as TARGET to a PDB, you cannot connect to a recovery catalog.

直连PDB示例:

$ rman target hrbkup@hrpdb   (此用户可以common user也可是pdb自已用户)

  • Backing Up CDBs and PDBs
  1. Backing Up a Whole CDB

The BACKUP command is used to back up CDBs. You can then recover either the whole CDB, the root only, or one or more PDBs from the CDB backup. To backup up a whole CDB:

  1. Start RMAN and connect to the root as a common user with the SYSBACKUP or SYSDBA privilege and to a recovery catalog (if used)
  2. Ensure that the database is mounted or open.
  3. Issue the BACKUP DATABASE command at the RMAN prompt.

BACKUP DATABASE PLUS ARCHIVELOG;

Note: Proxy PDBs are not backed up while backing up a CDB.

  1. Backing Up the Root with RMAN

You can use RMAN to make a backup of only the root. Because the root contains critical metadata for the whole CDB, Oracle recommends that you back up the root or back up the whole CDB at regular intervals.

To back up the root with RMAN:

  1. Start RMAN and connect to the root as a common user with the SYSBACKUP or SYSDBA privilege.
  2. Enter the following command:

BACKUP DATABASE ROOT;

  1. Backing Up PDBs with RMAN

RMAN enables you to back up one or more PDBs in a CDB using the BACKUP command.

备份PDB可通过CDB$root或直连PDB备份,前者备份会有root及对应备份的PDB可见,而后者所有pdb的root均可见

There are two approaches to backing up a PDB with RMAN:

  1. Connect to the root and then use the BACKUP PLUGGABLE DATABASE command. This approach enables you to back up multiple PDBs with a single command.

When you connect to the root and back up a PDB, this backup is visible to the root and to that particular PDB but not to the other PDBs.

  1. Connect to the PDB and use the BACKUP DATABASE command. This approach backs up only a single PDB and enables you to use the same commands used for backing up non-CDBs.

Backups created when connected to any PDB are visible when connected to the root.

直连PDB的备份方式无法备份归档日志

When you back up individual PDBs, the archived redo logs are not backed up.

  1. To back up one or more PDBs while connected to the root:

Start RMAN and connect to the root as a common user with the SYSBACKUP or SYSDBA privilege.

Issue a BACKUP PLUGGABLE DATABASE command at the RMAN prompt.

BACKUP PLUGGABLE DATABASE sales, hr;

  1. To back up one PDB while connected to the PDB:

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

Issue a BACKUP DATABASE command at the RMAN prompt.

BACKUP DATABASE;

Note: Backing up a proxy PDB using RMAN is not supported.

  1. Backing Up Tablespaces and Data Files in a PDB

备份PDB的表空间与数据文件略有不同,因为表空间可能重名但数据文件号不会,表空间只能直接PDB备份,数据文件则可以在CDB$root中备份

Because tablespaces in different PDBs can have the same name, to eliminate ambiguity you must connect directly to a PDB to back up one or more of its tablespaces.

Ensure that the CDB is open or mounted. Tablespaces can be read-only or read-write.

In contrast, because data file numbers and paths are unique across the CDB, you can connect to either the root or a PDB to back up PDB data files. If you connect to the root, you can back up data files from multiple PDBs with a single command. If you connect to a PDB, you can back up only data files in that PDB.

To back up tablespaces in a PDB:

  1. Start RMAN and connect to the PDB as a local user with the SYSBACKUP or SYSDBA privilege.
  2. Issue a BACKUP TABLESPACE command.

BACKUP TABLESPACE users, examples;

To back up data files in a PDB:

  1. Do one of the following:

Start RMAN and connect to the root as a common user with the SYSBACKUP or SYSDBA privilege.

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

  1. Issue a BACKUP DATAFILE command.

BACKUP DATAFILE 10, 13;

  1. Backing Up Application Containers

RMAN enables you to use the BACKUP command to perform backup operations on the application root, one or more application PDBs, and the application container.

  1. Backing Up the Application Root

类似备份CDB$root

Use one of the following approaches to back up the application root:

  1. Connect to the application root and use the BACKUP DATABASE ROOT command

Start RMAN and connect to the application root as an application common user with the SYSDBA or SYSBACKUP privilege.

The application root has its own service name and you can connect to the application root in the same way that you connect to a PDB.

BACKUP DATABASE ROOT;

  1. Connect to the CDB root and use the BACKUP PLUGGABLE DATABASE command

Start RMAN and connect to the CDB root as a common user with the SYSDBA or SYSBACKUP privilege.

Use the BACKUP PLUGGABLE DATABASE command to back up the application root.

BACKUP PLUGGABLE DATABASE hr_appcont;

  1. Backing Up the Application Root and its Application PDBs

类似备份whole CDB

Start RMAN and connect to the application root as an application common user with the SYSDBA or SYSBACKUP privilege.

The application root has its own service name and you can connect to the application root in the same way that you connect to a PDB.

BACKUP DATABASE;

  1. Backing Up Application PDBs

Connect to the application root as an application common user with the SYSDBA or SYSBACKUP privilege.

The application root has its own service name and you can connect to the application root in the same way that you connect to a PDB.

Connect to the CDB root as a common user with the SYSDBA or SYSBACKUP privilege.

Use the BACKUP PLUGGABLE DATABASE command to back up the application PDB. To back up multiple application PDBs, use a comma-separated list of application PDB names.

BACKUP PLUGGABLE DATABASE hr_app_pdb;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值