免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Oracle備份與恢復(fù)案例(二)

第三章.了解與恢復(fù)相關(guān)的信息

 

1理解報警日志文件

報警日志文件一般記載了數(shù)據(jù)庫的啟動/關(guān)閉信息,歸檔信息,備份信息,恢復(fù)信息,常見錯誤信息,部分?jǐn)?shù)據(jù)庫修改記錄等。一般令名規(guī)則為<SID>Alrt.logAlrt<SID>.log,如我的測試數(shù)據(jù)庫的報警日志文件的名稱為testalrt.log。

 

報警日志文件的路徑是根據(jù)初始化參數(shù)background_dump_dest來決定的,如在我的機器上,該參數(shù)值為D:\Oracle\admin\test\bdump,那么,你就可以在該路徑下找到該文件。


2后臺進程跟蹤文件

后臺進程跟蹤文件的路徑與報警日志文件的路徑一致,在某些情況下,你可以通過后臺跟蹤文件的信息了解更多的需要恢復(fù)的信息。如在數(shù)據(jù)庫需要恢復(fù)的時候,報警日志文件中常有這樣的語句:


Errors in file D:\Oracle\admin\test\bdump\testDBW0.TRC:

ORA-01157: cannot identify/lock data file 1 - see DBWR trace file

通過提示的DBWR跟蹤文件,可以查詢到更詳細(xì)的信息。


3
、v$recover_filev$recovery_log

這是兩個動態(tài)性能視圖,可以在mount下查看,通過這兩個視圖,你可以了解詳細(xì)的需要恢復(fù)的數(shù)據(jù)文件與需要使用到的歸檔日志。


第四章.數(shù)據(jù)庫恢復(fù)案例


4.1
非歸檔模式下的備份與恢復(fù)


備份方案:采用OS冷備份

 

1.連接數(shù)據(jù)庫并創(chuàng)建測試表

SQL> connect internal/password as sysdba;

Connected.

SQL> create table test(a int);

Table created

SQL> insert into test values(1);

1 row inserted

SQL> commit;

Commit complete

 

2.備份數(shù)據(jù)庫

SQL> @coldbak.sql或在DOSsvrmgrl @coldbak.sql

 

3.再插入記錄

SQL> insert into test values(2);

1 row inserted

SQL> commit;

Commit complete

SQL> select * from test;

                        A

-------------------

                        1

                        2

4.關(guān)閉數(shù)據(jù)庫

SQL> shutdown immediate;

Database closed.

Database dismounted.

Oracle instance shut down.

 

5.毀壞一個或多個數(shù)據(jù)文件,如刪除user01.dbf

C:\>del D:\Oracle\ORADATA\TEST\USERS01.DBF

模擬媒體毀壞。

 

6.重新啟動數(shù)據(jù)庫,會發(fā)現(xiàn)如下錯誤

SQL> startup

Oracle instance started.

 

Total System Global Area 102020364 bytes

Fixed Size                   70924 bytes

Variable Size             85487616 bytes

Database Buffers          16384000 bytes

Redo Buffers                 77824 bytes

Database mounted.

ORA-01157:cannot identify/lock data file 3 - see DBWR trace file

ORA-01110:data file 3: 'D:\Oracle\ORADATA\TEST\USERS01.DBF'

 

在報警文件中,會有更詳細(xì)的信息

Errors in file D:\Oracle\admin\test\bdump\testDBW0.TRC:

ORA-01157: cannot identify/lock data file 3 - see DBWR trace file

ORA-01110: data file 3: 'D:\Oracle\ORADATA\TEST\USERS01.DBF'

ORA-27041: unable to open file

OSD-04002: unable to open file

O/S-Error: (OS 2)系統(tǒng)找不到指定的文件。

 

7.拷貝備份復(fù)原到原來位置(restore過程)

C:\>xcopy d:\database\*.* d:\Oracle\oradata\test/H/R/S

 

8.打開數(shù)據(jù)庫,檢查數(shù)據(jù)

SQL> alter database open;

Database altered.

SQL> select * from test;

                        A

---------------------------------------

                        1

 

這里可以發(fā)現(xiàn),數(shù)據(jù)庫恢復(fù)成功,但在備份之后與崩潰之前的數(shù)據(jù)丟失了。


說明:

1、非歸檔模式下的恢復(fù)方案可選性很小,一般情況下只能有一種恢復(fù)方式,就是數(shù)據(jù)庫的冷備
份的完全恢復(fù),僅僅需要拷貝原來的備份就可以(restore),不需要recover

2、這種情況下的恢復(fù),可以完全恢復(fù)到備份的點上,但是可能是丟失數(shù)據(jù)的,在備份之后與崩潰之前的數(shù)據(jù)將全部丟失;

3、不管毀壞了多少數(shù)據(jù)文件或是聯(lián)機日志或是控制文件,都可以通過這個辦法恢復(fù),因為這個恢復(fù)過程是Restore所有的冷備份文件,而這個備份點上的所有文件是一致的,與最新的數(shù)據(jù)庫沒有關(guān)系,就好比把數(shù)據(jù)庫又放到了一個以前的""上;

4、對于非歸檔模式下,最好的辦法就是采用OS的冷備份,建議不要用RMAN來作冷備份,效果不好,因為RMAN不備份聯(lián)機日志,restore不能根本解決問題;

5、如果沒有備份聯(lián)機日志,如RMAN的備份,就需要利用不完全恢復(fù)(until cancel)的方法來重新創(chuàng)建聯(lián)機日志文件。


4.2歸檔模式下丟失或損壞一個數(shù)據(jù)文件


4.2.1OS備份方案

在歸檔方式下?lián)p壞或丟失一個數(shù)據(jù)文件,如果存在相應(yīng)的備份與該備份以來的歸檔日志,恢復(fù)還是比較簡單的,可以作到盡量少的Down機時間,并能作到數(shù)據(jù)庫的完全恢復(fù)。


1、 連接數(shù)據(jù)庫,創(chuàng)建測試表并插入記錄

SQL> connect internal/password as sysdba;

Connected.

SQL> create table test(a int) tablespace users;

Table created

SQL> insert into test values(1);

1 row inserted

SQL> commit;

Commit complete

 

2、 備份數(shù)據(jù)庫

SQL> @hotbak.sql或在DOSsvrmgrl @hotbak.sql

 

3 繼續(xù)在測試表中插入記錄

SQL> insert into test values(2);

1 row inserted

SQL> commit;

Commit complete

SQL> select * from test;

                        A

  --------------------------------------

                        1

                        2

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

 

4、 關(guān)閉數(shù)據(jù)庫,模擬丟失數(shù)據(jù)文件

SQL> shutdown immediate;

Database closed.

Database dismounted.

Oracle instance shut down

C:\>del D:\Oracle\ORADATA\TEST\USERS01.DBF

模擬媒體毀壞。

 

5、 啟動數(shù)據(jù)庫錯誤,脫機該數(shù)據(jù)文件:

SQL> startup

Oracle instance started.

 

Total System Global Area 102020364 bytes

Fixed Size                   70924 bytes

Variable Size             85487616 bytes

Database Buffers          16384000 bytes

Redo Buffers                 77824 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 3 - see DBWR trace file

ORA-01110: data file 3: 'D:\Oracle\ORADATA\TEST\USERS01.DBF'


還可以查看報警文件(見上一個恢復(fù)案例)或動態(tài)視圖v$recover_file

SQL> select * from v$recover_file;

 

    FILE# ONLINE ERROR                CHANGE#    TIME

---------- ------- ------------------ ---------- -----------

        3ONLINE                        1013500 2003-05-07

 

脫機數(shù)據(jù)文件

SQL> alter database datafile 3 offline drop;

Database altered.

 

6、 打開數(shù)據(jù)庫,拷貝備份回來(restore),恢復(fù)(recover)該數(shù)據(jù)文件,并聯(lián)機:


SQL> alter database open;

Database altered.


拷貝備份從備份處

copy d:\databak\ users01.dbf d:\Oracle\oradata\test;


恢復(fù)該數(shù)據(jù)文件

SQL> recover datafile 3;


ORA-00279: change 1053698 generated at 05/07/2003 17:51:26 needed for

thread 1

ORA-00289: suggestion :
D:\Oracle\ORADATA\TEST\ARCHIVE\TESTT001S00304.ARC

ORA-00280: change 1053698 for thread 1 is in sequence #304

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

AUTO

ORA-00279: change 1053701 generated at 05/07/2003 17:51:39 needed for

thread 1

ORA-00289: suggestion : D:\Oracle\ORADATA\TEST\ARCHIVE\TESTT001S00305.ARC

ORA-00280: change 1053701 for thread 1 is in sequence #305

ORA-00278: log file 'D:\Oracle\ORADATA\TEST\ARCHIVE\TESTT001S00304.ARC' no longer needed for this recovery Log applied.

Media recovery complete.


恢復(fù)成功,聯(lián)機該數(shù)據(jù)文件

SQL> alter database datafile 3 online;

Database altered.

 

7、 檢查數(shù)據(jù)庫的數(shù)據(jù)(完全恢復(fù))

SQL> select * from test;

                        A

--------------------------------

                        1

                        2

說明:

1、采用熱備份,需要運行在歸檔模式下,可以實現(xiàn)數(shù)據(jù)庫的完全恢復(fù),也就是說,從備份后到數(shù)據(jù)庫崩潰時的數(shù)據(jù)都不會丟失;

2、可以采用全備份數(shù)據(jù)庫的方式備份,對于特殊情況,也可以只備份特定的數(shù)據(jù)文件,如只備份用戶表空間(一般情況下對于某些寫特別頻繁的數(shù)據(jù)文件,可以單獨加大備份頻率);

3、如果在恢復(fù)過程中,發(fā)現(xiàn)損壞的是多個數(shù)據(jù)文件,即可以采用一個一個數(shù)據(jù)文件的恢復(fù)方法(第5步中需要對數(shù)據(jù)文件一一脫機,第6步中需要對數(shù)據(jù)文件分別恢復(fù)),也可以采用整個數(shù)據(jù)庫的恢復(fù)方法;

4、如果是系統(tǒng)表空間的損壞,不能采用此方法。

 

4.2.2RMAN備份方案


RMAN也可以進行聯(lián)機備份,而且備份與恢復(fù)方法將比OS備份更簡單可靠。

1、連接數(shù)據(jù)庫,創(chuàng)建測試表并插入記錄

SQL> connect internal/password as sysdba;

Connected.

 

SQL> create table test(a int) tablespace users;

Table created

SQL> insert into test values(1);

1 row inserted

SQL> commit;

Commit complete

 

2、 備份數(shù)據(jù)庫表空間users

C:\>rman

Recovery Manager: Release8.1.6.0.0 - Production

RMAN> connect rcvcat rman/rman@back

RMAN-06008: connected to recovery catalog database

RMAN> connect target internal/virpure

RMAN-06005: connected to target database: TEST (DBID=1788174720)

 

RMAN> run{

2> allocate channel c1 type disk;

3> backup tag 'tsuser' format 'd:\backup\tsuser_%u_%s_%p'

4> tablespace users;

5> release channel c1;

6> }

 

RMAN-03022: compiling command: allocate

RMAN-03023: executing command: allocate

RMAN-08030: allocated channel: c1

RMAN-08500: channel c1: sid=16 devtype=DISK

 

RMAN-03022: compiling command: backup

RMAN-03025: performing implicit partial resync of recovery catalog

RMAN-03023: executing command: partial resync

RMAN-08003: starting partial resync of recovery catalog

RMAN-08005: partial resync complete

RMAN-03023: executing command: backup

RMAN-08008: channel c1: starting full datafile backupset

RMAN-08502: set_count=5 set_stamp=494177612 creation_time=16-MAY-03

RMAN-08010: channel c1: specifying datafile(s) in backupset

RMAN-08522: input datafile fno=00003 name=D:\Oracle\ORADATA\TEST\USER01.DBF

RMAN-08013: channel c1: piece 1 created

RMAN-08503: piece handle=D:\BACKUP\TSUSER_05EN93AC_5_1 comment=NONE

RMAN-08525: backup set complete, elapsed time: 00:00:01

RMAN-03023: executing command: partial resync

RMAN-08003: starting partial resync of recovery catalog

RMAN-08005: partial resync complete

RMAN-03022: compiling command: release

RMAN-03023: executing command: release

RMAN-08031: released channel: c1

RMAN>

 

3、 繼續(xù)在測試表中插入記錄

SQL> insert into test values(2);

1 row inserted

SQL> commit;

Commit complete

SQL> select * from test;

                        A

---------------------------------------

                        1

                        2

SQL> alter system switch logfile;

System altered.

SQL>r

1* alter system switch logfile;

System altered.

 

4、 關(guān)閉數(shù)據(jù)庫,模擬丟失數(shù)據(jù)文件
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Oracle備份與恢復(fù)案例
RMAN 系列(六) ---- RMAN 高級恢復(fù) 8
如何獲得數(shù)據(jù)庫的DBID
Oracle Database 10 g : 為 DBA 提供的最佳前 20 位的特性(九)
Oracle備份/恢復(fù)案例03
LINUX下Oracle for NBU實驗手冊
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服