<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 71  文章 - 15  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    因為口渴,上帝創(chuàng)造了水;
    因為黑暗,上帝創(chuàng)造了火;
    因為我需要朋友,所以上帝讓你來到我身邊
    Click for Shaanxi xi'an, Shaanxi Forecast
    ╱◥█◣
      |田|田|
    ╬╬╬╬╬╬╬╬╬╬╬
    If only I have such a house!
    〖總在爬山 所以艱辛〗
    Email:myesjoy@yahoo.com.cn
    NickName:yesjoy
    MSN:myesjoy@hotmail.com
    QQ:150230516

    〖總在尋夢 所以苦痛〗

    常用鏈接

    留言簿(3)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    Hibernate在線

    Java友情

    Java認證

    linux經(jīng)典

    OA系統(tǒng)

    Spring在線

    Structs在線

    專家專欄

    企業(yè)信息化

    大型設(shè)備共享系統(tǒng)

    工作流

    工作流產(chǎn)品

    網(wǎng)上購書

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

     

    Oracle數(shù)據(jù)庫的備份與恢復(fù)方案

    出處:互聯(lián)網(wǎng)

      數(shù)據(jù)庫的備份和恢復(fù)是指為保護一個數(shù)據(jù)庫免于數(shù)據(jù)損失或者在發(fā)生數(shù)據(jù)損失后進行數(shù)據(jù)重新創(chuàng)建的各種策略和步驟、方法。數(shù)據(jù)備份幾乎是任何計算機系統(tǒng)中絕對必需的組成部分。意外斷電、系統(tǒng)或服務(wù)器崩潰、用戶失誤、磁盤損壞甚至數(shù)據(jù)中心的災(zāi)難性丟失都可能造成數(shù)據(jù)庫文件的破壞或丟失。而這些文件往往包含著珍貴的數(shù)據(jù),經(jīng)不得任何損失。數(shù)據(jù)庫管理員必須對此有所準備。在這種情況下,備份與恢復(fù)占了舉足輕重的位置。

     

    1.1 如何啟動ARCHIVELOG模式?

    系統(tǒng)環(huán)境:

    1、操作系統(tǒng):Windows 2000 Server,機器內(nèi)存128M

    2、數(shù)據(jù)庫: Oracle 8i R2 (8.1.6) for NT 企業(yè)版

    3、安裝路徑:C:ORACLE

    實現(xiàn)步驟:

    1、管理器

    SVRMGR> connect internal

    SVRMGR> shutdown

    SVRMGR> startup mount [dbname]

    SVRMGR> alter database [dbname] archivelog; --起用歸檔模式

    SVRMGR> archive log start --啟動自動歸檔模式,重起數(shù)據(jù)庫后,按init.ora配置

    SVRMGR> alter database [dbname] open; --打開數(shù)據(jù)庫

    SVRMGR> exit

    2、修改數(shù)據(jù)庫初始化參數(shù)文件,定義歸檔模式(自動)、歸檔日志文件保存路徑、歸檔日志文件命名方法

    3、重新啟動數(shù)據(jù)庫

    具體實例:

    C:>svrmgrl

    Oracle Server Manager Release 3.1.6.0.0 - Production

    版權(quán)所有 (c) 19971999Oracle Corporation。保留所有權(quán)利。

    Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production

    With the Partitioning option

    JServer Release 8.1.6.0.0 - Production

    SVRMGR> connect internal

    連接成功。

    SVRMGR> shutdown

    已關(guān)閉數(shù)據(jù)庫。

    已卸下數(shù)據(jù)庫。

    已關(guān)閉 ORACLE 實例。

    SVRMGR> startup mount

    已啟動 ORACLE 實例。

    系統(tǒng)全局區(qū)域合計有 57124108個字節(jié)

    Fixed Size 70924個字節(jié)

    Variable Size 40198144個字節(jié)

    Database Buffers 16777216個字節(jié)

    Redo Buffers 77824個字節(jié)

    已裝入數(shù)據(jù)庫。

    SVRMGR> alter database archivelog;

    語句已處理。

    SVRMGR> archive log start

    語句已處理。

    SVRMGR> alter database open;

    語句已處理。

    SVRMGR> alter system switch logfile; --強制系統(tǒng)進行日志切換,可馬上觀察到歸檔日志的產(chǎn)生語句已處理。

    SVRMGR> exit

    服務(wù)器管理程序結(jié)束。

    修改數(shù)據(jù)庫參數(shù)文件c:oracleadminoradbpfileinit.ora

    取消以下語句的#注釋

    log_archive_start = true

    log_archive_dest_1 = "location=C:Oracleoradataoradbarchive"

    log_archive_format = %%ORACLE_SID%%T%TS%S.ARC

    關(guān)閉數(shù)據(jù)庫,重新啟動

    查看C:Oracleoradataoradbarchive目錄下,可以看到類似ORADBT001S01201.ARC的文件,說明歸檔成功

    解釋init.ora參數(shù)文件中關(guān)于歸檔重做日志參數(shù)項的含義:

    歸檔模式是自動還是手工,true為自動,false為手工

    log_archive_start = true

    歸檔日志文件所保存的路徑

    log_archive_dest_1 = "location=C:Oracleoradataoradbarchive"

    歸檔日志文件的命名方法

    log_archive_format = %%ORACLE_SID%%T%TS%S.ARC

    歸檔命令:

    啟動自動歸檔模式,系統(tǒng)重起后,將按init.ora中的參數(shù)log_archive_start的值設(shè)置歸檔方式

    SVRMGR> archive log start

    啟動手工歸檔模式

    SVRMGR> archive log stop

    查看歸檔信息:重做日志是否歸檔方式、是自動歸檔還是手工歸檔、歸檔路徑、最舊的聯(lián)機日志循序號...

    SVRMGR> archive log list

    歸檔一個已滿,但沒有歸檔的聯(lián)機重做日志

    SVRMGR> archive log next

    歸檔所有已滿,但沒有歸檔的聯(lián)機重做日志

    SVRMGR> archive log all

    注意:一個事務(wù)即使不被提交,也會被寫入到重做日志中

    1.2 如何使用歸檔日志進行完全恢復(fù)?

    系統(tǒng)環(huán)境:

    1、操作系統(tǒng):Windows 2000 Server,機器內(nèi)存128M

    2、數(shù)據(jù)庫: Oracle 8i R2 (8.1.6) for NT 企業(yè)版

    3、安裝路徑:C:ORACLE

    模擬現(xiàn)象:

    先將數(shù)據(jù)庫設(shè)置為歸檔模式

    SQL*Plus

    --創(chuàng)建實驗表空間

    create tablespace test datafile

    "c:test.ora" size 5M

    AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED

    default storage (initial 128K next 1M pctincrease 0)

    /

    --創(chuàng)建實驗用戶

    drop user test cascade;

    create user test identified by test default tablespace test;

    grant connect,resource to test;

    conn test/test

    create table a(a number);

    insert into a values(1);

    insert into a select * from a; --反復(fù)插入,達到10萬條

    commit;

    拷貝test.oratest1.ora文件

    insert into a select * from a; --20萬條

    commit;

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

    shutdown

    刪除test.ora文件,把test1.ora拷貝為test.ora

    重新啟動數(shù)據(jù)庫

    這時,可以mount上,但無法打開,因為現(xiàn)在使用的數(shù)據(jù)文件是舊的

    只有10萬條記錄,與控制文件中記載的log number不一樣

    startup mount

    需要recover database,使數(shù)據(jù)庫記錄重新恢復(fù)到當前的20萬條

    C:>svrmgrl

    svrmgrl>connect internal

    svrmgrl>shutdown

    svrmgrl>startup mount

    svrmgrl>set autorecovery on

    svrmgrl>recover database;

    svrmgrl>alter database open;

    conn test/test

    select count(*) from a; --數(shù)據(jù)又恢復(fù)到20萬條

    conn system/manager

    --刪除實驗表空間

    alter tablespace test offline;

    drop tablespace test INCLUDING CONTENTS;

    1.3 沒有備份、只有歸檔日志,如何恢復(fù)數(shù)據(jù)文件?

    系統(tǒng)環(huán)境:

    1、操作系統(tǒng):Windows 2000 Server,機器內(nèi)存128M

    2、數(shù)據(jù)庫: Oracle 8i R2 (8.1.6) for NT 企業(yè)版

    3、安裝路徑:C:ORACLE

    模擬現(xiàn)象:

    可通過重建數(shù)據(jù)文件來恢復(fù),前提是歸檔日志文件保存完整

    先將數(shù)據(jù)庫設(shè)置為歸檔模式

    SQL*Plus

    conn system/manager

    --創(chuàng)建實驗表空間

    create tablespace test datafile

    "c:test.ora" size 5M

    AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED

    default storage (initial 128K next 1M pctincrease 0)

    /

    --創(chuàng)建實驗用戶

    drop user test cascade;

    create user test identified by test default tablespace test;

    grant connect,resource to test;

    conn test/test

    create table a(a number);

    insert into a values(1);

    insert into a select * from a; --反復(fù)插入,達到100萬條

    commit;

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

    SVRMGR> connect internal

    SVRMGR> alter system switch logfile; --強制歸檔

    SVRMGR> alter system switch logfile;

    SVRMGR> alter system switch logfile;

    SVRMGR> shutdown

    --操作系統(tǒng)下刪除test.ora文件

    --重新啟動數(shù)據(jù)庫

    SVRMGR> connect internal

    SVRMGR> startup

    這時,可以mount上,但無法打開,因為數(shù)據(jù)文件test.ora不存在,

    顯示錯誤如下:

    ORA-01157: ????/?????? 8 - ??? DBWR ????

    ORA-01110: ???? 8: "C:TEST.ORA"

    SVRMGR> connect internal

    SVRMGR> startup mount

    SVRMGR> alter database create datafile "c:test.ora";

    SVRMGR> set autorecovery on

    SVRMGR> recover datafile "c:test.ora";

    SVRMGR> alter database open;

    conn test/test

    select count(*) from a; --數(shù)據(jù)又恢復(fù)到100萬條

    --刪除實驗表空間

    conn system/manager

    alter tablespace test offline;

    drop tablespace test INCLUDING CONTENTS;

    drop user test;

    如果是非歸檔模式,也可以運用以上方法,

    前提是:輸入記錄所占空間的大小不超過所有聯(lián)機日志文件的大小

    即:用聯(lián)機日志文件來恢復(fù)

    1.4 聯(lián)機熱備份失敗后,如何打開數(shù)據(jù)庫?

    系統(tǒng)環(huán)境:

    1、操作系統(tǒng):Windows 2000

    2、數(shù)據(jù)庫: Oracle 8i R2 (8.1.6) for NT 企業(yè)版

    3、安裝路徑:C:ORACLE

    錯誤現(xiàn)象:

    進行聯(lián)機熱備份時,服務(wù)器發(fā)生故障,如掉電,重新啟動服務(wù)器,

    啟動數(shù)據(jù)庫時,無法打開數(shù)據(jù)庫,Oracle要求進行介質(zhì)恢復(fù),

    因為表空間還處在熱備份狀態(tài)。

    模擬現(xiàn)象及解決方法:

    先將數(shù)據(jù)庫設(shè)置為歸檔模式

    C:>svrmgrl

    svrmgrl>connect internal

    svrmgrl>alter tablespace 表空間名 begin backup;

    --表空間熱備模式?jīng)]結(jié)束就強行關(guān)閉數(shù)據(jù)庫,造成錯誤

    svrmgrl>shutdown abort

    svrmgrl>startup mount

    --將此表空間的數(shù)據(jù)文件在沒打開數(shù)據(jù)庫時置成end backup模式

    svrmgrl>alter database datafile "表空間的數(shù)據(jù)文件名" end backup;

    --或執(zhí)行表空間介質(zhì)恢復(fù)

    svrmgrl>recover tablespace 表空間名;

    svrmgrl>alter database open;

    1.5 某個數(shù)據(jù)文件損壞,如何打開數(shù)據(jù)庫?

    系統(tǒng)環(huán)境:

    1、操作系統(tǒng):Windows 2000 Server,機器內(nèi)存128M

    2、數(shù)據(jù)庫: Oracle 8i R2 (8.1.6) for NT 企業(yè)版

    3、安裝路徑:C:ORACLE

    錯誤現(xiàn)象:

    因誤操作,數(shù)據(jù)庫中某一數(shù)據(jù)文件被誤刪,

    控制面板的Oracle相關(guān)服務(wù)顯示已啟動,但用SQL*Plus無法連接,

    顯示以下錯誤

    ORA-01033: ORACLE initialization or shutdown in progress

    模擬現(xiàn)象:

    create tablespace test datafile

    "c:test.ora" size 5M

    AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED

    default storage (initial 128K next 1M pctincrease 0)

    /

    關(guān)閉所有服務(wù)stop.bat

    net stop "OracleWebAssistant0"

    net stop "OracleOraHome81TNSListener"

    net stop "OracleServiceORADB"

    shutdown

    c

    在操作系統(tǒng)中刪除test.ora文件

    重新啟動服務(wù)start.bat

    net start "OracleWebAssistant0"

    net start "OracleOraHome81TNSListener"

    net start "OracleServiceORADB"

    服務(wù)里OracleServiceORADB顯示已啟動,但用SQL*Plus無法連接,

    顯示ORA-01033: ORACLE initialization or shutdown in progress

    解決方法:

    先讓該數(shù)據(jù)文件脫機,就可以打開數(shù)據(jù)庫

    C:>svrmgrl

    svrmgrl>connect internal

    svrmgrl>shutdown

    svrmgrl>startup mount

    d

    --ARCHIVELOG模式命令,文件名要大寫

    svrmgrl>alter database datafile "C:TEST.ORA" offline;

    --NOARCHIVELOG模式命令

    svrmgrl>alter database datafile "C:TEST.ORA" offline drop;

    svrmgrl>alter database open;

    --查詢數(shù)據(jù)文件聯(lián)、脫機狀態(tài)

    SQL> select file#,name,status from v$datafile;

    SQL> drop tablespace test;

    表空間已丟棄。

    _allow_resetlogs_corruption=true

    本文來自各大博客,版權(quán)歸原作者所有!
    文章信息如下:
    引用源博文網(wǎng)址:http://maxz.itpub.net/post/17787/188561
    發(fā)布日期:Tue, 08 08 2006 13:18:55
    返回首頁  注冊成為博客

    Copyright © 1990-2006

    posted on 2007-05-12 20:39 ★yesjoy★ 閱讀(1076) 評論(0)  編輯  收藏 所屬分類: 數(shù)據(jù)庫備份/恢復(fù)方案

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 精品免费久久久久久久| 久久久久久久岛国免费播放 | 免费国产怡红院在线观看| 亚洲国产系列一区二区三区| 性生交片免费无码看人| 亚洲另类小说图片| 亚洲午夜国产精品无码老牛影视| 2022年亚洲午夜一区二区福利| 久热免费在线视频| 亚洲国产美女视频| 性做久久久久久久免费看| 亚洲精品国产第一综合99久久| 国产乱色精品成人免费视频| 手机永久免费的AV在线电影网| 亚洲aⅴ无码专区在线观看| 天天摸夜夜摸成人免费视频| 久久久久噜噜噜亚洲熟女综合| 国产三级在线免费观看| 日韩精品无码区免费专区| 亚洲AV无码一区东京热久久 | 亚洲中字慕日产2021| 三年片在线观看免费观看高清电影| 亚洲熟妇无码八V在线播放| 性无码免费一区二区三区在线| 亚洲美女视频网址| 在线免费不卡视频| 国产精品免费久久久久影院| 久久久久亚洲Av片无码v| 中字幕视频在线永久在线观看免费| 亚洲av永久中文无码精品综合| 亚洲色一色噜一噜噜噜| 在线观看亚洲免费视频| 久久久久亚洲AV成人网人人网站| 特级精品毛片免费观看| 亚洲av无码专区在线电影| 国产精品亚洲αv天堂无码| 日本最新免费网站| 色老头综合免费视频| 亚洲日本香蕉视频观看视频| 免费A级毛片在线播放不收费| 三年片在线观看免费观看大全一|