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
- 【12c cdb pdb】實驗
- 【ASK_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(一)什麼是CDB與PDB?Oracle
- oracle 12c rman備份pdbOracle
- Oracle 12C 中CDB和PDB的引數檔案管理Oracle
- 【RECO_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(四)PDB的幾種恢復方式Oracle
- oracle 12c PDB隨CDB啟動和連結PDB的方式Oracle
- 【ASK_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(二)備份恢復之前你需要知道的Oracle
- oracle 12c 針對cdb的差異0備與對pdb進行恢復Oracle
- 【CDB】Oracle CDB/PDB常用管理命令Oracle
- Oracle 12c系列(七) | Non-CDB轉換為PDBOracle
- 【PDB】pdb閃回,Oracle還原點Oracle
- 「Oracle」Oracle 資料庫備份還原Oracle資料庫
- Oracle 12c 手動建立CDB和非CDBOracle
- Sqlserver關於校驗和_備份還原的CHECKSUMSQLServer
- 12C關於CDB、PDB建立AWR的方法和總結
- 2.6.1 CDB中備份和恢復的概述
- 12C關於CDB、PDB的官方解釋
- 12C關於CDB、PDB引數的區別和總結
- 12c跨平臺完成PDB的備份遷移
- oracle 還原 .dmp 格式備份檔案Oracle
- Oracle 12c no-CDB轉換為CDBOracle
- Mysql資料備份和還原MySql
- 【SQL Server】本地備份和還原SQLServer
- oracle 19c CDB vs pdb 建立Oracle
- Oracle 12c 備份與恢復Oracle
- 多租戶:在Oracle12.2中 從Non-CDB遷移到PDB,從PDB遷移另一個CDB中Oracle
- Oracle 12c系列(二)|PDB的建立Oracle
- Oracle資料庫備份還原詳解XKUSOracle資料庫
- Oracle 12c CDB&PDBs管理Oracle
- elasticsearch備份和還原(基於hdfs)Elasticsearch
- 「MySQL」資料庫備份和還原MySql資料庫
- oracle 12c non-cdb升級成cdb模式Oracle模式
- Oracle 12c系列(五)|PDB RefreshOracle
- Oracle 12c系列(六)|Relocate a PDBOracle
- 詳解MYSQL的備份還原(PHP實現)MySqlPHP
- 12C多租戶關於CDB、PDB的常用SQL語句SQL
- 12C把non-CDB的單庫匯入到CDB裡面當成PDB的方法