冷備:,即關(guān)閉數(shù)據(jù)庫備份,要求備份數(shù)據(jù)庫三大文件(數(shù)據(jù)文件、控制文件、日志文件)及參數(shù)文件、口令文件;同時冷備之前要一致性關(guān)庫,以觸發(fā)ckpt實現(xiàn)三大文件一致性,以使恢復(fù)數(shù)據(jù)庫是不需要recover;
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了公主嶺免費建站歡迎大家使用!
1.查看備份文件絕對路徑(重要)
SYS@ORA11GR2>selectname fromv$datafile;
NAME
--------------------------------------------------------/u01/app/oracle/oradata/ORA11GR2/system01.dbf
/u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf
/u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf
/u01/app/oracle/oradata/ORA11GR2/users01.dbf
/u01/app/oracle/oradata/ORA11GR2/example01.dbf
/u01/app/oracle/oradata/ORA11GR2/ts_ora11gr2_01.dbf
/u01/app/oracle/oradata/ORA11GR2/undotbs2_01.dbf
7 rows selected.
SYS@ORA11GR2>selectname fromv$controlfile;
NAME
--------------------------------------------------------
/u01/app/oracle/oradata/ORA11GR2/control01.ctl
/u01/app/oracle/oradata/ORA11GR2/control02.ctl
/u01/app/FRA/control03.ctl
SYS@ORA11GR2>
SYS@ORA11GR2>selectmember fromv$logfile;
MEMBER
--------------------------------------------------------
/u01/app/oracle/oradata/ORA11GR2/redo03.log
/u01/app/oracle/oradata/ORA11GR2/redo02.log
/u01/app/oracle/oradata/ORA11GR2/redo01.log
/u01/app/oracle/oradata/ORA11GR2/redo01_a.log
/u01/app/oracle/oradata/ORA11GR2/redo02_a.log
/u01/app/oracle/oradata/ORA11GR2/redo03_a.log
/u01/app/FRA/redo01_b.log
/u01/app/FRA/redo02_b.log
/u01/app/FRA/redo03_b.log
9 rows selected.
SYS@ORA11GR2>
2.一致性關(guān)閉數(shù)據(jù)庫:(觸發(fā)CKPT,然后實施備份)
SYS@ORA11GR2>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ORA11GR2>
3.回到操作系統(tǒng)層復(fù)制鏡像(所有數(shù)據(jù)庫文件)
——創(chuàng)建備份目錄:
[oracle@wang ~]$ mkdir cold
[oracle@wang ~]$ ls
cold
[oracle@wang ~]$ cd cold/
[oracle@wang cold]$ ls
[oracle@wang cold]$
[oracle@wang cold]$ pwd
/home/oracle/cold
——備份控制文件、數(shù)據(jù)文件、redo日志到備份目錄:
[oracle@wang ~]$ cd /u01/app/oracle/oradata/
ORA11GR2/ PROD/
[oracle@wang ~]$ cd /u01/app/oracle/oradata/
[oracle@wang oradata]$
[oracle@wang oradata]$ cd ORA11GR2
[oracle@wang ORA11GR2]$ ls
control01.ctl redo02.log ts_ora11gr2_01.dbf
control02.ctl redo03_a.log undotbs01.dbf
example01.dbf redo03.log undotbs2_01.dbf
redo01_a.log sysaux01.dbf users01.dbf
redo01.log system01.dbf
redo02_a.log temp01.dbf
[oracle@wang ORA11GR2]$ pwd
/u01/app/oracle/oradata/ORA11GR2
[oracle@wang ORA11GR2]$ cp * /home/oracle/cold/
[oracle@wang ORA11GR2]$
成功,驗證:
[oracle@wang cold]$ du -sh
2.3G .
[oracle@wang cold]$ ll
total 2383092
-rw-r----- 1 oracle oinstall 9748480 Sep 27 15:12control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Sep 27 15:12control02.ctl
-rw-r----- 1 oracle oinstall 363077632 Sep 27 15:12 example01.dbf
-rw-r----- 1 oracle oinstall 52429312 Sep 27 15:12redo01_a.log
-rw-r----- 1 oracle oinstall 52429312 Sep 27 15:12redo01.log
-rw-r----- 1 oracle oinstall 52429312 Sep 27 15:12 redo02_a.log
-rw-r----- 1 oracle oinstall 52429312 Sep 27 15:12 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Sep 27 15:12 redo03_a.log
-rw-r----- 1 oracle oinstall 52429312 Sep 27 15:12 redo03.log
-rw-r----- 1 oracle oinstall 660611072 Sep 27 15:12 sysaux01.dbf
-rw-r----- 1 oracle oinstall 849354752 Sep 27 15:12 system01.dbf
-rw-r----- 1 oracle oinstall 51388416 Sep 27 15:12 temp01.dbf
-rw-r----- 1 oracle oinstall 20979712 Sep 27 15:12 ts_ora11gr2_01.dbf
-rw-r----- 1 oracle oinstall 94380032 Sep 27 15:12 undotbs01.dbf
-rw-r----- 1 oracle oinstall 104865792 Sep 27 15:12 undotbs2_01.dbf
-rw-r----- 1 oracle oinstall 6561792 Sep 27 15:12 users01.dbf
[oracle@wang cold]$
——備份參數(shù)文件及口令文件:
[oracle@wang ORA11GR2]$ cd $ORACLE_HOME/dbs
[oracle@wang dbs]$ cp initORA11GR2.ora spfileORA11GR2.ora /home/oracle/cold/
[oracle@wang dbs]$
[oracle@wang dbs]$ cp orapwORA11GR2 /home/oracle/cold/
驗證:
[oracle@wang cold]$ ls initORA11GR2.ora
initORA11GR2.ora
[oracle@wang cold]$ ls spfileORA11GR2.ora
spfileORA11GR2.ora
[oracle@wang cold]$ ls orapwORA11GR2
orapwORA11GR2
4.模擬刪除$ORACLE_HOME/dbs的參數(shù)文件及密碼文件,刪除$ORACLE_HOME/oradata/ORA11GR2/下的所有數(shù)據(jù)庫文件
[oracle@wang dbs]$ cd /u01/app/oracle/oradata/ORA11GR2/
[oracle@wang ORA11GR2]$ ls
control01.ctl example01.dbf redo01.log redo02.log redo03.log system01.dbf ts_ora11gr2_01.dbf undotbs2_01.dbf
control02.ctl redo01_a.log redo02_a.log redo03_a.log sysaux01.dbf temp01.dbf undotbs01.dbf users01.dbfv
[oracle@wang ORA11GR2]$rm *
[oracle@wang ORA11GR2]$ls
[oracle@wang ORA11GR2]$
5.啟動實例(nomount):
SYS@ORA11GR2>startup nomount;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initORA11GR2.ora'
SYS@ORA11GR2>
顯示沒有找到參數(shù)文件,恢復(fù)參數(shù)文件:
[oracle@wang cold]$ cp initORA11GR2.ora spfileORA11GR2.ora /u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@wang cold]$
再次啟動實例:
SYS@ORA11GR2>startup nomount;
ORACLE instance started.
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 457179200 bytes
Database Buffers 268435456 bytes
Redo Buffers 2842624 bytes
SYS@ORA11GR2>
——實例啟動
6.啟動到mount:
SYS@ORA11GR2>alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info
SYS@ORA11GR2>
恢復(fù)控制文件:
[oracle@wang cold]$ cp control01.ctl control02.ctl /u01/app/oracle/oradata/ORA11GR2/
[oracle@wang cold]$
[oracle@wang ORA11GR2]$ pwd
/u01/app/oracle/oradata/ORA11GR2
[oracle@wang ORA11GR2]$
[oracle@wang ORA11GR2]$ ls
control01.ctl control02.ctl
再次啟動到mount:
SYS@ORA11GR2>alter database mount;
Database altered.
SYS@ORA11GR2>
成功!
7.打開數(shù)據(jù)庫:
SYS@ORA11GR2>alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/ORA11GR2/system01.dbf'
——恢復(fù)數(shù)據(jù)文件及日志文件:
[oracle@wang cold]$ cp *dbf *log /u01/app/oracle/oradata/ORA11GR2/
[oracle@wang cold]$
[oracle@wang ORA11GR2]$ ls
control01.ctl example01.dbf redo01.log redo02.log redo03.log system01.dbf ts_ora11gr2_01.dbf undotbs2_01.dbf
control02.ctl redo01_a.log redo02_a.log redo03_a.log sysaux01.dbf temp01.dbf undotbs01.dbf users01.dbf
——再次打開數(shù)據(jù)庫:
SYS@ORA11GR2>alter database open;
Database altered.
SYS@ORA11GR2>select status from v$instance;
STATUS
------------
OPEN
SYS@ORA11GR2>
數(shù)據(jù)庫已打開,恢復(fù)成功!?。。。。。。?!
(數(shù)據(jù)庫已從冷備恢復(fù)回來,不需要recovery,因為冷備是在一致性關(guān)閉數(shù)據(jù)庫的基礎(chǔ)上實施的,數(shù)據(jù)庫已處于一致狀態(tài))