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 备份与还原的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 查询省或城市
- 下一篇: power query时间函数(思维导图