模拟非归档模式的备份与恢复(使用冷备)

1、开启非归档模式

SQL> archive log list
SQL> alter database noarchivelog;
SQL> alter database open;

2.查询数据文件和控制文件的位置,冷备份

select name from v$datafile union select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/racdb/control01.ctl
/u01/app/oracle/oradata/racdb/control02.ctl
/u01/app/oracle/oradata/racdb/control03.ctl
/u01/app/oracle/oradata/racdb/eas_d_anjoy_standard01.dbf
/u01/app/oracle/oradata/racdb/sysaux01.dbf
/u01/app/oracle/oradata/racdb/system01.dbf
/u01/app/oracle/oradata/racdb/test01.dbf
/u01/app/oracle/oradata/racdb/undotbs1.dbf
/u01/app/oracle/oradata/racdb/users01.dbf

mkdir -p /home/oracle/bak
shutdown immediate
cp /u01/app/oracle/oradata/racdb/control01.ctl /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/control02.ctl /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/control03.ctl /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/eas_d_anjoy_standard01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/sysaux01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/system01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/test01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/undotbs1.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/users01.dbf /home/oracle/bak/

3. 开库,误删主要数据数据

rm -rf /u01/app/oracle/oradata/racdb/sysaux01.dbf
rm -rf /u01/app/oracle/oradata/racdb/control01.ctl

startup
shutdown immediate
这是启动数据库报错,正常关库

4.恢复数据

cp /home/oracle/bak/control01.ctl /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/control02.ctl /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/control03.ctl /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/eas_d_anjoy_standard01.dbf /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/sysaux01.dbf /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/system01.dbf /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/test01.dbf /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/undotbs1.dbf /u01/app/oracle/oradata/racdb/
cp /home/oracle/bak/users01.dbf /u01/app/oracle/oradata/racdb/

5.重新启动数据库

startup mount
recover database until cancel;
alter database open resetlogs;

6.误删非重要数据文件

shutdown immediate
cp /u01/app/oracle/oradata/racdb/control01.ctl /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/control02.ctl /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/control03.ctl /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/eas_d_anjoy_standard01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/sysaux01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/system01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/test01.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/undotbs1.dbf /home/oracle/bak/
cp /u01/app/oracle/oradata/racdb/users01.dbf /home/oracle/bak/

rm -rf /u01/app/oracle/oradata/racdb/eas_d_anjoy_standard01.dbf

startup(正常启库报错)
shutdown immediate

因为数据文件 /u01/app/oracle/oradata/racdb/eas_d_anjoy_standard01.dbf 中的数据并不重要,
startup force mount
alter database datafile 5 offline drop;
alter database open;

Related Posts