oracle rman 备份与还原
生活随笔
收集整理的這篇文章主要介紹了
oracle rman 备份与还原
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
restore: 還原(文件級恢復),與backup相對,從備份讀出恢復備份的數據。
recover: 恢復(數據級恢復),指在數據文件成功還原之后,使用歸檔日志和在線重做日志對數據文件進行恢復,主要前滾與回滾兩個動作。最常見的就是實例恢復。
完備腳本
#!/bin/bashexport ORACLE_SID=db3 export ORACLE_BASE=/u01/oracle export ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1$ORACLE_HOME/bin/rman target / << EOF run{ allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; allocate channel c4 type disk; allocate channel c5 type disk; crosscheck archivelog all;backup as compressed backupset database format '/dbbackup/full_dbbackup_%T_%d_%U';sql 'alter system archive log current'; backup as compressed backupset filesperset 10 format '/dbbackup/Arch_%d_%T_%s.bak' archivelog all;delete noprompt obsolete; release channel c1; release channel c2; release channel c3; release channel c4; release channel c5; } EOF差異備份腳本
#!/bin/bashexport ORACLE_SID=sqmesdb3 export ORACLE_BASE=/u01/oracle export ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1pscnt=`ps -ef | grep rman | grep -v grep | wc -l` echo "archivebackupprocesscount:$pscnt" if [ $pscnt -gt 0 ];thenecho "`date`exitarchivelogbackup!"exit 0 else$ORACLE_HOME/bin/rman target / << EOFrun{ # backup as compressed backupset archivelog all format '/dbbackup/archivelog_backup_%T_%d_%U' not backed up 2 times;# backup as compressed backupset archivelog all format '/dbbackup/archivelog_backup_%T_%d_%U';delete noprompt archivelog all completed before 'sysdate-7';} EOF fi還原control文件
最好還原完備的control file
異機還原腳本
catalog start with '/dbbackup/'; # 指定日志路徑 run{ allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; allocate channel c4 type disk; allocate channel c5 type disk; RESTORE DATABASE ; #recover database using backup controlfile until cancel; recover database until time "to_date('2022-01-27 20:40:00','yyyy-mm-dd hh24:mi:ss')"; release channel c1; release channel c2; release channel c3; release channel c4; release channel c5; }如果recover失敗
可能失敗, 因為archive log找不到
報錯內容:
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 08/23/2022 15:48:19 RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 55081 and starting SCN of 89990540475使用scn位置補充還原
RMAN> recover database until scn 89990540475;Starting recover at 23-AUG-22 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=129 device type=DISKstarting media recovery media recovery complete, elapsed time: 00:00:05Finished recover at 23-AUG-22開啟數據庫
[oracle@sqmesdbbk ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Tue Aug 23 16:43:44 2022Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Automatic Storage Management, OLAP, Data Mining and Real Application Testing optionsSQL> alter database open resetlogs;Database altered.總結
以上是生活随笔為你收集整理的oracle rman 备份与还原的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 查询省或城市
- 下一篇: 学 Python 知识点其实特简单, “