??????????????????????????????????????????????????б?????????????rman???л????????????????????????????????????????????????????????????????????????????????????????ò?????????
?????????????????????????????????????7*24?????????????????????????????б?????
???????????????????????????????????????
????1. ?????????
RMAN> backup database;
Starting backup at 10-APR-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/u01/oracle/oradata/orcl/user02.dbf
input datafile file number=00006 name=/u01/oracle/oradata/orcl/tmpspace0327
input datafile file number=00007 name=/u01/oracle/oradata/orcl/undotbs02.dbf
input datafile file number=00008 name=/u01/oracle/oradata/orcl/example.dbf
input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 10-APR-17
channel ORA_DISK_1: finished piece 1 at 10-APR-17
piece handle=/tmp/0us1cc3q_1_1 tag=TAG20170410T225138 comment=NONE
channel ORA_DISK_1: backup set complete?? elapsed time: 00:01:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 10-APR-17
channel ORA_DISK_1: finished piece 1 at 10-APR-17
piece handle=/tmp/0vs1cc6f_1_1 tag=TAG20170410T225138 comment=NONE
channel ORA_DISK_1: backup set complete?? elapsed time: 00:00:02
Finished backup at 10-APR-17
????2 .?????(??????)
????SQL> drop table emp purge;
????Table dropped.
????3. ???????
????????????????????????????scn????????????????????????
SQL> desc dbms_logmnr;
PROCEDURE ADD_LOGFILE
Argument Name          Type            In/Out Default?
------------------------------ ----------------------- ------ --------
LOGFILENAME            VARCHAR2        IN
OPTIONS            BINARY_INTEGER      IN     DEFAULT
# ??dbms_logmnr????????????????ADD_LOGFILE ????????????????????????????????????????????????????logfilename ?????????????????????????????????????????????????????
SQL> select group#??members??status from v$log;
GROUP#    MEMBERS STATUS
---------- ---------- ----------------
1      1 CURRENT
2      1 INACTIVE
3      1 INACTIVE
# ???????????????????????1
SQL> select group#??member??status from v$logfile;
GROUP#
----------
MEMBER                                     STATUS
---------------------------------------------------------------------- -------
3
/u01/oracle/oradata/orcl/redo03.log
2
/u01/oracle/oradata/orcl/redo02.log
1
/u01/oracle/oradata/orcl/redo01.log
# ?????????????1 ????????‘/u01/oracle/oradata/orcl/redo01.log’
???????????????????????
????SQL> exec dbms_logmnr.add_logfile('/u01/oracle/oradata/orcl/redo01.log');
????PL/SQL procedure successfully completed.
?????????????
SQL> desc dbms_logmnr;
PROCEDURE START_LOGMNR
Argument Name          Type            In/Out Default?
------------------------------ ----------------------- ------ --------
STARTSCN           NUMBER          IN     DEFAULT
ENDSCN             NUMBER          IN     DEFAULT
STARTTIME          DATE            IN     DEFAULT
ENDTIME            DATE            IN     DEFAULT
DICTFILENAME           VARCHAR2        IN     DEFAULT
OPTIONS            BINARY_INTEGER      IN     DEFAULT
# ????????????dbms_logmnr?????????start_logmnr ????????????????????
SQL> execute dbms_logmnr.START_LOGMNR(options=>dbms_logmnr.dict_from_online_catalog);
PL/SQL procedure successfully completed.
# ????????
???????????????????????????scn???????v$logmnr_contents;
SQL> select scn??to_char(TIMESTAMP??'yyyy-mm-dd hh24:mi:ss') TIMESTAMP??SQL_REDO??SQL_UNDO from v$logmnr_contents where table_name = 'EMP';
SCN TIMESTAMP        SQL_REDO         SQL_UNDO
---------- -------------------- -------------------- --------------------
2507301 2017-04-10 22:54:49  drop table emp purge
?????????????????????????????scn??????
??????????????????????????1??
???????????????
????SQL> exec dbms_logmnr.end_logmnr;
????PL/SQL procedure successfully completed.
????4. ????????
RMAN> shutdown immediate;
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
#?????????
RMAN> startup mount;
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area     584568832 bytes
Fixed Size                     2230552 bytes
Variable Size                444597992 bytes
Database Buffers             130023424 bytes
Redo Buffers                   7716864 bytes
#?????mount????
RMAN> run{
2> set until scn 2507301;
3> restore database;
4> recover database;
5> alter database open resetlogs;
6> }
executing command: SET until clause
Starting restore at 10-APR-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=137 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oracle/oradata/orcl/user02.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/oracle/oradata/orcl/tmpspace0327
channel ORA_DISK_1: restoring datafile 00007 to /u01/oracle/oradata/orcl/undotbs02.dbf
channel ORA_DISK_1: restoring datafile 00008 to /u01/oracle/oradata/orcl/example.dbf
channel ORA_DISK_1: reading from backup piece /tmp/0us1cc3q_1_1
channel ORA_DISK_1: piece handle=/tmp/0us1cc3q_1_1 tag=TAG20170410T225138
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete?? elapsed time: 00:01:15
Finished restore at 10-APR-17
Starting recover at 10-APR-17
using channel ORA_DISK_1
starting media recovery
media recovery complete?? elapsed time: 00:00:01
Finished recover at 10-APR-17
database opened
# ??????run{}??????л????restore??recover??open resetlogs;
# ???
????5. ???
SQL> desc emp;
Name                      Null?    Type
----------------------------------------- -------- ----------------------------
EMPNO                     NOT NULL NUMBER(4)
ENAME                          VARCHAR2(10)
JOB                            VARCHAR2(9)
MGR                            NUMBER(4)
HIREDATE                       DATE
SAL                            NUMBER(7??2)
COMM                           NUMBER(7??2)
DEPTNO                         NUMBER(2)
SQL> select count(*) from emp;
COUNT(*)
----------
# ???????emp???????
????6. ???±????????
???????????????????????????????????????????????????????????????????????????
??????oracle11g ?л??????????????????????????
???????????2??裺
????1) ?????????????
????2)??????н??в???????
????3) ??????в?????????????????????????
???????????????ù?????????????????????п????????????????????????????????????