17.08.17

控制文件

丢失部分控制文件:

SQL> select * from v$controlfile;

$ >/u01/app/oracle/oradata/orcl/control01.ctl

SQL> select * from v$tablespace;           报错

SQL> alter system checkpoint;                报错

$ vi /u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log

SQL> shutdown abort

SQL> startup nomount

SQL> show parameter control_files

$ cp /u01/app/oracle/fast_recovery_area/orcl/control02.ctl /u01/app/oracle/oradata/orcl/control01.ctl

SQL> alter database mount;

SQL> alter database open;

 

丢失全部控制文件(有自动备份):

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

RMAN> backup datafile 4;

$ >/u01/app/oracle/oradata/orcl/control01.ctl

$ >/u01/app/oracle/fast_recovery_area/orcl/control02.ctl

SQL> select * from v$tablespace;           报错

SQL> alter system checkpoint;                报错

SQL> shutdown abort

SQL> startup nomount

RMAN> restore controlfile from autobackup;

RMAN> alter database mount;

RMAN> recover database;

RMAN> alter database open resetlogs;

 

丢失全部控制文件(没有自动备份):

SQL> alter database backup controlfile to '/home/oracle/control.bak';

SQL> alter database backup controlfile to trace;

SQL> select * from v$diag_info;

spfile

有自动备份:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

RMAN> backup datafile 4;

联机恢复:

$ mv $ORACLE_HOME/dbs/spfileorcl.ora $ORACLE_HOME/dbs/spfileorcl.ora.bak

SQL> alter system set resource_limit=true;   报错

SQL> create spfile='/home/oracle/spfile.bak' from memory;

$ mv /home/oracle/spfile.bak $ORACLE_HOME/dbs/spfileorcl.ora

脱机恢复:

SQL> shutdown immediate

$ mv $ORACLE_HOME/dbs/spfileorcl.ora $ORACLE_HOME/dbs/spfileorcl.ora.bak

RMAN> startup

RMAN> restore spfile from '/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_26/o1_mf_s_894118741_c2vkgo8x_.bkp';

RMAN> startup force

 

没有备份:

利用alert_orcl.log中的参数值,构造initorcl.ora

SQL> create spfile='/home/oracle/spfile.bak' from pfile;

利用备份init.ora

$ vi /u01/app/oracle/product/11.2.0/db_1/dbs/init.ora       完善参数

SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/init.ora'

SQL> create spfile from pfile;

redo log

丢失一个成员:

SQL> select GROUP#, MEMBERS from v$log;

SQL> select GROUP#, MEMBER from v$logfile;

SQL> alter database add logfile member '/home/oracle/redo01b.log' to group 1;

SQL> alter database add logfile member '/home/oracle/redo02b.log' to group 2;

SQL> alter database add logfile member '/home/oracle/redo03b.log' to group 3;

SQL> alter system switch logfile;

SQL> alter system switch logfile;

SQL> alter system switch logfile;

故障:

SQL> select group#, status from v$log;           确认current

$ rm -f /home/oracle/redo02b.log                  删除current组成员

SQL> alter system switch logfile;

$ vi /u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log      警告日志

恢复:

SQL> alter database drop logfile member '/home/oracle/redo02b.log';

SQL> alter database add logfile member '/home/oracle/redo02b.log' reuse to group 2;

如果是当前日志组,不能删除成员,只能先切换再修改

 

丢失inactive日志组:

故障:

SQL> alter system checkpoint;

SQL> select group#, status from v$log;           确认inactive

SQL> shutdown abort

$ rm -f /home/oracle/redo03b.log /u01/app/oracle/oradata/orcl/redo03.log

$ startup          报错

恢复:

SQL> startup mount

SQL> select group#, status, archived from v$log;

SQL> alter database clear logfile group 3;

SQL> alter database open;

如果日志未归档:

SQL> alter database clear unarchived logfile group 3;

做数据库的全备份

 

丢失current日志组(正常关闭数据库):

故障:

SQL> select group#, status from v$log;           确认current

SQL> shutdown immediate

$ rm -f /home/oracle/redo02b.log /u01/app/oracle/oradata/orcl/redo02.log

SQL> startup            报错

恢复:

SQL> startup mount

SQL> select group#, status , archived from v$log;

SQL> alter database clear unarchived logfile group 2;

SQL> alter database open;

做数据库的全备份

 

丢失current日志组(非正常关闭数据库):

故障:

RMAN> backup database;

SQL> create table t1(x varchar2(50));

SQL> insert into t1 values ('after backup, before archived');

SQL> commit;

SQL> alter system switch logfile;

SQL> insert into t1 values ('after backup, after archived, current');

SQL> commit;

SQL> insert into t1 values ('after backup, after archived, current, uncommitted');

SQL> alter system checkpoint;

SQL> shutdown abort

$ rm -f /home/oracle/redo03b.log /u01/app/oracle/oradata/orcl/redo03.log

SQL> startup            报错

SQL> select group#, sequence#, status, archived from v$log;        确认日志序号

恢复:

RMAN> run {

startup force mount;

set until sequence 10;

restore database;

recover database;

alter database open resetlogs;}

SQL> select * from t1;              丢失数据

 

丢失active日志组:

 

恢复数据块

故障:

SQL> create tablespace tbs01 datafile '/home/oracle/tbs01.dbf' size 5M;

SQL> create table t1 tablespace tbs01 as select * from dba_objects where rownum<=30000;

RMAN> backup tablespace tbs01;

SQL> alter system flush buffer_cache;

$ dd of=/home/oracle/tbs01.dbf bs=8k conv=notrunc seek=300<<EOF

                                                                         不截断      第300个数据块

SQL> select count(*) from t1;          报错

$ dbv file='/home/oracle/tbs01.dbf'

恢复:

SQL> select file#, block# from v$database_block_corruption;

RMAN> recover datafile 6 block 300;

RMAN> recover corruption list;

 

DBMS_REPAIR包隔离数据块

rman恢复目录

SQL> show parameter control_file_record_keep_time

 

dbca创建数据库rc(不配置emfra200M内存,字符集unicode

或者:

netca创建主机连接字符串rc指向自身。

 

rc

$ sqlplus sys/password@rc as sysdba

SQL> create tablespace rc_tbs datafile '/home/oracle/rc_tbs.dbf' size 50M;

SQL> create user rcowner identified by password default tablespace rc_tbs quota unlimited on rc_tbs;

SQL> grant recovery_catalog_owner to rcowner;

 

$ rman catalog rcowner/password@rc

RMAN> create catalog;

$ rman target sys/password@orcl catalog rcowner/password@rc

$ rman target / catalog rcowner/password@rc

RMAN> register database;

 

dbca删除rc

posted on 2017-08-19 09:18  zhang_x  阅读(136)  评论(0编辑  收藏  举报

导航