使用管理主控台還原資料庫
還原至原始資料庫後,系統會將原始的生產應用程式資料替換為指定的時間點映像檔。這項還原作業會導致所有目前的應用程式資料遺失,因為應用程式會還原為建立映像檔時的狀態。這項操作無法復原。完成還原作業所需的時間取決於相關資料量。您也可以將資料庫還原至其他目標。
請按照這些操作說明,使用 RMAN 從管理控制台自動還原 Oracle 資料庫,並覆寫原始的實際工作環境資料庫。
開啟管理控制台,前往「應用程式管理工具」,然後輸入資料庫應用程式名稱,或使用篩選器找出所需的資料庫映像檔。
在應用程式上按一下滑鼠右鍵,然後選取「存取」。
在「存取」頁面中選取圖片,然後點按「掛載」選單下方的「還原」。
在「Restore」頁面中,選取「Traditional」 (而非「Mount and Migrate」)。
使用「Restore Range」滑桿選取特定時間點,即可還原資料庫。將滑桿工具向左滑動,即可只還原資料庫,而不套用任何記錄。
在「使用者名稱」中,輸入所選目標伺服器的 Oracle 軟體擁有者。
針對「管道數量」,請指定 RMAN 管道數量,以便設定資料庫還原作業的平行作業。
按一下「提交」。
系統隨即會顯示警告對話方塊。請詳閱內容,然後輸入
DATA LOSS
來確認。系統會將這項工作排入下一個可用的任務時段。您可以透過「Jobs Monitor」查看進度。
使用管理控制台將資料庫還原至任何目標
請按照這些操作說明,透過管理控制台使用 RMAN 將 Oracle 資料庫還原至新目標。
- 在「App Manager」 >「Applications」清單中,按一下資料庫的滑鼠右鍵,然後選取「Access」。
- 選取要復原的備份映像檔,然後選擇「還原」。
在「還原」頁面中,選取「傳統」。
- 目標:針對所有設定,您可以從下拉式選單中選擇所有符合條件的 Oracle 資料庫伺服器。從下拉式選單中選取要還原的目標伺服器。
- Replace Original Application identity:這個選項僅適用於將備份資料還原至原始產生備份的裝置上。
- 是:這會取代原始應用程式,並與原始應用程式具有相同的應用程式 ID、工作記錄、備份映像檔和備份方案。
- 否:這不會取代原始應用程式。系統會在還原作業中,將新資料庫視為新應用程式。
- 快轉時間:為使用記錄保護的資料庫選擇日期和時間,以便復原到所需的時間點。
應用程式選項:
- DATABASESID:系統會預先填入受保護的資料庫 SID 名稱,且無法變更。
- USERNAME:系統會預先填入來源資料庫 Oracle 軟體擁有者的名稱。如果所選目標伺服器的 Oracle 軟體擁有者不同,請更新 USERNAME。
- ORAHOME:預先填入來源資料庫 Oracle 主機路徑。如果 Oracle 主目錄與所選目標伺服器不同,請更新 Oracle 主目錄目錄。
- 進階選項:系統會預先填入這項資訊,並在備份時顯示來源的所有資料庫參數設定 (來自 pfile)。請確認要還原的目標資料庫伺服器 (來源或新目標) 的參數值正確無誤。
對應選項:
目標資料庫類型:從下拉式清單中選取資料庫的資料庫目標類型 (ASM 磁碟群組或檔案系統)。備份映像檔不支援 ASM 格式的檔案系統目標類型。
來源資料庫 備用圖片格式 還原目標 ASM ASM ASM ASM 檔案系統 ASM 檔案系統 檔案系統 檔案系統 從下拉式清單中選取目標 ASM 磁碟群組和檔案系統對應項目,適用於下列三種檔案類型:資料檔案、控制檔案和資料庫的重做檔案。
按一下「飛行前檢查」。如果前置檢查失敗,請修正問題,然後再次執行前置檢查。
按一下「提交」,即可提交還原工作。
使用 RMAN 手動復原 Oracle 資料庫
如要手動復原 Oracle 資料庫,請參閱這些程序。
非 RAC、非 ASM、檔案系統
復原檔案系統中含有資料檔案的 Oracle 資料庫,並以檔案格式暫存磁碟格式進行保護
從受保護的來源資料庫掛載映像檔。
在「Mount」視窗的「Mapping Options」中,提供圖片的掛載位置,例如:
/acttestdb
。如需掛載資料庫映像檔的操作說明,請參閱「掛載受保護的 Oracle 資料庫映像檔,以便存取資料」。資料庫備份映像檔已掛載至:
/acttestdb
受保護的封存記錄會掛載在:
/acttestdb_Log
設定 Oracle 環境,並使用 sqlplus 關閉資料庫:
sqlplus / as sysdba sql> shutdown immediate;
確認資料庫已關閉。結束資料庫的任何剩餘程序。
ps -ef | grep database sid
使用已掛接磁碟區中的備份參數檔案,在未掛載狀態下啟動資料庫。備份參數檔案位於頂層掛載資料夾下方,例如
/acttestdb
設定 Oracle 環境,並使用 sqlplus 啟動資料庫:
sqlplus / as sysdba sql> startup nomount pfile='/acttestdb/database sid___backup.ora';
從現有的 pfile 建立新的 spfile,然後重新啟動資料庫。
從 pfile 建立 spfile:
create spfile='$ORACLE_HOME/dbs/spfile_database sid.ora' from pfile='/acttestdb/database sid___backup.ora';
在 spfile 處於未掛載狀態時重新啟動資料庫:
shutdown immediate; startup nomount;
使用 RMAN 從已掛載的備份和災難復原封存日誌映像檔還原控制檔案。使用已掛載記錄的最新控制檔案,例如:
/acttestdb_Log/cf D_sid-id_Target SID.ctl
或有多張記錄圖片:
/acttestdb_Log_1/cf-D_sid-id_Target SID.ctl
rman target / restore controlfile from '/acttestdb_Log_1/cf-D_<var>sid</var>-id_<var>id</var>.ctl' ;
掛載資料庫:
alter database mount;
將備份和災難復原掛載的資料庫映像檔和封存記錄映像檔目錄到 RMAN:
run { catalog start with '+acttestdg/db_name/datafile' noprompt; catalog start with '+acttestdg/db_namearchivelog' noprompt; catalog start with 'mountpoint_log' noprompt; }
還原及復原資料庫:
run { restore database ; recover database; }
如要使用 yyyymmddhh24mi 格式進行特定時間點復原:
run { restore database; recover database until time "to_date('timestamp','yyyymmddhh24mi')"; }
開啟含有重設記錄選項的資料庫。
如要復原主要資料庫:
alter database open resetlogs;
如要復原 Data Guard 待命資料庫,請啟動 Data Guard 管理的復原程序:
alter database recover managed standby database nodelay disconnect;
資料庫可供讀取和寫入。
RAC 或獨立 ASM、檔案系統
復原在 ASM 磁碟群組中,以檔案格式保護的 Oracle 資料庫資料檔案
從受保護的來源資料庫掛載映像檔。
在「掛載」視窗的「對應選項」下方,提供圖片的掛載位置,例如:
/acttestdb
。如需掛載資料庫映像檔的操作說明,請參閱「掛載在檔案系統下受保護的 Oracle 資料庫映像檔,以便存取資料」。資料庫備份映像檔已掛載至掛載位置:
/acttestdb
受保護的封存記錄會掛載在:
/acttestdb_Log
關閉 Oracle 資料庫。從節點 1 以 su 權限切換至 Oracle OS 使用者:
su - oracle
設定 Oracle 環境,並使用 srvctl 停止所有節點的資料庫:
srvctl stop database -d <var>database_name</var>
確認資料庫已關閉 (所有節點)。結束資料庫的任何剩餘程序。
ps -ef | grep <var>database_name</var>
使用已掛接磁碟區中的備份參數檔案,在未掛接狀態下啟動資料庫。備份參數檔案位於頂層已掛載資料夾下,例如
/acttestdb
設定 Oracle 環境,並使用 sqlplus 啟動資料庫:
sqlplus / as sysdba startup nomount pfile='/acttestdb/<var>database_name</var>___backup.ora';
建立新的 spfile,然後重新啟動資料庫。
如要取得磁碟群組下原始 spfile 的路徑:
cat $ORACLE_HOME/dbs/init{database sid}.ora
例如:spfile=+{preferred disk group}/db_name/spfiledb_name.ora`
create spfile='+{preferred disk group}/{db name}/spfile<var>db_name</var>.ora' from pfile='/acttestdb/<var>db_name</var>___backup.ora';
在 spfile 處於未掛載狀態時重新啟動資料庫:
shutdown immediate; startup nomount;
使用 RMAN 從已掛載的備份和 DR 封存記錄映像檔還原控制檔案。使用已掛載記錄檔的最新控制檔案,例如:
/acttestdb_Log/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl
或有多張記錄圖片:
/acttestdb_Log_1/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl
target / restore controlfile from '/acttestdb_Log_1/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl' ; ```
掛載資料庫:
alter database mount;
將備份和 DR 已掛載的資料庫映像檔和封存記錄映像檔目錄到 RMAN:
run { catalog start with '/acttestdb/datafile' noprompt; catalog start with '/acttestdb/archivelog' noprompt; catalog start with '/acttestdb_Log' noprompt;}
還原及復原資料庫:
run { restore database ; recover database; }
如要使用 yyyymmddhh24mi 格式進行特定時間點復原:
run { restore database; recover database until time "to_date('<var>timestamp</var>','yyyymmddhh24mi')"; }
開啟含有重設記錄選項的資料庫。
- 如要復原主要資料庫:
alter database open resetlogs;
RAC 設定需要在重設記錄後執行另一個步驟:關閉節點 1 上的資料庫,並在所有節點上啟動資料庫。
使用 sqlplus 關閉資料庫:
sqlplus / as sysdba shutdown immediate; ``` Use srvctl to start the database across all nodes: ```srvctl srvctl start database -d <var>database_name</var> ``` + For Data Guard standby database recovery: + For non-RAC config: Start the Data Guard managed recovery process ```rman alter database recover managed standby database nodelay disconnect; ``` + For RAC config: Shut down the database on node 1 and start the database in mounted state across all nodes. 1. Use sqlplus to shut down the database: ```sqlplus / as sysdba shutdown immediate; ``` 1. Use srvctl to start the database in a mount state across all nodes: ```srvctl srvctl start database -d <var>database_name</var> -o mount ``` 1. Start the Data Guard managed recovery process: ```rman alter database recover managed standby database nodelay disconnect; ```
資料庫可供讀取和寫入。
RAC 或獨立 ASM、ASM 磁碟群組
在 ASM 磁碟群組中,使用含有資料檔案的 Oracle 資料庫,並在 ASM 磁碟群組暫存磁碟格式下進行保護
從受保護的來源資料庫掛載映像檔。在「Mount」視窗中,為 RAC 節點 1 的 ASM 下方映像檔掛載作業提供偏好的磁碟群組。如要進一步瞭解如何掛載資料庫映像檔,請參閱「Mounting an Oracle Database Image Protected Under an ASM Disk Group for Data Access」(為資料存取目的,掛載在 ASM 磁碟群組下受保護的 Oracle 資料庫映像檔)。
舉例來說,在掛載畫面上:
選取主機:RAC 節點 1 資料庫伺服器
首選磁碟群組:acttestdg
RAC 節點清單:RAC 節點 1 的 IP
備份參數檔案會複製至
/act/touch/<var>preferred_disk_group</var>/
下,例如:/act/touch/acttestdg/<var>database_name</var>___backup.ora
關閉 Oracle 資料庫。
從節點 1 以 su 權限切換至 Oracle OS 使用者:
su - oracle
設定 Oracle 環境。使用 srvctl 停止所有節點的資料庫:
srvctl stop database -d <var>database_name</var>
確認資料庫已關閉 (在所有節點上)。結束資料庫的所有剩餘程序。
ps -ef | grep <var>db_name</var>
使用 /act/touch/acttestdg 下複製的備份參數檔案,以 nomount 狀態啟動資料庫。
設定 Oracle 環境。使用 sqlplus 啟動資料庫:
```sqlplus / as sysdba startup nomount pfile='/act/touch/acttestdg/<var>db_name</var>___backup.ora'; ```
建立新的 spfile,然後重新啟動資料庫。
如要取得磁碟群組下原始 spfile 的路徑:
```sqlplus cat $ORACLE_HOME/dbs/init(database sid).ora ```
例如:spfile=+preferred disk group/db_name/spfiledb_name.ora
create spfile='+<var>preferred disk group</var>/<var>db_name</var>/spfile<var>db_name</var>.ora' from pfile='/act/touch/acttestdg/<var>db_name</var>___backup.ora';
在 spfile 處於未掛載狀態時重新啟動資料庫:
```sql shutdown immediate; startup nomount; ```
使用 RMAN 從已掛載備份和災難復原封存日誌映像檔還原控制檔案。使用已掛載記錄映像檔的最新控制檔案,例如:
/acttestdb_Log/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl
,或如果有多個記錄映像檔:/acttestdb_Log_1/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl
```rman rman target / restore controlfile from '/acttestdg_Log_1/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl' ; ```
掛載資料庫:
```rman alter database mount; ```
將備份和災難復原掛載的資料庫映像檔和封存記錄映像檔,目錄化為 RMAN:
```rman run { catalog start with '+acttestdg/<var>db_name</var>/datafile' noprompt; catalog start with '+acttestdg/<var>db_name</var>/archivelog' noprompt; catalog start with '/acttestdg_Log' noprompt;} ```
還原及復原資料庫:
```rman run { restore database ; recover database ; } ```
如要執行特定時間點復原作業,請執行下列復原指令:
```rman run { restore database; recover database until time "to_date('<var>timestamp</var>','yyyymmddhh24mi')"; } ```
開啟含有重設記錄選項的資料庫。
如要復原主要資料庫:
alter database open resetlogs;
RAC 設定需要另一個步驟:重設記錄後,請關閉節點 1 上的資料庫,並在所有節點上啟動資料庫。使用 sqlplus 關閉資料庫:
/ as sysdba shutdown immediate;
使用 srvctl 在所有節點上啟動資料庫:
start database -d <var>database_name</var>
針對 Data Guard 待命資料庫復原作業:
針對非 RAC 設定:啟動 Data Guard 受管理的復原程序:
alter database recover managed standby database nodelay disconnect;
針對 RAC 設定:關閉節點 1 上的資料庫,並在所有節點上以已掛載的狀態啟動資料庫。
使用 sqlplus 關閉資料庫:
as sysdba shutdown immediate;
使用 srvctl 在所有節點上以掛載狀態啟動資料庫:
start database -d <var>database_name</var> -o mount
啟動 Data Guard 管理的復原程序:
alter database recover managed standby database nodelay disconnect;
資料庫可供讀取和寫入。
復原 Oracle 表格空間和資料檔案
如要復原單一表格空間資料檔案 (例如因資料損毀而導致):
將備份/復原裝置中的最新資料庫快照掛載回 Oracle 伺服器。
將資料庫備份快照目錄到 RMAN。
使用備份快照還原及復原表格空間,詳情請參閱這篇文章。
在 ASM 磁碟群組中,還原正式版資料庫的單一表格空間
如要將生產資料庫的單一表格空間還原至主要節點,請按照下列步驟操作:
掛接資料庫指定時間點快照,詳情請參閱「將 Oracle 資料庫掛接為標準掛載」。
在「掛載」視窗的「對應選項」下方,提供圖片的掛載位置。舉例來說,如果是 ASM 磁碟群組下的映像檔,請提供「Preferred Disk Group」下的磁碟群組名稱;如果是檔案系統下的映像檔,請提供掛載位置,例如
/acttestdb
。如需掛載在檔案系統下受保護的 Oracle 資料庫映像檔的操作說明,請參閱「掛載在檔案系統下受保護的 Oracle 資料庫映像檔,以便存取資料」。
如要進一步瞭解如何掛載在 ASM 磁碟群組下受保護的 Oracle 資料庫映像檔,請參閱「掛載在 ASM 磁碟群組下受保護的 Oracle 資料庫映像檔,以便存取資料」。
在主要節點中,以 Oracle OS 使用者身分登入資料庫伺服器。
設定資料庫環境並登入 RMAN:
rman target /
在 RMAN 提示訊息中,將備份資料檔案和封存記錄資料夾編目:
範例:受 ASM 磁碟群組保護的資料庫映像檔: (已掛載的 ASM 磁碟群組名稱為「+ acttestdg」):
```rman catalog start with '+acttestdg/<var>db_name</var>/datafile' noprompt; catalog start with '+acttestdg/<var>db_name</var>/archivelog' noprompt; catalog start with ‘/<var>mountpoint_log</var>'; noprompt; (If archivelogs are protected by Backup and DR) ```
範例:受檔案系統保護的資料庫映像檔 (已掛載的檔案系統名稱為「/acttestdb」):
```rman catalog start with '/acttestdb/datafile' noprompt; catalog start with '/acttestdb/archivelog' noprompt; catalog start with '/acttestdb_log/archivelog' noprompt; ``` (If archivelogs are protected by Backup and DR)
您現在可以執行所有 RMAN 復原指令,例如:
完成後,請卸載並刪除映像檔。
復原表空間
如要復原表空間,請按照下列步驟操作:
```rman
restore tablespace <var>tablespace name</var>;
recover tablespace <var>tablespace name</var>;
```
復原資料檔案
如要復原資料檔案,請按照下列步驟操作:
```rman
restore datafile <var>file#</var>;
recover datafile <var>file#</var>;
```
復原損毀的資料庫區塊
如何復原損毀的資料庫區塊:
掛接資料庫指定時間點快照,詳情請參閱「將 Oracle 資料庫掛接為標準掛載」。
在「Mount」視窗的「Mapping Options」中,提供圖片的掛載位置。舉例來說,如果是 ASM 磁碟群組中的映像檔,請在「Preferred Disk Group」(偏好磁碟群組) 下方提供磁碟群組名稱,如果是檔案系統中的映像檔,請提供掛載位置,例如 /acttestdb。
如要瞭解如何掛載在檔案系統下受保護的 Oracle 資料庫映像檔,請參閱「掛載在檔案系統下受保護的 Oracle 資料庫映像檔,以便存取資料」。
如要進一步瞭解如何掛載在 ASM 磁碟群組下受保護的 Oracle 資料庫映像檔,請參閱「掛載在 ASM 磁碟群組下受保護的 Oracle 資料庫映像檔,以便存取資料」。
在主要節點中,以 Oracle OS 使用者身分登入資料庫伺服器。
設定資料庫環境並登入 sqlplus,然後查詢 v$database_block_corruption 以檢查損毀的區塊:
```sh sqlplus / as sysdba sql> SELECT * FROM V$DATABASE_BLOCK_CORRUPTION; ```
登入 RMAN 來復原所有損毀的區塊:
```rman rman target / RECOVER CORRUPTION LIST; ```
區塊復原後,資料庫會將這些區塊從 V$DATABASE_BLOCK_CORRUPTION 中移除。
如要復原個別損毀的區塊 (例如資料檔案 8 和區塊 13):
透過 RMAN 提示
```rman recover datafile 8 block 13; ```
復原遺失的控制檔案
如要復原遺失的控制檔案,請按照下列步驟操作:
掛接資料庫時間點快照,詳情請參閱「將 Oracle 資料庫掛接為標準掛載」。
在「Mount」視窗的「Mapping Options」中,提供圖片的掛載位置。舉例來說,如果是 ASM 磁碟群組下的映像檔,請在「Preferred Disk Group」下方提供磁碟群組名稱;如果是檔案系統下的映像檔,請提供掛載位置,例如
/acttestdb
。如需掛載在檔案系統下受保護的 Oracle 資料庫映像檔的操作說明,請參閱「掛載在檔案系統下受保護的 Oracle 資料庫映像檔,以便存取資料」。
如要進一步瞭解如何掛載在 ASM 磁碟群組下受保護的 Oracle 資料庫映像檔,請參閱「Mounting an Oracle Database Image Protected Under an ASM Disk Group for Data Access」。
在主要節點中,以 Oracle OS 使用者身分登入資料庫伺服器。
設定資料庫環境並登入 sqlplus,然後關閉資料庫並以 nomount 狀態啟動:
針對獨立資料庫:
```sql sqlplus / as sysdba sql> shutdown immediate; sql> startup nomount; ```
針對已掛載映像檔節點的 RAC 資料庫,請關閉所有節點的資料庫:
```sh srvctl stop database -d <var>db_name</var> sql> startup nomount; ```
從備份和 DR 已掛載映像檔還原控制檔案。
例如:
/acttestdb
(檔案系統) 和+acttestdg
(適用於 ASM)```rman rman target / restore controlfile from '/acttestdb/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl' ; (Filesystem mount) restore controlfile from '+acttestdb/cf-D_<var>db_name</var>-id_<var>db_id</var>.ctl' ; (ASM mount) ```
透過 sqlplus 掛載及開啟資料庫:
```sql sqlplus / as sysdba sql> alter database mount; sql> recover database until cancel; sql> alter database open resetlogs; ```
復原 Oracle 可插拔式資料庫
如要復原 Oracle 12c 以上版本的可插入式資料庫 (PDB),請按照下列步驟操作:
掛載來源資料庫伺服器的映像檔,以便復原。在「Mount」視窗中,為 RAC 節點 1 的 ASM 下方的映像檔掛載點提供偏好的磁碟群組。如要進一步瞭解如何掛載資料庫映像檔,請參閱「掛載在 ASM 磁碟群組下受保護的 Oracle 資料庫映像檔,以便存取資料」。
關閉可插入式資料庫:
從節點 1
su
傳送至 Oracle 使用者su - oracle
設定 Oracle 環境。以「sysdba」使用者身分連線至 Oracle 資料庫:
/ as sysdba alter pluggable database <var>pluggable_db_name</var> close;
將備份和 DR 已掛載的資料庫映像檔和封存記錄映像檔目錄到 RMAN:
run { catalog start with '+acttestdg/<var>db_name</var>/datafile' noprompt; catalog start with '+acttestdg/<var>db_name</var>/archivelog' noprompt; catalog start with '/acttestdg_Log' noprompt; }
還原及復原可插入式資料庫
run { restore pluggable database <var>pluggable_db_name</var>; recover pluggable database <var>pluggable_db_name</var> until time "to_date('<var>required time stamp</var>>';,';yyyymmddhh24mi')"; }
開啟可插入式資料庫:
alter pluggable database <var>pluggable_db_name</var> open;
可插入式資料庫可供讀取和寫入。
Oracle DBA 指南
- Oracle 資料庫的備份和災難復原
- 保護 Oracle 資料庫的先決條件
- Oracle 修補程式和已知問題
- 準備要保護的 Oracle 資料庫
- 探索及保護 Oracle 資料庫
- Oracle 資料庫的詳細資料和設定
- 在備份和災難復原服務中使用 dNFS
- 保護所偵測到的 Oracle 資料庫
- 將 Oracle 資料庫掛載為標準掛載點
- 建立 Oracle 資料庫的即時虛擬副本
- 還原及復原 Oracle 資料庫
- 使用掛載和遷移功能立即復原 Oracle 資料庫
- 透過備份和災難復原工作流程佈建環境