實驗環境:CentOS5.0+Oracle11gR2.0
實驗目的:練習Oracle資料庫在NOACRHIVE模式下的冷備及complete Recovery。原檔案的位置:/u01/oradata/denver,恢複到/u01/oradata/md目錄中
實驗步驟:
第一步:將資料庫設定為noarchivelog模式,並進行冷備
[sql]
- sys@DENVER> startup mount
- ORACLE instance started.
-
- Total System Global Area 422670336 bytes
- Fixed Size 1336960 bytes
- Variable Size 314575232 bytes
- Database Buffers 100663296 bytes
- Redo Buffers 6094848 bytes
- Database mounted.
-
- sys@DENVER> alter database noarchivelog
- 2 /
-
- Database altered.
-
- sys@DENVER> archive log list
- Database log mode No Archive Mode
- Automatic archival Disabled
- Archive destination /u01/admin/denver/archdest
- Oldest online log sequence 1
- Current log sequence 1
- sys@DENVER> alter database open;
-
- Database altered.
-
- sys@DENVER> @coldbackup
coldbackup.sql指令碼內容如下:
[sql]
- [oracle@oracle11gR2 ~]$ more coldbackup.sql
- Remark Set SQL*Plus variables to manipulate output
- set feedback off heading off verify off trimspool off
- set pagesize 0 linesize 200
-
- Remark set SQL*Plus user variable used in this script
- define dir='/tmp/backup/cold/'
- define fil='/tmp/closed_backup_commands.sql'
- prompt *** Spooling to &fil
-
- Remark Create a command file with file backup commands
- spool &fil
- select 'host cp '|| name ||' &dir' from v$datafile order by 1;
- select 'host cp '|| member ||' &dir' from v$logfile order by 1;
- select 'host cp '|| name ||' &dir' from v$controlfile order by 1;
- select 'host cp '|| name ||' &dir' from v$tempfile order by 1;
- select 'host cp '|| destination ||'/* &dir' from v$archive_dest where dest_id=1;
- spool off;
-
- Remark Shutdown the database cleanly
- shutdown immediate;
-
- Rmemark Run the copy file commands from the operating system
- @&fil
-
- Remark Start the database again
- Startup;
第二步:類比磁碟損壞:
remove data file、control file and redo file
[sql]
- [oracle@oracle11gR2 ~]$ cd /u01/oradata/denver
- [oracle@oracle11gR2 denver]$ rm -f *
第三步:在資料庫關閉的情況下,將備份檔案restore到md目錄下
[sql]
- [oracle@oracle11gR2 denver]$ cd /u01/oradata/md
- [oracle@oracle11gR2 md]$ cp /tmp/backup/cold/* .