日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle rman 备份与还原

發布時間:2023/12/31 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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

RMAN> restore controlfile from '/dbbackup/c-1644883930-20220813-01';

異機還原腳本

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 备份与还原的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。