归档模式已经开启:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oradata/arch
Oldest online log sequence 33
Next log sequence to archive 35
Current log sequence 35
SQL> select 'alter tablespace '||tablespace_name||' begin backup;' from dba_tablespaces where contents<>'TEMPORARY';
'ALTERTABLESPACE'||TABLESPACE_NAME||'BEGINBACKUP;'
-------------------------------------------------------------
alter tablespace SYSTEM begin backup;
alter tablespace SYSAUX begin backup;
alter tablespace UNDOTBS1 begin backup;
alter tablespace USERS begin backup;
SQL> alter tablespace SYSTEM begin backup;
alter tablespace SYSAUX begin backup;
alter tablespace UNDOTBS1 begin backup;
alter tablespace USERS begin backup;
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL> !
[oracle@localhost ~]$
[oracle@localhost ~]$ cd /oradata
[oracle@localhost oradata]$ ls
arch orcl
[oracle@localhost oradata]$ cd orcl
[oracle@localhost orcl]$ ls
control01.ctl control02.ctl redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
[oracle@localhost orcl]$ cp * /oracle/orabak0917/
[oracle@localhost orcl]$ cd /oracle/orabak0917/
[oracle@localhost orabak0917]$ ls
control01.ctl control02.ctl redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
[oracle@localhost orabak0917]$ exit
exit
SQL> select 'alter tablespace '||tablespace_name||' end backup;' from dba_tablespaces where contents<>'TEMPORARY';
'ALTERTABLESPACE'||TABLESPACE_NAME||'ENDBACKUP;'
-----------------------------------------------------------
alter tablespace SYSTEM end backup;
alter tablespace SYSAUX end backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace USERS end backup;
SQL> alter tablespace SYSTEM end backup;
alter tablespace SYSAUX end backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace USERS end backup;
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL>
--做一点数据更新,切换日志,手动归档
SQL> create table baktest (id number);
Table created.
SQL> alter system archive log current;
System altered.
SQL> alter system switch logfile;
System altered.
SQL>
SQL> !
[oracle@localhost ~]$ cd /oradata/orcl
[oracle@localhost orcl]$ ls
control01.ctl control02.ctl redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
[oracle@localhost orcl]$ rm control0*
[oracle@localhost orcl]$ exit
exit
SQL> insert into baktest (id) values (100);
1 row created.
SQL> commit;
Commit complete.
SQL> !
[oracle@localhost ~]$ cd /oradata/orcl
[oracle@localhost orcl]$ ls
redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
[oracle@localhost orcl]$ exit
exit
SQL> shutdown immediate
Database closed.
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/oradata/orcl/control01.ctl'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> !
[oracle@localhost ~]$ cd /oracle
[oracle@localhost oracle]$ ls
lost+found orabak0917 software
[oracle@localhost oracle]$ cd orabak0917
[oracle@localhost orabak0917]$ ls
control01.ctl control02.ctl redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
[oracle@localhost orabak0917]$ cp control01.ctl /oradata/orcl/
[oracle@localhost orabak0917]$ cp control02.ctl /oradata/orcl/
[oracle@localhost orabak0917]$ exit
exit
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 839282688 bytes
Fixed Size 2233000 bytes
Variable Size 520097112 bytes
Database Buffers 314572800 bytes
Redo Buffers 2379776 bytes
Database mounted.
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/oradata/orcl/system01.dbf'
ORA-01207: file is more recent than control file - old control file
SQL>
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE# from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------------------ ------------
1 536987
2 536993
3 536999
4 537005
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
539844
539844
539844
539844
SQL>
SQL> recover database until cancel using backup controlfile;
ORA-00279: change 538754 generated at 09/17/2014 11:45:33 needed for thread 1
ORA-00289: suggestion : /oradata/arch/dbname_1_37_854903932.arc
ORA-00280: change 538754 for thread 1 is in sequence #37
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oradata/orcl/redo01.log
Log applied.
Media recovery complete.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
SQL> alter database open noresetlogs;
alter database open noresetlogs
*
ERROR at line 1:
ORA-01588: must use RESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
SQL>
--恢复出来了
该贴由system转至本版2014-11-19 9:34:57