Oracle 12c 新特性 --- PDBs Point-in-Time Recoverys

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/leo__1990/article/details/90199334

概念

You can now recover a PDB to a specific point-in-time.
This feature is a high availability enhancement for consolidation and extends point-in-time recovery functionality to PDBs.
您现在可以将PDB恢复到特定的时间点。
该特性是对整合的高可用性增强,并将点时恢复功能扩展到PDBs。
The steps to perform point-in-time recovery of PDBs are similar to the ones for performing DBPITR, with the differences described in this section. When you recover one or more PDBs to a specified point-in-time, the remaining PDBs in the CDB are not affected and they can be open and operational. After recovery, the old backups of the PDB remain valid and can be used if a media failure occurs. You do not need to create new backups.

If you have performed point-in-time recovery for a PDB, then you cannot directly flashback the whole CDB to a point that is beyond the point in time to which the PDB was recovered. You must use the steps described in "Performing Flashback Database Operations on a CDB When a PDB Was Recovered Using DBPITR".

When performing DBPITR on one or more PDBs in a CDB, backups of the root and the seed database (PDB$SEED) of the CDB that contains the PDBs are required.

In a Data Guard environment, you may need to flash back the entire standby database or restore the PDB for the standby database to follow a primary database with a PDB that was restored to a point in time.
执行PDBs的时间点恢复的步骤与执行DBPITR的步骤类似,在本节中描述的差异。当您将一个或多个PDBs恢复到指定的时间点时,CDB中的其余PDBs不受影响,它们可以打开和操作。恢复后,PDB的旧备份仍然有效,如果出现媒体故障,则可以使用。您不需要创建新的备份。
如果您对PDB执行了时间点恢复,那么您就不能直接将整个CDB倒叙到一个超出了PDB恢复时间点的点上。您必须使用“Performing Flashback Database Operations on a CDB When a PDB Was Recovered Using DBPITR"”中描述的步骤。
在CDB中的一个或多个PDBs上执行DBPITR时,需要对包含PDBs的CDB的根和种子数据库(PDB $ seed)进行备份。
在数据保护环境中,您可能需要返回整个备用数据库,或者恢复备用数据库的PDB,以跟踪主数据库,并将PDB恢复到时间点。

实验 

1)备份PDB
[oracle@dg1 ~]$ rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Aug 3 16:10:08 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CNDBA (DBID=211273844)

RMAN> BACKUP PLUGGABLE DATABASE pdbcndba;

Starting backup at 03-AUG-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=00010 name=/u01/app/oracle/oradata/cndba/pdbcndba/sysaux01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/cndba/pdbcndba/system01.dbf
input datafile file number=00011 name=/u01/app/oracle/oradata/cndba/pdbcndba/undotbs01.dbf
input datafile file number=00012 name=/u01/app/oracle/oradata/cndba/pdbcndba/users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-AUG-17
channel ORA_DISK_1: finished piece 1 at 03-AUG-17
piece handle=/u01/app/oracle/product/12.1.0/db_1/dbs/06sb07ol_1_1 tag=TAG20170803T170629 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
Finished backup at 03-AUG-17

Starting Control File and SPFILE Autobackup at 03-AUG-17
piece handle=/u01/app/oracle/product/12.1.0/db_1/dbs/c-211273844-20170803-04 comment=NONE
Finished Control File and SPFILE Autobackup at 03-AUG-17

2)创建用户,表
[oracle@dg1 ~]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Aug 3 17:17:10 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

SQL> conn /as sysdba
Connected.

SQL> CREATE USER test IDENTIFIED BY test
  DEFAULT TABLESPACE users
  QUOTA UNLIMITED ON users;
  
User created.

SQL> grant dba to test;

Grant succeeded.

SQL> conn test/test@pdbcndba
Connected.
SQL> set time on;
15:45:14 SQL> create table leo1 (id number(10));

Table created.

15:45:22 SQL> insert into leo1 values(10);

1 row created.

15:45:28 SQL> commit;

Commit complete.

15:45:31 SQL> select * from leo1;

	ID
----------
	10
3) 切换归档
15:45:45 SQL> conn /as sysdba
Connected.
15:45:52 SQL> alter system switch logfile;

System altered.

15:45:54 SQL> alter system switch logfile;

System altered.
4)删除表病记录时间
15:45:56 SQL> alter session set container=pdbcndba;

Session altered.

15:47:49 SQL> conn test/test@pdbcndba
Connected.

15:49:08 SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2017-08-03 15:49:17

16:23:13 SQL>  drop table leo1 purge;

Table dropped.
5)基于时间点的恢复PDB
[oracle@dg1 ~]$ rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Aug 3 16:57:57 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CNDBA (DBID=211273844)

RMAN> ALTER PLUGGABLE DATABASE pdbcndba CLOSE;

using target database control file instead of recovery catalog
Statement processed
--恢复到删除表的时间 16:23:13
RMAN> run{
  SET UNTIL TIME "TO_DATE('03-08-2017 16:23:13','DD-MM-YYYY HH24:MI:SS')";
  RESTORE PLUGGABLE DATABASE pdbcndba;
  RECOVER PLUGGABLE DATABASE pdbcndba AUXILIARY DESTINATION '/tmp';
  ALTER PLUGGABLE DATABASE pdbcndba OPEN RESETLOGS;
}

executing command: SET until clause

Starting restore at 03-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=27 device type=DISK

skipping datafile 11; already restored to file /u01/app/oracle/oradata/cndba/pdbcndba/undotbs01.dbf
skipping datafile 12; already restored to file /u01/app/oracle/oradata/cndba/pdbcndba/users01.dbf
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 00009 to /u01/app/oracle/oradata/cndba/pdbcndba/system01.dbf
channel ORA_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/cndba/pdbcndba/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/12.1.0/db_1/dbs/01sb02a3_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/12.1.0/db_1/dbs/01sb02a3_1_1 tag=TAG20170803T153323
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 03-AUG-17

Starting recover at 03-AUG-17
using channel ORA_DISK_1


starting media recovery

archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/product/12.1.0/db_1/dbs/arch1_3_946811064.dbf
archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/product/12.1.0/db_1/dbs/arch1_4_946811064.dbf
archived log for thread 1 with sequence 5 is already on disk as file /u01/app/oracle/product/12.1.0/db_1/dbs/arch1_5_946811064.dbf
media recovery complete, elapsed time: 00:00:05
Finished recover at 03-AUG-17

Statement processed

6)验证数据是否还原成功
16:35:44 SQL> conn /as sysdba
Connected.
16:35:47 SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDBCNDBA			  READ WRITE NO
	 
16:38:46 SQL> alter session set container=pdbcndba;

Session altered.

16:39:00 SQL> 
16:39:00 SQL> conn test/test@pdbcndba
Connected.
16:39:10 SQL>  select * from leo1;

	ID
----------
	10

参考链接:

http://docs.oracle.com/database/121/BRADV/rcmflash.htm#BRADV89755

https://oracle-base.com/articles/12c/multitenant-rman-backup-recovery-cdb-and-pdb-12cr1

猜你喜欢

转载自blog.csdn.net/leo__1990/article/details/90199334
今日推荐