本文共 2128 字,大约阅读时间需要 7 分钟。
查看数据库是否处于归档模式,开启数据库热备模式,拷贝操作系统数据库数据文件到备份目录
SYS@PROD> archive log listDatabase log mode Archive ModeAutomatic archival EnabledArchive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/archOldest online log sequence 2Next log sequence to archive 4Current log sequence 4SYS@PROD> alter database begin backup;Database altered.SYS@PROD> host[oracle@enmoedu1 PROD]$ rm -rf /home/oracle/bak/*[oracle@enmoedu1 PROD]$ cp *.dbf /home/oracle/bak[oracle@enmoedu1 PROD]$ exitexitSYS@PROD> alter database end backup;Database altered.
删除所有的数据文件
SYS@PROD> host[oracle@enmoedu1 PROD]$ rm -rf *.dbf[oracle@enmoedu1 PROD]$ lltotal 172652-rw-r----- 1 oracle oinstall 9748480 Jan 24 22:50 control01.ctl-rw-r----- 1 oracle oinstall 9748480 Jan 24 22:50 control02.ctl-rw-r----- 1 oracle oinstall 52429312 Jan 24 22:50 redo01.log-rw-r----- 1 oracle oinstall 52429312 Jan 24 22:41 redo02.log-rw-r----- 1 oracle oinstall 52429312 Jan 24 22:41 redo03.log[oracle@enmoedu1 PROD]$
启动数据库报错
SYS@PROD> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SYS@PROD> startupORACLE instance started.Total System Global Area 835104768 bytesFixed Size 2257840 bytesVariable Size 536874064 bytesDatabase Buffers 289406976 bytesRedo Buffers 6565888 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 1 - see DBWR trace fileORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'SYS@PROD>
拷贝热备后的数据文件到原数据文件目录
[oracle@enmoedu1 PROD]$ cp /home/oracle/bak/*.dbf ./ ——拷贝数据文件到以前的数据文件目录[oracle@enmoedu1 PROD]$ exitexitSYS@PROD> select open_mode from v$database;OPEN_MODE--------------------MOUNTEDSYS@PROD> alter database open——尝试打开数据库,报错 2 ;alter database open*ERROR at line 1:ORA-01113: file 1 needs media recoveryORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'
恢复数据库
SYS@PROD> recover database;——恢复数据库Media recovery complete.SYS@PROD> alter database open;——开库Database altered.SYS@PROD> select status from v$instance;STATUS------------OPEN