Oracle 12c 多租户 CDB 与 PDB 备份

一、  CDB 备份

1.1  只备份CDB

只备份CDB数据库需要具有SYSDBA或SYSBACKUP权限用户连接到CDB的root环境下,执行backupdatabase root命令即可完成对CDB的备份,方法如下:
[[email protected] ~]$ rman target / 
[[email protected] ~]$ mkdir /home/oracle/rmanback/
RMAN> backup database root format=‘/home/oracle/rmanback/db_%d_%U‘; 
RMAN-03002: failure of backup command at 05/10/2017 23:14:58
RMAN-06817: Pluggable Database CDB$ROOT cannot be backed up in NOARCHIVELOG mode.
说明: 只备份 CDB 需要数据库在归档环境下,自行把数据设置为归档模式。
RMAN> select name,log_mode from v$database;
NAME      LOG_MODE    
--------- ------------
ANDYCDB   ARCHIVELOG  
RMAN> backup database root format=‘/home/oracle/rmanback/db_%d_%U‘;

Starting backup at 10-MAY-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_system_djsytx31_.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_sysaux_djsyx1t8_.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_undotbs1_djsyyjlk_.dbf
input datafile file number=00007 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_users_djsyykpc_.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAY-17
channel ORA_DISK_1: finished piece 1 at 10-MAY-17
piece handle=/home/oracle/rmanback/db_ANDYCDB_07s3u63n_1_1 tag=TAG20170510T233207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 10-MAY-17

Starting Control File and SPFILE Autobackup at 10-MAY-17
piece handle=/home/oracle/fast_recovery_area/ANDYCDB/autobackup/2017_05_10/o1_mf_s_943659193_dk6dosvv_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 10-MAY-17

1.2.  备份整个CDB及其下面的所有PDB
备份整个CDB数据库及其下面的所有PDB类似于非CDB数据库方法相同,使用具有SYSDBA或SYSBACKUP权限用户连接到CDB的root环境下面,然后执行backupdatabase命令即可完成整个CDB的备份,方法如下: 
RMAN> backup database format=‘/home/oracle/rmanback/db_%d_%U‘;

Starting backup at 10-MAY-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_system_djsytx31_.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_sysaux_djsyx1t8_.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_undotbs1_djsyyjlk_.dbf
input datafile file number=00007 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_users_djsyykpc_.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAY-17
channel ORA_DISK_1: finished piece 1 at 10-MAY-17
piece handle=/home/oracle/rmanback/db_ANDYCDB_09s3u69m_1_1 tag=TAG20170510T233517 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:17
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00022 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_sysaux_dk5wmv11_.dbf
input datafile file number=00021 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_system_dk5wmv0s_.dbf
input datafile file number=00024 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_undo_1_dk5wmv13_.dbf
input datafile file number=00023 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_users_dk5wmv12_.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAY-17
channel ORA_DISK_1: finished piece 1 at 10-MAY-17
piece handle=/home/oracle/rmanback/db_ANDYCDB_0as3u6c3_1_1 tag=TAG20170510T233517 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:39
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_sysaux_djsz1z2x_.dbf
input datafile file number=00005 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_system_djsz1z31_.dbf
input datafile file number=00008 name=/home/oracle/app/oracle/oradata/ANDYCDB/datafile/o1_mf_undotbs1_djsz1z34_.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAY-17
channel ORA_DISK_1: finished piece 1 at 10-MAY-17
piece handle=/home/oracle/rmanback/db_ANDYCDB_0bs3u6da_1_1 tag=TAG20170510T233517 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
Finished backup at 10-MAY-17

Starting Control File and SPFILE Autobackup at 10-MAY-17
piece handle=/home/oracle/fast_recovery_area/ANDYCDB/autobackup/2017_05_10/o1_mf_s_943659480_dk6dyrlw_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 10-MAY-17

二、 备份 PDB

1.1.  备份单个和多个PDB
在CDB中允许备份一个或多少PDB数据库(如果要备份多个pdb,只需在备份命令后面跟上多个你想备份的pdb实例的名称,如下backup pluggable database pdb1,pdb2; ),备份一个PDB数据库可以通过以下两个方式备份:
注意:如果没有开启归档模式,单独备份 CDB 或者是 PDB 都会报ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
方式一:在CDB根(root)使用BACKUP PLUGGABLE DATABASE命令备份一个或多个PDB数据库。 
[[email protected] ~]$ rman target / 
RMAN>  backup pluggable database pdb01;

Starting backup at 10-MAY-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00022 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_sysaux_dk5wmv11_.dbf
input datafile file number=00021 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_system_dk5wmv0s_.dbf
input datafile file number=00024 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_undo_1_dk5wmv13_.dbf
input datafile file number=00023 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_users_dk5wmv12_.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAY-17
channel ORA_DISK_1: finished piece 1 at 10-MAY-17
piece handle=/home/oracle/fast_recovery_area/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/backupset/2017_05_10/o1_mf_nnndf_TAG20170510T234055_dk6f47wq_.bkp tag=TAG20170510T234055 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
Finished backup at 10-MAY-17

Starting Control File and SPFILE Autobackup at 10-MAY-17
piece handle=/home/oracle/fast_recovery_area/ANDYCDB/autobackup/2017_05_10/o1_mf_s_943659691_dk6f5cpf_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 10-MAY-17
备份默认在 闪回恢复区里。

方式二:在PDB中使用BACKUP DATABASE备份当前连接的PDB数据库,前提条件是需要配置好TNSNAMES.ORA文件。 
[[email protected] ~]$ rman target sys/[email protected]:1521/pdb01
connected to target database: ANDYCDB:PDB01 (DBID=2550500229) 
RMAN> backup database format=‘/home/oracle/rmanback/db_%d_%U‘;

Starting backup at 10-MAY-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00022 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_sysaux_dk5wmv11_.dbf
input datafile file number=00021 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_system_dk5wmv0s_.dbf
input datafile file number=00024 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_undo_1_dk5wmv13_.dbf
input datafile file number=00023 name=/home/oracle/app/oracle/oradata/ANDYCDB/4ECF8621E3DA38EEE0531019640AA598/datafile/o1_mf_users_dk5wmv12_.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAY-17
channel ORA_DISK_1: finished piece 1 at 10-MAY-17
piece handle=/home/oracle/rmanback/db_ANDYCDB_0fs3u6tn_1_1 tag=TAG20170510T234559 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 10-MAY-17

时间: 2024-10-16 17:28:15

Oracle 12c 多租户 CDB 与 PDB 备份的相关文章

Oracle 12c 多租户 CDB 与 PDB之 shared undo 与 Local undo 切换

undo 在12C R1版本中只支持Global Shared Undo模式, 所有container共享一个UNDO表空间, 目前保留这种模式只是为了升级过渡, 在12C R2引入了PDB Local UNDO模式,每个container都有自己的UNDO 表空间, 对于RAC是每个实例每个container都有自己的UNDO表空间, 这也正是推荐的.在DBCA时会有local undo选项,且默认勾选. local undo 模式的好处:1.减少undo表空间的争用,同时方便拔插 2.只有使

oracle 12c service之cdb和pdb

srvctl add service 参数如下:-s:服务名-r:首选实例名-a:备用实例名-p:TAF策略,有none,basic,preconnect三个值可选-d-pdb srvctl add service -help 查看各个参数的含义 这里如果未指定-pdb,则连到cdb上,这在远程克隆pdb,设置tns的时候需要 srvctl add service -s lych_srv -d xxx -pdb xxx -a xxx -r xxx ---手动配置TNS的话就srvctl conf

Oracle 12c 多租户家族(12c 18c 19c)如何在 PDB 中添加 HR 模式

Oracle 12c 多租户家族(12c [12.2.0.1].18c [12.2.0.2].19c [12.2.0.3])如何在 PDB 中添加模式:19c (19.3) 手工添加示例 HR 用户 Oracle 12c 如何在 PDB 中添加 SCOTT 模式(手工方式) Oracle 12c 如何在 PDB 中添加 SCOTT 模式(数据泵方式) 目录 1. 配置TNSNAMES.ora 2. 连接PDB 3. 执行脚本 1. 配置TNSNAMES.ora 略,请参考 12c 手工方式和 1

Oracle12c多租户CDB 与 PDB 参数文件位置探讨、查询 CDB 与 PDB 不同值的参数

一. Oracle12c多租户CDB 与 PDB 参数文件位置 CDB的参数文件依然使用12c以前的SPIFLE,pdb的参数文件不会出现在SPFILE中,而是直接从CDB中继承,如果PDB中有privete Local parameter 会存在 CDB 的 PDB_SPFILE$字典表 中以con_id区别,当PDB UN-Plug时,PDB参数会写入PDB的XML文件中,当drop pluggable database后,pdb信息和PDB_SPFILE$记录也会被清除.再当PDB重新Pl

2.oracle 12c 创建-访问-关闭-删除PDB

1.创建PDB SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/ora12c/system01.dbf /u01/app/oracle/oradata/ora12c/pdbseed/system01.dbf /u01/app/oracle/oradata/or

oracle 12c 多租户 pdb 恢复(单个pdb数据文件、非系统pdb表空间、整个pdb数据库)

环境:数据库版本 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 实验准备:1.-- 数据库归档模式SQL> select name,log_mode from v$database;NAME  LOG_MODE--------- ------------ANDYCDB   ARCHIVELOG   > 数据库归档模式 2.-- 登录 PDB 中创建实验表空间 与 用户[[email pr

Oracle 12c 多租户在 CDB 中 Plug A PDB,Unplugging A PDB

Oracle 数据库 12 c 中介绍了多租户选项允许单个容器数据库 (CDB) 来承载多个单独的可插拔数据库 (PDB).本文简单的演示了如何在 CDB 中 Plug A PDB,Unplugging A PDB 操作. 一. plugged PDB into Unplugged PDBSQL> show pdbs    CON_ID CON_NAME  OPEN MODE  RESTRICTED---------- ------------------------------ -------

Oracle 12c 多租户配置和修改 CDB 和 PDB 参数

1. 配置CDB 实例参数,影响CDB与所有 PDB为CDB配置例程参数相对于对于非CDB的数据库是变化不太.ALTER SYSTEM命令用于设置初始化参数,与使用ALTER DATABASE命令修改一些数据库配置.ALTER SYSTEM SET parameter_name=value CONTAINER=ALL;说明:使用CONTAINER=ALL后,cdb与pdbs这个参数相同.pdbs可以在本地设置同一参数为不同值,将覆盖CONTAINER=ALL设定的值. 2. 修改 CDB ALT

Oracle 12C -- 手动创建CDB

1.指定oracle_sid $ export ORACLE_SID=db12 2.指定环境变量 比如ORACLE_BASE.ORACLE_HOME.PATH(要包含$ORACLE_HOME/bin)3.选定验证方式 ·操作系统验证 ·口令文件验证4.创建初始化参数文件 $ vi initdb12.ora db_name='db12' memory_target=2G processes = 150 db_block_size=8192 db_domain='' diagnostic_dest=