手工热备份
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了手工热备份相关的知识,希望对你有一定的参考价值。
手工热备份步骤:
开库备份只用于归档模式,而且热备之前先执行命令:
热备步骤:
alter database/tablespace XXX begin backup 这句话会导致锁块头,scn号不会变化。
cp files
alter database/tablespace XXX end backup
实验备份users表空间,并测试删除文件并恢复:
1、首先开始备份users表空间
[email protected]> alter tablespace users begin backup;
Tablespace altered.
2、操作系统命令拷贝文件:
[[email protected] ~]$ cd /u01/app/oracle
[[email protected] oracle]$ mkdir hot_dir
[[email protected] oracle]$ cp /u01/app/oracle/oradata/test0910/users01.dbf /u01/app/oracle/hot_dir/users01.dbf
3、结束users表空间的备份:
[email protected]> alter tablespace users end backup;
Tablespace altered.
4、此时删除users01.dbf文件
[[email protected] oracle]$ ls /u01/app/oracle/oradata/test0910/users01.dbf
ls: /u01/app/oracle/oradata/test0910/users01.dbf: No such file or directory
5、关库,再启库,报错:
[email protected]> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
[email protected]> 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恢复,这里用拷贝方式)
[[email protected] oracle]$ cp /u01/app/oracle/hot_dir/users01.dbf /u01/app/oracle/oradata/test0910/users01.dbf
[[email protected] oracle]$ ls /u01/app/oracle/oradata/test0910/users01.dbf
/u01/app/oracle/oradata/test0910/users01.dbf
7、再开库,报错,需要介质恢复:
[email protected]> 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、介质恢复:
[email protected]> recover datafile 4;
Media recovery complete.
9、再开库,成功:
[email protected]> alter database open;
Database altered.
以上是关于手工热备份的主要内容,如果未能解决你的问题,请参考以下文章