Oracle 12c 多租戶 CDB 與 PDB 備份

張衝andy發表於2017-05-10

一、  CDB 備份

1.1  只備份CDB

只備份CDB資料庫需要具有SYSDBA或SYSBACKUP許可權使用者連線到CDB的root環境下,執行backupdatabase root命令即可完成對CDB的備份,方法如下:
[oracle@12c01 ~]$ rman target / 
[oracle@12c01 ~]$ 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資料庫。 
[oracle@localhost ~]$ 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檔案。 
[oracle@12c01 ~]$ rman target sys/oracle@10.100.25.16: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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2138844/,如需轉載,請註明出處,否則將追究法律責任。

相關文章