Oracle 12C 新特性之 恢復表
RMAN的表級和表分區級恢復應用場景:
1、You need to recover a very small number of tables to a particular point in time. In this situation, TSPITR is not the most effective solution because it moves all the objects in the tablespace to a specified point in time.
2、You need to recover tables that have been logically corrupted or have been dropped and purged.
3、Flashback Table is not possible because the desired point-in-time is older than available undo.
4、You want to recover data that is lost after a DDL operation modified the structure of tables. Using Flashback Table is not possible because a DDL was run on the tables between the desired point in time and the current time. Flashback Table cannot rewind tables through structural changes such as a truncate table operation.
譯文:
1、您需要將非常少量的表恢復到特定的時間點。在這種情況下,TSPITR 不是最有效的解決方案,因為它將表空間中的所有對象都移動到指定的時間點。
2、您需要恢復已被邏輯損壞或已被刪除和清除的表。
3、Flashback Table 不可用,如undo 數據已經被覆蓋。
4、恢復在DDL操作修改表結構之後丟失的數據。使用Flashback表是不可能的,因為在需要的時間點和當前時間之間的表上運行一個DDL。閃回表不能通過諸如截斷表操作之類的結構更改來倒表。
RMAN的表級和表分區級恢復限制:
1、Tables and table partitions belonging to SYS schema cannot be recovered.
2、Tables and table partitions from SYSTEM and SYSAUX tablespaces cannot be recovered.
3、Tables and table partitions on standby databases cannot be recovered.
4、Tables with named NOT NULL constraints cannot be recovered with the REMAP option.
RMAN的表級和表分區級恢復前提:
1、The target database must be in read-write mode.
2、The target database must be in ARCHIVELOG mode.
3、You must have RMAN backups of the tables or table partitions as they existed at the point in time to which you want recover these objects.
4、To recover single table partitions, the COMPATIBLE initialization parameter for target database must be set to 11.1.0 or higher.
恢復方法:
1、SCN
2、Time
3、Sequence number
RMAN從備份中自動處理恢復表或者表分區時的步驟:
1、Determines which backup contains the tables or table partitions that need to be recovered, based on the point in time specified for the recovery.
2、Determines if there is sufficient space on the target host to create the auxiliary instance that will be used during the table or partition recovery process.
If the required space is not available, then RMAN displays an error and exits the recovery operation.
3、Creates an auxiliary database and recovers the specified tables or table partitions, until the specified point in time, into this auxiliary database.
You can specify the location to which the recovered data files are stored in the auxiliary database.
4、Creates a Data Pump export dump file that contains the recovered tables or table partitions.
You can specify the name and the location of the export dump file used to store the metadata of the recovered tables or table partitions.
5、(Optional) Imports the Data Pump export dump file into the target instance.
You can choose not to import the export dump file that contains the recovered tables or table partitions into the target database. If you do not import the export dump file as part of the recovery process, you must manually import it later using the Data Pump Import utility.
6、(Optional) Renames the recovered tables or table partitions in the target database.
You can also import recovered objects into a tablespace or schema that is different from the one in which they originally existed.
譯:
1.確定哪些備份包含需要恢復的表或表分區,根據指定的時間來進行恢復。
2.確定目標主機上是否有足夠的空間來創建將在表或分區恢復過程中使用的輔助實例。 如果需要的空間不足,那麽RMAN會報錯並退出恢復操作。
3.創建一個輔助數據庫並恢復指定的表或表分區,並根據指定的時間來恢復指定的表或表分區到輔助數據庫中。 可以指定用於存儲已恢復表或表分區的元數據的導出轉儲文件的名稱和位置。
4.創建一個數據泵導出轉儲文件,其中包含已恢復的表或表分區。可以指定用於存儲已恢復表或表分區的元數據的導出轉儲文件的名稱和位置。
5. (可選操作)將上一步生產的數據泵文件導入到目標實例中。您可以選擇不導入包含已恢復的表或表分區到目標數據庫的導出轉儲文件。如果您不導入導出轉儲文件作為恢復過程的一部分,那麽您必須在稍後使用 impdp 手工導入。
6. (可選操作)在目標數據庫中rename 恢復表或表分區。
PDB操作流程:
-- 準備測試環境
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB01 READ WRITE NO
4 PDB02 READ WRITE NO
SQL> alter session set container=pdb01;
Session altered.
SQL> select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
BBB
6 rows selected.
-- 建立測試用戶
SQL> show con_name
CON_NAME
------------------------------
PDB01
SQL> create user andy identified by andy default tablespace bbb;
User created.
SQL> grant dba to andy;
Grant succeeded.
-- 創建測試表:
SQL> conn [email protected]
Connected.
SQL> create table andy(id int);
Table created.
SQL> insert into andy values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> conn / as sysdba
Connected.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
-- RMAN 備份CDB
--使用如下命令備份CDB的組建:ROOT,SEED,PDBS:
[[email protected]