Oracle資料庫的冷備及完全恢複

來源:互聯網
上載者:User

實驗環境:CentOS5.0+Oracle11gR2.0

實驗目的:練習Oracle資料庫在NOACRHIVE模式下的冷備及complete Recovery。原檔案的位置:/u01/oradata/denver,恢複到/u01/oradata/md目錄中

實驗步驟:

第一步:將資料庫設定為noarchivelog模式,並進行冷備

[sql]
  1. sys@DENVER> startup mount  
  2. ORACLE instance started.  
  3.   
  4. Total System Global Area  422670336 bytes  
  5. Fixed Size                  1336960 bytes  
  6. Variable Size             314575232 bytes  
  7. Database Buffers          100663296 bytes  
  8. Redo Buffers                6094848 bytes  
  9. Database mounted.  
  10.   
  11. sys@DENVER> alter database noarchivelog  
  12.   2  /  
  13.   
  14. Database altered.  
  15.   
  16. sys@DENVER> archive log list  
  17. Database log mode              No Archive Mode  
  18. Automatic archival             Disabled  
  19. Archive destination            /u01/admin/denver/archdest  
  20. Oldest online log sequence     1  
  21. Current log sequence           1  
  22. sys@DENVER> alter database open;  
  23.   
  24. Database altered.  
  25.   
  26. sys@DENVER> @coldbackup  
coldbackup.sql指令碼內容如下:

[sql]
  1. [oracle@oracle11gR2 ~]$ more coldbackup.sql   
  2. Remark Set SQL*Plus variables to manipulate output  
  3. set feedback off heading off verify off trimspool off  
  4. set pagesize 0 linesize 200  
  5.   
  6. Remark set SQL*Plus user variable used in this script  
  7. define dir='/tmp/backup/cold/'  
  8. define fil='/tmp/closed_backup_commands.sql'  
  9. prompt *** Spooling to &fil  
  10.   
  11. Remark Create a command file with file backup commands  
  12. spool &fil  
  13. select 'host cp '|| name ||' &dir' from v$datafile order by 1;  
  14. select 'host cp '|| member ||' &dir' from v$logfile order by 1;  
  15. select 'host cp '|| name ||' &dir' from v$controlfile order by 1;  
  16. select 'host cp '|| name ||' &dir' from v$tempfile order by 1;  
  17. select 'host cp '|| destination ||'/* &dir' from v$archive_dest where dest_id=1;  
  18. spool off;  
  19.   
  20. Remark Shutdown the database cleanly  
  21. shutdown immediate;  
  22.   
  23. Rmemark Run the copy file commands from the operating system  
  24. @&fil  
  25.   
  26. Remark Start the database again  
  27. Startup;  

第二步:類比磁碟損壞:

remove data file、control file and redo file 

[sql]
  1. [oracle@oracle11gR2 ~]$ cd /u01/oradata/denver  
  2. [oracle@oracle11gR2 denver]$ rm -f *  
第三步:在資料庫關閉的情況下,將備份檔案restore到md目錄下

[sql]
  1. [oracle@oracle11gR2 denver]$ cd /u01/oradata/md  
  2. [oracle@oracle11gR2 md]$ cp /tmp/backup/cold/* .  
  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.