如何重建Oracle DataGuard

來源:互聯網
上載者:User

無暇每日檢查Oracle資料庫的同布情況,後來才發現主庫壓根沒有同步歸檔日誌到備庫,因為備庫斷電後一直沒有開,但問題是主庫在10幾天前刪除過歸檔日誌,慘!為了想節省時間,想去備份撈撈看,結果是備份也沒有需要的歸檔日誌。無耐,只好重建。

1、登入主庫備份控制檔案到資料檔案所在的目錄。
1.1先查詢資料檔案所在的目錄:select name from v$datafile
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/ora/oracle/oradata/tsing/system01.dbf
/ora/oracle/oradata/tsing/undotbs01.dbf
/ora/oracle/oradata/tsing/sysaux01.dbf
/ora/oracle/oradata/tsing/users01.dbf
/ora/oracle/oradata/tsing/mast.dbf
/ora/oracle/oradata/tsing/mas.dbf
6 rows selected.

1.2 備份控制檔案到資料檔案所在的目錄
SQL> alter database create standby controlfile as '/ora/oracle/oradata/tsing/node1.ctl';
Database altered.


2、登入備庫刪除資料檔案
2.1關閉備庫執行個體
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

2.2進入資料檔案所在的目錄,然後刪除
cd /ora/oracle/oradata/tsing/
[oracle@TAIXIN-HR1 tsing]$ ls
control01.ctl  mast.dbf    redo03.log    stdREDO04.LOG  undotbs01.dbf
control02.ctl  orapwtsing  stdREDO01.LOG  sysaux01.dbf  users01.dbf
control03.ctl  redo01.log  stdREDO02.LOG  system01.dbf
mas.dbf        redo02.log  stdREDO03.LOG  temp01.dbf
[oracle@TAIXIN-HR1 tsing]$ rm -f *

3、從主庫用SCP命令將資料檔案及控制檔案傳到備庫
scp -r /ora/oracle/oradata/tsing/* oracle@TAIXIN-HR1:/ora/oracle/oradata/tsing/
oracle@taixin-hr1's password:
control01.ctl                                100% 7088KB  6.9MB/s  00:00
control02.ctl                                100% 7088KB  6.9MB/s  00:00
control03.ctl                                100% 7088KB  6.9MB/s  00:01
inittsing.ora                                100% 1407    1.4KB/s  00:00
mas.dbf                                      100%  16GB  25.5MB/s  10:30
mast.dbf                                      100%  136MB  22.7MB/s  00:06
node1.ctl                                    100% 7088KB  6.9MB/s  00:00
orapwtsing                                    100% 1536    1.5KB/s  00:00
redo01.log                                    100%  50MB  25.0MB/s  00:02
redo02.log                                    100%  50MB  25.0MB/s  00:02
redo03.log                                    100%  50MB  25.0MB/s  00:02
sqlnet.log                                    100%  668    0.7KB/s  00:00
stdREDO01.LOG                                100%  50MB  16.7MB/s  00:03
stdREDO02.LOG                                100%  50MB  50.0MB/s  00:01
stdREDO03.LOG                                100%  50MB  50.0MB/s  00:01
stdREDO04.LOG                                100%  50MB  25.0MB/s  00:02
sysaux01.dbf                                  100%  490MB  18.9MB/s  00:26
system01.dbf                                  100%  520MB  21.7MB/s  00:24
temp01.dbf                                    100%  20MB  20.0MB/s  00:01
tsing1.ctl                                    100% 6928KB  6.8MB/s  00:01
undotbs01.dbf                                100%  115MB  23.0MB/s  00:05
users01.dbf                                  100% 5128KB  5.0MB/s  00:00
[oracle@TAIXIN-HR tsing]$

4、重新命名剛傳到備庫的控制檔案
4.1先刪除目錄下原有的三個控制檔案
[oracle@TAIXIN-HR1 tsing]$ ls
control01.ctl  mast.dbf    redo03.log    stdREDO04.LOG  undotbs01.dbf
control02.ctl  node1.ctl  sqlnet.log    sysaux01.dbf  users01.dbf
control03.ctl  orapwtsing  stdREDO01.LOG  system01.dbf
inittsing.ora  redo01.log  stdREDO02.LOG  temp01.dbf
mas.dbf        redo02.log  stdREDO03.LOG  tsing1.ctl
[oracle@TAIXIN-HR1 tsing]$ rm contro*
[oracle@TAIXIN-HR1 tsing]$ ls
inittsing.ora  orapwtsing  sqlnet.log    stdREDO04.LOG  tsing1.ctl
mas.dbf        redo01.log  stdREDO01.LOG  sysaux01.dbf  undotbs01.dbf
mast.dbf      redo02.log  stdREDO02.LOG  system01.dbf  users01.dbf
node1.ctl      redo03.log  stdREDO03.LOG  temp01.dbf


4.2 將node1.ctl的控制檔案重新命名成三個控制檔案
[oracle@TAIXIN-HR1 tsing]$ mv node1.ctl control01.ctl
[oracle@TAIXIN-HR1 tsing]$ cp control01.ctl control02.ctl
[oracle@TAIXIN-HR1 tsing]$ cp control02.ctl control03.ctl
[oracle@TAIXIN-HR1 tsing]$ ls
control01.ctl  mast.dbf    sqlnet.log    sysaux01.dbf  users01.dbf
control02.ctl  orapwtsing  stdREDO01.LOG  system01.dbf
control03.ctl  redo01.log  stdREDO02.LOG  temp01.dbf
inittsing.ora  redo02.log  stdREDO03.LOG  tsing1.ctl
mas.dbf        redo03.log  stdREDO04.LOG  undotbs01.dbf

5、串連備庫,並按如下操作
sqlplus / as sysdba
SQL>startup nomount
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;

6、測試重建是否成功(主庫切換日誌後查看備庫是否應用日誌)
在主庫上執行
SQL>alter system switch logfile;
在從庫上
SQL>select sequence#,applied from v$archived_log;

推薦閱讀:

使用RMAN的Duplicate功能建立物理DataGuard

Oracle基礎教程之通過RMAN複製資料庫

RMAN備份策略制定參考內容

RMAN備份學習筆記

OracleDatabase Backup加密 RMAN加密

通過RMAN備份duplicate建立DataGuard

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.