首页 > 代码库 > 手工热备份
手工热备份
1、首先要开归档,因为是热备份
设置表空间为只读
SQL> alter tablespace exec read only;
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
TEMPTS ONLINE
TOOLS ONLINE
EXEC READ ONLY
QIANYI ONLINE
UNDO_SMALL2 ONLINE
TEMPTS2 ONLINE
GOLDENGATE ONLINE
TBS_GGUSER ONLINE
只读状态下备份报错,因为它对数据文件加不上锁
SQL> alter tablespace exec begin backup;
alter tablespace exec begin backup
*
ERROR at line 1:
ORA-01642: begin backup not needed for read only tablespace ‘EXEC‘
数据文件的scn号不一致了:
SQL> select file#,checkpoint_change# from v$datafile;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
1 2831387
2 2831387
3 2831387
4 2831387
5 2834548
6 2831387
7 2831387
8 2831387
将表空间设置生读写模式:
2、执行开始备份表空间的命令后,正常关库是无法成功的:
SQL> alter tablespace EXEC read write;
SQL> alter tablespace exec begin backup;
Tablespace altered.
SQL> shutdown immediate;
ORA-01149: cannot shutdown - file 5 has online backup set
ORA-01110: data file 5: ‘/u01/app/oracle/oradata/PROD/exec.dbf‘
可以用shutdown abort关库,但是这样会导致数据文件的scn号不一致,开库是需要恢复表空间
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 150994944 bytes
Fixed Size 1218220 bytes
Variable Size 79694164 bytes
Database Buffers 67108864 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: ‘/u01/app/oracle/oradata/PROD/exec.dbf‘
SQL> recover tablespace exec;
Media recovery complete.
SQL> alter database open;
本文出自 “柚子” 博客,请务必保留此出处http://6205351.blog.51cto.com/6195351/1530615