oracle 12c中CDB和PDB的備份還原實驗
本文件分為兩部分:
1.單個pdb備份還原
2.只cdb備份還原
1.rman只備份pdb
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 MPDB01 READ WRITE NO
5 MPDB02 READ WRITE NO
CDB和PDB中建立如下測試表:
SQL> create table t_for_back (a int);
Table created.
SQL> insert into t_for_back select 1 from dual;
1 row created.
SQL> commit;
Commit complete.
備份單個pdb
RMAN> BACKUP pluggable database mpdb02 FORMAT '/backup/oraback/bk_%s_%p_%t';
Starting backup at 19-JUL-19
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=00016 name=/u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_undotbs1_gm2p199r_.dbf
input datafile file number=00014 name=/u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_system_gm2p199h_.dbf
input datafile file number=00015 name=/u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_sysaux_gm2p199q_.dbf
input datafile file number=00017 name=/u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_users_gm2p199s_.dbf
channel ORA_DISK_1: starting piece 1 at 19-JUL-19
channel ORA_DISK_1: finished piece 1 at 19-JUL-19
piece handle=/backup/oraback/bk_100_1_1014040596 tag=TAG20190719T135636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 19-JUL-19
Starting Control File and SPFILE Autobackup at 19-JUL-19
piece handle=/u02/app/oracle/products/12.2.0.1/db_1/dbs/c-3951895183-20190719-01 comment=NONE
Finished Control File and SPFILE Autobackup at 19-JUL-19
檢查備份情況:
RMAN> list backup of pluggable database mpdb02;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
94 Full 1.17G DISK 00:00:08 19-JUL-19
BP Key: 94 Status: AVAILABLE Compressed: NO Tag: TAG20190719T135636
Piece Name: /backup/oraback/bk_100_1_1014040596
List of Datafiles in backup set 94
Container ID: 5, PDB Name: MPDB02
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
14 Full 2902650 19-JUL-19 NO /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_system_gm2p199h_.dbf
15 Full 2902650 19-JUL-19 NO /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_sysaux_gm2p199q_.dbf
16 Full 2902650 19-JUL-19 NO /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_undotbs1_gm2p199r_.dbf
17 Full 2902650 19-JUL-19 NO /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_users_gm2p199s_.dbf
模擬資料檔案丟失
[oracle@oradb-2062 datafile]$ mv o1_mf_system_gm2p199h_.dbf o1_mf_system_gm2p199h_.dbf.bak
cdb和mpdb01中:
SQL> create table t19071901 (a int);
Table created.
SQL> insert into t19071901 select 1 from dual;
1 row created.
SQL> commit;
Commit complete.
mpdb02中
SQL> create table t19071901 (a int) tablespace users;
Table created.
SQL> insert into t19071901 select 1 from dual;
1 row created.
SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
SQL> sho con_name
ERROR:
ORA-03135: connection lost contact
Process ID: 94384
Session ID: 33 Serial number: 19671
SP2-1545: This feature requires Database availability.
現在RMAN恢復:
RMAN> restore pluggable database mpdb02;
Starting restore at 19-JUL-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00014 to /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_system_gm2p199h_.dbf
channel ORA_DISK_1: restoring datafile 00015 to /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_sysaux_gm2p199q_.dbf
channel ORA_DISK_1: restoring datafile 00016 to /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_undotbs1_gm2p199r_.dbf
channel ORA_DISK_1: restoring datafile 00017 to /u02/app/oracle/oradata/MCDB/8E032EED10D56F47E05302CEA8C0D24C/datafile/o1_mf_users_gm2p199s_.dbf
channel ORA_DISK_1: reading from backup piece /backup/oraback/bk_100_1_1014040596
channel ORA_DISK_1: piece handle=/backup/oraback/bk_100_1_1014040596 tag=TAG20190719T135636
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 19-JUL-19
RMAN> recover pluggable database mpdb02;
Starting recover at 19-JUL-19
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:02
Finished recover at 19-JUL-19
資料檢查
SQL> alter session set container=mpdb02;
Session altered.
SQL> select * from t_for_back
2 ;
A
----------
1
SQL> select * from t19071901;
A
----------
1
###########################################################################
下面用rman只備份cdb
RMAN> backup database root FORMAT '/backup/oraback/bk_%s_%p_%t';
Starting backup at 19-JUL-19
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=/u02/app/oracle/oradata/MCDB/datafile/o1_mf_system_gkmjqb8y_.dbf
input datafile file number=00003 name=/u02/app/oracle/oradata/MCDB/datafile/o1_mf_sysaux_gkmjt28w_.dbf
input datafile file number=00004 name=/u02/app/oracle/oradata/MCDB/datafile/o1_mf_undotbs1_gkmjvjz7_.dbf
input datafile file number=00007 name=/u02/app/oracle/oradata/MCDB/datafile/o1_mf_users_gkmjvl3k_.dbf
channel ORA_DISK_1: starting piece 1 at 19-JUL-19
channel ORA_DISK_1: finished piece 1 at 19-JUL-19
piece handle=/backup/oraback/bk_102_1_1014042002 tag=TAG20190719T142002 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:16
Finished backup at 19-JUL-19
Starting Control File and SPFILE Autobackup at 19-JUL-19
piece handle=/u02/app/oracle/products/12.2.0.1/db_1/dbs/c-3951895183-20190719-02 comment=NONE
Finished Control File and SPFILE Autobackup at 19-JUL-19
SQL> shutdown abort
ORACLE instance shut down.
SQL>
SQL>
SQL>
SQL> startup
ORACLE instance started.
Total System Global Area 1191182336 bytes
Fixed Size 8792104 bytes
Variable Size 436209624 bytes
Database Buffers 738197504 bytes
Redo Buffers 7983104 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1:
'/u02/app/oracle/oradata/MCDB/datafile/o1_mf_system_gkmjqb8y_.dbf'
SQL> select status from v$instance;
STATUS
------------------------------------
MOUNTED
RMAN> restore database root;
Starting restore at 19-JUL-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=42 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u02/app/oracle/oradata/MCDB/datafile/o1_mf_system_gkmjqb8y_.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u02/app/oracle/oradata/MCDB/datafile/o1_mf_sysaux_gkmjt28w_.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u02/app/oracle/oradata/MCDB/datafile/o1_mf_undotbs1_gkmjvjz7_.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u02/app/oracle/oradata/MCDB/datafile/o1_mf_users_gkmjvl3k_.dbf
channel ORA_DISK_1: reading from backup piece /backup/oraback/bk_102_1_1014042002
channel ORA_DISK_1: piece handle=/backup/oraback/bk_102_1_1014042002 tag=TAG20190719T142002
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 19-JUL-19
RMAN> recover database root;
Starting recover at 19-JUL-19
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 19-JUL-19
RMAN> alter database open;
Statement processed
BACKUP DATABASE;
會備份所有的CDB和PDB
BACKUP DATABASE root;
只備份CDB
BACKUP DATABASE pdb01,pdb02;
備份指定的PDB
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31480688/viewspace-2651129/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【BAK_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(三)CDB與PDB的備份方式Oracle
- Oracle 12c 多租戶 CDB 與 PDB 備份Oracle
- 【ASK_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(一)什麼是CDB與PDB?Oracle
- Oracle 12C 中CDB和PDB的引數檔案管理Oracle
- oracle 12c rman備份pdbOracle
- oracle 12c PDB隨CDB啟動和連結PDB的方式Oracle
- 【RECO_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(四)PDB的幾種恢復方式Oracle
- ORACLE 12C新特性——CDB與PDBOracle
- 【ASK_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(二)備份恢復之前你需要知道的Oracle
- Oracle 12c 多租戶在 CDB 中 Plug A PDB,Unplugging A PDBOracle
- 12c RAC 和 CDB/PDB 學習
- Oracle 12C RMAN transport tablespace from PDB of RAC CDB to remote PDBOracleREM
- Oracle 12c PDB的資料備份恢復Oracle
- Oracle 12C RMAN Duplicating the PDB to remote CDBOracleREM
- Oracle 12c CDB&PDB 基本維護Oracle
- oracle基礎備份和還原Oracle
- Oracle CDB和PDB基本管理Oracle
- Oracle 12c 多租戶配置和修改 CDB 和 PDB 引數Oracle
- Oracle 12c 使用Non-CDB來建立PDBOracle
- Sqlserver關於校驗和_備份還原的CHECKSUMSQLServer
- 【PDB】pdb閃回,Oracle還原點Oracle
- oracle 12c 針對cdb的差異0備與對pdb進行恢復Oracle
- 【CDB】Oracle CDB/PDB常用管理命令Oracle
- oracle12c的CDB和PDB初探Oracle
- MySQL備份和還原MySql
- ORACLE RMAN備份及還原Oracle
- Oracle 12c系列(七) | Non-CDB轉換為PDBOracle
- 12C關於CDB、PDB建立AWR的方法和總結
- 優化 SQL Server 中的備份和還原效能優化SQLServer
- 「Oracle」Oracle 資料庫備份還原Oracle資料庫
- MySQL之備份和還原MySql
- oracle資料還原與備份Oracle
- Oracle 12c 手動建立CDB和非CDBOracle
- 12C還原使用舊版本RMAN所建立的備份
- 12C關於CDB、PDB引數的區別和總結
- Oracle 12c多租戶特性詳解:PDB 的備份與恢復Oracle
- mysql備份還原-基於binlog的增量備份還原MySql
- 利用dump和restore實現Linux的備份和還原RESTLinux