首页 > 代码库 > 手工热备份

手工热备份

手工热备份步骤:

开库备份只用于归档模式,而且热备之前先执行命令:

热备步骤:

alter database/tablespace  XXX begin backup 这句话会导致锁块头,scn号不会变化。

cp files

alter database/tablespace XXX end backup


实验备份users表空间,并测试删除文件并恢复:

1、首先开始备份users表空间

sys@TEST0910> alter tablespace users begin backup;

 

Tablespace altered.

 

2、操作系统命令拷贝文件:

[oracle@rtest ~]$ cd /u01/app/oracle

[oracle@rtest oracle]$ mkdir hot_dir

[oracle@rtest oracle]$ cp /u01/app/oracle/oradata/test0910/users01.dbf  /u01/app/oracle/hot_dir/users01.dbf

 

3、结束users表空间的备份:

sys@TEST0910> alter tablespace users end backup;

 

Tablespace altered.

 

4、此时删除users01.dbf文件

[oracle@rtest oracle]$ ls /u01/app/oracle/oradata/test0910/users01.dbf

ls: /u01/app/oracle/oradata/test0910/users01.dbf: No such file or directory

 

5、关库,再启库,报错:

sys@TEST0910> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

sys@TEST0910> startup

ORACLE instance started.

 

Total System Global Area 2505338880 bytes

Fixed Size                  2230952 bytes

Variable Size             587203928 bytes

Database Buffers         1895825408 bytes

Redo Buffers               20078592 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 4 - see DBWR trace file

ORA-01110: data file 4: ‘/u01/app/oracle/oradata/test0910/users01.dbf‘

 

6、通过操作系统拷贝到正确的位置,(也可以通过rman恢复,这里用拷贝方式)

[oracle@rtest oracle]$ cp /u01/app/oracle/hot_dir/users01.dbf /u01/app/oracle/oradata/test0910/users01.dbf

[oracle@rtest oracle]$ ls /u01/app/oracle/oradata/test0910/users01.dbf

/u01/app/oracle/oradata/test0910/users01.dbf

 

7、再开库,报错,需要介质恢复:

sys@TEST0910> alter database open;

alter database open

*

ERROR at line 1:

ORA-01113: file 4 needs media recovery

ORA-01110: data file 4: ‘/u01/app/oracle/oradata/test0910/users01.dbf‘

 

8、介质恢复:

sys@TEST0910> recover datafile 4;

Media recovery complete.

 

9、再开库,成功:

sys@TEST0910> alter database open;

 

Database altered.




手工热备份