知识大全 利用dbmsbackuprestore恢复数据库
Posted 数据库
篇首语:一寸光阴一寸金,寸金难买寸光阴。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 利用dbmsbackuprestore恢复数据库相关的知识,希望对你有一定的参考价值。
进行测试之前先将数据库做全备
引用
RMAN> run
> allocate channel ch device type disk;
> backup database include current controlfile format /backup/full%t tag= FULLDB ;
> sql alter system archive log current ;
> backup archivelog all format /backup/arch%t tag= ARCHIVELOG ;
> release channel ch ;
>
allocated channel: ch
channel ch : sid= devtype=DISK
Starting backup at JAN
channel ch : starting full datafile backupset
channel ch : specifying datafile(s) in backupset
including current controlfile in backupset
input datafile fno= name=/app/oracle/oradata/ora i/system dbf
input datafile fno= name=/app/oracle/oradata/ora i/undotbs dbf
input datafile fno= name=/app/oracle/oradata/ora i/example dbf
input datafile fno= name=/app/oracle/oradata/ora i/STREAM dbf
input datafile fno= name=/app/oracle/oradata/ora i/xdb dbf
input datafile fno= name=/app/oracle/oradata/ora i/indx dbf
input datafile fno= name=/app/oracle/oradata/ora i/users dbf
input datafile fno= name=/app/oracle/oradata/ora i/cwmlite dbf
input datafile fno= name=/app/oracle/oradata/ora i/drsys dbf
input datafile fno= name=/app/oracle/oradata/ora i/odm dbf
input datafile fno= name=/app/oracle/oradata/ora i/tools dbf
channel ch : starting piece at JAN
channel ch : finished piece at JAN
piece handle=/backup/full ment=NONE
channel ch : backup set plete elapsed time: : :
Finished backup at JAN
Starting Control File and SPFILE Autobackup at JAN
piece handle=/app/oracle/product/ /dbs/c ment=NONE
Finished Control File and SPFILE Autobackup at JAN
sql statement: alter system archive log current
Starting backup at JAN
current log archived
channel ch : starting archive log backupset
channel ch : specifying archive log(s) in backup set
input archive log thread= sequence= recid= stamp=
input archive log thread= sequence= recid= stamp=
input archive log thread= sequence= recid= stamp=
channel ch : starting piece at JAN
channel ch : finished piece at JAN
piece handle=/backup/arch ment=NONE
channel ch : backup set plete elapsed time: : :
Finished backup at JAN
Starting Control File and SPFILE Autobackup at JAN
piece handle=/app/oracle/product/ /dbs/c ment=NONE
Finished Control File and SPFILE Autobackup at JAN
released channel: ch
假设现在数据库异常宕机
引用
SQL> shutdown abort
ORACLE instance shut down
启动数据库至nomount状态
引用
SQL> startup nomount
ORACLE instance started
Total System Global Area bytes
Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
利用dbms_backup_restore恢复控制文件
SQL> DECLARE
devtype varchar ( );
done boolean;
BEGIN
devtype := dbms_backup_restore DeviceAllocate(type => ident => testctl );
dbms_backup_restore RestoresetdataFile;
dbms_backup_restore RestoreControlFileto( /app/oracle/oradata/ora i/control ctl );
dbms_backup_restore RestoreBackupPiece( /backup/full ′ done => done);
dbms_backup_restore RestoresetdataFile;
dbms_backup_restore RestoreControlFileto( /app/oracle/oradata/ora i/control ctl );
dbms_backup_restore RestoreBackupPiece( /backup/full ′ done => done);
dbms_backup_restore RestoresetdataFile;
dbms_backup_restore RestoreControlFileto( /app/oracle/oradata/ora i/control ctl );
dbms_backup_restore RestoreBackupPiece( /backup/full ′ done => done);
dbms_backup_restore DeviceDeallocate;
END;
/
PL/SQL procedure successfully pleted
当然也已可用rman进行控制文件恢复
引用
RMAN> restore controlfile from /app/oracle/product/ /dbs/c ′;
Starting restore at JAN
using channel ORA_DISK_
channel ORA_DISK_ : restoring controlfile
channel ORA_DISK_ : restore plete
replicating controlfile
input filename=/app/oracle/oradata/ora i/control ctl
output filename=/app/oracle/oradata/ora i/control ctl
output filename=/app/oracle/oradata/ora i/control ctl
Finished restore at JAN
利用dbms_backup_restore恢复数据文件
引用
SQL> DECLARE
devtype varchar ( );
done boolean;
BEGIN
devtype := dbms_backup_restore DeviceAllocate (type => ident => testdatafile );
dbms_backup_restore RestoreSetDatafile;
dbms_backup_restore RestoreDatafileTo(dfnumber => toname => /app/oracle/oradata/ora i/system dbf );
dbms_backup_restore RestoreDatafileTo(dfnumber => toname => /app/oracle/oradata/ora i/undotbs dbf );
dbms_backup_restore RestoreBackupPiece(done => done handle => /backup/full ′ params => null);
dbms_backup_restore DeviceDeallocate;
END;
/
PL/SQL procedure successfully pleted
利用dbms_backup_restore恢复归档日志
引用
SQL> DECLARE
devtype varchar ( );
done boolean;
BEGIN
devtype := dbms_backup_restore DeviceAllocate (type => ident => testarchlog );
dbms_backup_restore RestoreSetArchivedLog(destination=> /app/oracle/product/ /dbs/arch );
dbms_backup_restore RestoreArchivedLog(thread=> sequence=> );
dbms_backup_restore RestoreArchivedLog(thread=> sequence=> );
dbms_backup_restore RestoreArchivedLog(thread=> sequence=> );
dbms_backup_restore RestoreBackupPiece(done => done handle => /backup/arch ′ params => null);
dbms_backup_restore DeviceDeallocate;
END;
/
PL/SQL procedure successfully pleted
不完全恢复打开数据库
引用
SQL> alter database mount;
Database altered
SQL> recover database using backup controlfile;
ORA : change generated at / / : : needed for thread
ORA : suggestion : /app/oracle/product/ /dbs/arch/ _ dbf
ORA : change for thread is in sequence #
Specify log: <RET>=suggested | filename | AUTO | CANCEL
auto
ORA : change generated at / / : : needed for thread
ORA : suggestion : /app/oracle/product/ /dbs/arch/ _ dbf
ORA : change for thread is in sequence #
ORA : log file /app/oracle/product/ /dbs/arch/ _ dbf no longer
needed for this recovery
ORA : change generated at / / : : needed for thread
ORA : suggestion : /app/oracle/product/ /dbs/arch/ _ dbf
ORA : change for thread is in sequence #
ORA : log file /app/oracle/product/ /dbs/arch/ _ dbf no longer
needed for this recovery
ORA : cannot open archived log
/app/oracle/product/ /dbs/arch/ _ dbf
ORA : unable to obtain file status
Linux Error: : No such file or directory
Additional information:
SQL> recover database using backup controlfile until cancel;
ORA : change generated at / / : : needed for thread
ORA : suggestion : /app/oracle/product/ /dbs/arch/ _ dbf
ORA : change for thread is in sequence #
Specify log: <RET>=suggested | filename | AUTO | CANCEL
/app/oracle/oradata/ora i/redo log
Log applied
cha138/Article/program/Oracle/201311/18092相关参考
利用VB进行SQL2000的数据备份和恢复 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 一备份
知识大全 用asp.net还原与恢复sqlserver数据库
上次做了个项目涉及到数据库的还原和恢复到网上找了一下是利用SQLDMO实现的只要添加SQLDMO引用就好了然后利用下边的类的方法就可以实现了 我把原作者的类扩充了一下可以自动识别nfig里的数据
有一个数据库standby库恢复时经常赶不上主库的进度用iostatx查看磁盘利用率的时候发现三个放数据文件的盘(每个盘是由个物理盘做的raid)的读iops在以内磁盘利用率在%以内所以初步分析恢
用Flashback功能恢复表中数据 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!这里只罗列出利用
全部或部分恢复数据文件数据库处于restrictmount状态 A完全恢复 操作系统还原所有或被损坏的数据文件 以restrict方式启动实例并mount数据库 SVRMG
在没有控制文件备份的情况下重新创建控制文件也是其中一个选择本文旨在帮助初学者学习之用谢谢!! 如何恢复一个只有完好数据文件的数据库? 本文欲将此数据文件恢复成数据库TTI实例名TTI $ORAC
SQLServer:无日志恢复数据库 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 事情的起因
昨天帮一个朋友恢复了sqlserver数据库现在把过程写出来大家一起分享 我那个哥们是从别人那拷了一个数据库的数据文件(c:\\mssql\\data目录下的文件) 最初我是用的 在一台好的
Oracle数据库备份与恢复 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 一导出/导入(Exp
Oracle数据库恢复后心得 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 刚安装完Oracle