使用用戶自定義的輔助實例執行基於表空間的時間點恢復

   關於表空間的時間點恢復的限制條件可查閱oracle官方文檔,這裏直接給出“使用用戶自定義的輔助實例執行基於表空間的時間點恢復”的步驟。


1 創建表空間及相關用戶


[oracle@dest backup]$ sqlplus  / as sysdba


SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 13 11:55:08 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> select tablespace_name from dba_tablespaces;


TABLESPACE_NAME

------------------------------

SYSTEM

SYSAUX

UNDOTBS1

TEMP

USERS

USER01

ERP

TEST


8 rows selected.


SQL> create tablespace crm datafile '/oracle/CRM/crm.dbf' size 10m;


Tablespace created.


SQL> create tablespace jxc datafile '/oracle/CRM/jxc.dbf' size 10m;


Tablespace created.


SQL> create user jiujian identified by dhhzdhhz default tablespace crm;


User created.


SQL> create user zx identified by dhhzdhhz default tablespace jxc;


User created.


SQL> grant resource,connect to jiujian;


Grant succeeded.


SQL> grant resource,connect to zx;


Grant succeeded.


SQL> select tablespace_name,status from dba_tablespaces;


TABLESPACE_NAME                STATUS

------------------------------ ---------

SYSTEM                         ONLINE

SYSAUX                         ONLINE

UNDOTBS1                       ONLINE

TEMP                           ONLINE

USERS                          ONLINE

JXC                            ONLINE

USER01                         ONLINE

ERP                            ONLINE

CRM                            ONLINE

TEST                           ONLINE


10 rows selected.


SQL> select username from dba_users where default_tablespace='CRM';


USERNAME

------------------------------

JIUJIAN


SQL> select username from dba_users where default_tablespace='JXC';


USERNAME

------------------------------

ZX




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


   GROUP# ARC  SEQUENCE# STATUS

---------- --- ---------- ----------------

        1 YES         16 INACTIVE

        2 YES         17 INACTIVE

        3 NO          18 CURRENT


SQL> alter system switch logfile;


System altered.


SQL> /


System altered.


SQL> /


System altered.


SQL> /


System altered.


SQL> /


System altered.


SQL> /


System altered.


SQL> alter system checkpoint;


System altered.


SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


2 備份當前數據庫


[oracle@dest backup]$ rman target /


Recovery Manager: Release 11.2.0.2.0 - Production on Thu Feb 13 11:59:08 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: CRM (DBID=3641885733)


RMAN> run{

2> delete noprompt obsolete;

3> crosscheck backup;

4> delete noprompt expired backup;

5> crosscheck archivelog all;

6> delete noprompt expired archivelog all;

7> backup incremental level=0  database format '/backup/crm/full-%T-%U.bak';

8> backup archivelog all  format '/backup/crm/arch-%T-%U.bak';

9> backup current controlfile format '/backup/crm/ctl-%T-%U.bak';

10> backup spfile format '/backup/crm/spf-%T-%U.bak';

11> delete noprompt archivelog all completed before 'SYSDATE - 7';

12> }

...........................備份過程略 ....................................


[oracle@dest backup]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 13 12:13:32 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> alter system switch logfile;


System altered.


SQL> /


System altered.


SQL> /


System altered.


SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@dest backup]$

[oracle@dest backup]$

[oracle@dest backup]$


3 在表空間crm和jxc上創建測試用的表數據


[oracle@dest backup]$ sqlplus jiujian/dhhzdhhz


SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 13 12:14:01 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> show user;

USER is "JIUJIAN"

SQL> create table t_jiujian(i int);


Table created.


SQL> begin

 2  for i in 1..20 loop

 3  insert into t_jiujian values(i);

 4  end loop;

 5  commit;

 6  end;

 7  /


PL/SQL procedure successfully completed.


SQL> select count(*) from t_jiujian;


 COUNT(*)

----------

       20


SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@dest backup]$ sqlplus zx/dhhzdhhz


SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 13 12:15:41 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> show user;

USER is "ZX"

SQL> create table t_zx(i int);


Table created.


SQL> begin

 2  for i in 1..20 loop

 3  insert into t_zx values(i);

 4  end loop;

 5  commit;

 6  end;

 7  /


PL/SQL procedure successfully completed.


SQL> select count(*) from t_zx;


 COUNT(*)

----------

       20



SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@dest backup]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 13 12:18:03 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


4 查詢數據庫當前的時間點


SQL> select current_scn,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from v$database;


CURRENT_SCN TO_CHAR(SYSDATE,'YY

----------- -------------------

   3966583 2014-02-13 12:18:14


5 刪除測試表空間crm上的表t_jiujian


SQL> select count(*) from jiujian.t_jiujian;


 COUNT(*)

----------

       20


SQL> alter system switch logfile;


System altered.


SQL> /


System altered.


SQL> select count(*) from jiujian.t_jiujian;


SQL> drop table jiujian.t_jiujian;


Table dropped.


SQL> commit;


Commit complete.


SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


注意:這裏爲了驗證表空間時間點恢復只會回退要操作的表空間。所以在刪除crm 表空間上的表數據後,給jxc表空間再添加一些數據,待回退crm表空間後,恢復該表空間上刪除的表數據。如果jxc表空間上的表數據沒丟失的話,則驗證了表空間時間點恢復只會回退要操作的表空間。


[oracle@dest backup]$ sqlplus zx/dhhzdhhz


SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 13 12:20:13 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> begin

 2  for i in 21..40 loop

 3  insert into t_zx values(i);

 4  end loop;

 5  commit;

 6  end;

 7  /


PL/SQL procedure successfully completed.


SQL> select count(*) from t_zx;


 COUNT(*)

----------

       40


---------前面折騰這麼長篇幅僅僅是爲了創建測試數據-------------------------------


6 創建輔助實例的初始化參數文件


[oracle@source /]$ cd $ORACLE_HOME/dbs

[oracle@source dbs]$ cp initCRM.ora initAUX.ora

更改 initAUX.ora內容如下

[oracle@source dbs]$ cat initAUX.ora

*.compatible='11.2.0.0.0'

*.control_files='/backup/control04.ctl'

*.db_block_size=8192

*.db_name=CRM

*.db_unique_name=_CRM

*.db_file_name_convert=('/oracle/CRM/CRM/','/backup/')

*.log_file_name_convert=('/oracle/CRM/CRM/','/backup/')

*.remote_login_passwordfile='EXCLUSIVE'

參數介紹如下:

db_name:屬於必須有的參數,該值須和目標數據庫配置一樣。

db_unique_name:屬於必須有的參數,一般該值指定爲_dbname即可。

compatible:屬於必須有的參數,該值需和目標庫一致。

db_block_size:屬於必須有的參數,該值需和目標數據庫一致。

remote_login_passwordfile:屬於必須有的參數,當用一個密碼文件連接輔助實例時,該值必須設置成EXCLUSIVE,其它爲NONE。

control_files:屬於非必須參數,該值指定文件名只要不和目標數據庫或者其它任意文件名衝突即可。

db_file_name_convert:屬於非必須參數,通過指定該值自動轉換路徑生成輔助實例所需的數據文件。

log_file_name_convert:屬於非必須參數,該值基於目標數據庫的日誌文件名,轉換路徑後生成輔助實例的聯機日誌文件。


7 創建輔助實例的密碼文件


[oracle@dest CRM]$ cd /ORACLE_HOME/dbs

[oracle@dest dbs]$ ls

01om0ebc_1_1  hc_CRM.dat    initAUX.ora  lkDCTA_TSPITR_CRM  spfileCRM.ora

06om0ek7_1_1  hc_DBUA0.dat  initCRM.ora  orapwCRM

hc_AUX.dat    hc_DctA.dat   lkCRM        snapcf_CRM.f

[oracle@dest dbs]$ cp orapwCRM orapwAUX


8 創建連接輔助數據庫的服務名


[oracle@source admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /oracle/app/db1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.


AUX =

 (DESCRIPTION =

   (ADDRESS_LIST =

     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.8)(PORT = 1521))

   )

   (CONNECT_DATA =

     (SID = AUX)

   )

 )


9 創建並啓動輔助實例的監聽服務


[oracle@source admin]$ cat listener.ora

# listener.ora Network Configuration File: /oracle/app/db1/network/admin/listener.ora

# Generated by Oracle configuration tools.


SID_LIST_AUX =

 (SID_LIST =

   (SID_DESC =

     (GLOBAL_DBNAME = AUX)

     (ORACLE_HOME = /oracle/app/db1)

     (SID_NAME = AUX)

   )

 )


ADR_BASE_AUX = /oracle/app


AUX =

 (DESCRIPTION =

   (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.10)(PORT = 1521))

 )



oracle@dest admin]$ lsnrctl


LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 13-FEB-2014 12:55:21


Copyright (c) 1991, 2010, Oracle.  All rights reserved.


Welcome to LSNRCTL, type "help" for information.


LSNRCTL> start aux

Starting /oracle/app/db1/bin/tnslsnr: please wait...


TNSLSNR for Linux: Version 11.2.0.2.0 - Production

System parameter file is /oracle/app/db1/network/admin/listener.ora

Log messages written to /oracle/app/diag/tnslsnr/dest/aux/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.5.10)(PORT=1521)))


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.5.10)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     aux

Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production

Start Date                13-FEB-2014 12:55:25

Uptime                    0 days 0 hr. 0 min. 1 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /oracle/app/db1/network/admin/listener.ora

Listener Log File         /oracle/app/diag/tnslsnr/dest/aux/alert/log.xml

Listening Endpoints Summary...

 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.5.10)(PORT=1521)))

Services Summary...

Service "AUX" has 1 instance(s).

 Instance "AUX", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

LSNRCTL> exit



10 啓動輔助數據庫到nomount 狀態


[oracle@source admin]$ export ORACLE_SID=AUX

[oracle@source admin]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.2.0 Production on Fri Nov 8 23:19:07 2013


Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to an idle instance.


SQL> startup nomount;

ORACLE instance started.


Total System Global Area  217157632 bytes

Fixed Size                  2225064 bytes

Variable Size             159386712 bytes

Database Buffers           50331648 bytes

Redo Buffers                5214208 bytes

SQL> show parameter control_files;


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

control_files                        string      /backup/control03.ctl

SQL> show parameter instance_name;


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

instance_name                        string      AUX


11 連接目標數據庫和輔助數據庫


[oracle@source admin]$ export ORACLE_SID=CRM

[oracle@source admin]$ rman target / auxiliary sys/dhhzdhhz@aux


Recovery Manager: Release 11.2.0.2.0 - Production on Thu Nov 28 06:46:58 2013


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: CRM (DBID=3599153036)

connected to auxiliary database: CRM (not mounted)


12 開始表空間的時間點恢復


Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@dest dbs]$ rman target /  auxiliary sys/dhhzdhhz@aux


Recovery Manager: Release 11.2.0.2.0 - Production on Thu Feb 13 13:39:51 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: CRM (DBID=3641885733)

connected to auxiliary database: CRM (not mounted)


RMAN> run{

2> set newname for tablespace crm to '/oracle/CRM/CRM/%b';

3> allocate auxiliary channel c1 device type disk;

4> recover tablespace crm until time "to_date('2014-02-13 12:18:14','yyyy-mm-dd hh24:mi:ss')" ;

5> }

注意 1 通過用戶定義的輔助實例在執行時需要至少分配一個 auxiliary 通道

    2 %b 表示從表空間數據文件全路徑中截取表空間的數據文件名

executing command: SET NEWNAME


using target database control file instead of recovery catalog

allocated channel: c1

channel c1: SID=135 device type=DISK


Starting recover at 2014-02-13 13:42:23

RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point-in-time


List of tablespaces expected to have UNDO segments

Tablespace SYSTEM

Tablespace UNDOTBS1

Running TRANSPORT_SET_CHECK on recovery set tablespaces

TRANSPORT_SET_CHECK completed successfully


contents of Memory Script:

{

# set requested point in time

set until  time "to_date('2014-02-13 12:18:14','yyyy-mm-dd hh24:mi:ss')";

# restore the controlfile

restore clone controlfile;

# mount the controlfile

sql clone 'alter database mount clone database';

# archive current online log

sql 'alter system archive log current';

# avoid unnecessary autobackups for structural changes during TSPITR

sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';

}

executing Memory Script


executing command: SET until clause


Starting restore at 2014-02-13 13:42:32


channel c1: starting datafile backup set restore

channel c1: restoring control file

channel c1: reading from backup piece /backup/crm/ctl-20140213-2cp0h1fh_1_1.bak

channel c1: piece handle=/backup/crm/ctl-20140213-2cp0h1fh_1_1.bak tag=TAG20140213T120257

channel c1: restored backup piece 1

channel c1: restore complete, elapsed time: 00:00:01

output file name=/backup/control04.ctl

Finished restore at 2014-02-13 13:42:34


sql statement: alter database mount clone database


sql statement: alter system archive log current


sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;


contents of Memory Script:

{

# set requested point in time

set until  time "to_date('2014-02-13 12:18:14','yyyy-mm-dd hh24:mi:ss')";

plsql <<<-- tspitr_2

declare

 sqlstatement       varchar2(512);

 offline_not_needed exception;

 pragma exception_init(offline_not_needed, -01539);

begin

 sqlstatement := 'alter tablespace '||  'CRM' ||' offline immediate';

 krmicd.writeMsg(6162, sqlstatement);

 krmicd.execSql(sqlstatement);

exception

 when offline_not_needed then

   null;

end; >>>;

# set destinations for recovery set and auxiliary set datafiles

set newname for datafile  1 to

"/backup/system01.dbf";

set newname for datafile  3 to

"/backup/undotbs01.dbf";

set newname for datafile  2 to

"/backup/sysaux01.dbf";

set newname for tempfile  1 to

"/backup/temp01.dbf";

set newname for datafile  5 to

"/oracle/CRM/CRM/crm.dbf";

# switch all tempfiles

switch clone tempfile all;

# restore the tablespaces in the recovery set and the auxiliary set

restore clone datafile  1, 3, 2, 5;

switch clone datafile all;

}

executing Memory Script


executing command: SET until clause


sql statement: alter tablespace CRM offline immediate


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME



Starting restore at 2014-02-13 13:42:41


channel c1: starting datafile backup set restore

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00001 to /backup/system01.dbf

channel c1: restoring datafile 00003 to /backup/undotbs01.dbf

channel c1: restoring datafile 00002 to /backup/sysaux01.dbf

channel c1: restoring datafile 00005 to /oracle/CRM/CRM/crm.dbf

channel c1: reading from backup piece /backup/crm/full-20140213-20p0h19e_1_1.bak

channel c1: piece handle=/backup/crm/full-20140213-20p0h19e_1_1.bak tag=TAG20140213T115941

channel c1: restored backup piece 1

channel c1: restore complete, elapsed time: 00:01:15

Finished restore at 2014-02-13 13:43:58


datafile 5 switched to datafile copy

input datafile copy RECID=2 STAMP=839425439 file name=/oracle/CRM/CRM/crm.dbf


contents of Memory Script:

{

# set requested point in time

set until  time "to_date('2014-02-13 12:18:14','yyyy-mm-dd hh24:mi:ss')";

# online the datafiles restored or switched

sql clone "alter database datafile  1 online";

sql clone "alter database datafile  3 online";

sql clone "alter database datafile  2 online";

sql clone "alter database datafile  5 online";

# recover and open resetlogs

recover clone database tablespace  "CRM", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;

alter clone database open resetlogs;

}

executing Memory Script


executing command: SET until clause


sql statement: alter database datafile  1 online


sql statement: alter database datafile  3 online


sql statement: alter database datafile  2 online


sql statement: alter database datafile  5 online


Starting recover at 2014-02-13 13:44:00


starting media recovery


archived log for thread 1 with sequence 24 is already on disk as file /oracle/archivelog/arch_1_24_839098938.arch

archived log for thread 1 with sequence 25 is already on disk as file /oracle/archivelog/arch_1_25_839098938.arch

archived log for thread 1 with sequence 26 is already on disk as file /oracle/archivelog/arch_1_26_839098938.arch

archived log for thread 1 with sequence 27 is already on disk as file /oracle/archivelog/arch_1_27_839098938.arch

archived log for thread 1 with sequence 28 is already on disk as file /oracle/archivelog/arch_1_28_839098938.arch

archived log file name=/oracle/archivelog/arch_1_24_839098938.arch thread=1 sequence=24

archived log file name=/oracle/archivelog/arch_1_25_839098938.arch thread=1 sequence=25

archived log file name=/oracle/archivelog/arch_1_26_839098938.arch thread=1 sequence=26

archived log file name=/oracle/archivelog/arch_1_27_839098938.arch thread=1 sequence=27

archived log file name=/oracle/archivelog/arch_1_28_839098938.arch thread=1 sequence=28

media recovery complete, elapsed time: 00:00:03

Finished recover at 2014-02-13 13:44:09


database opened


contents of Memory Script:

{

# make read only the tablespace that will be exported

sql clone 'alter tablespace  CRM read only';

# create directory for datapump import

sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''

/oracle/app/db1/dbs''";

# create directory for datapump export

sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''

/oracle/app/db1/dbs''";

}

executing Memory Script


sql statement: alter tablespace  CRM read only


sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/oracle/app/db1/dbs''


sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/oracle/app/db1/dbs''


Performing export of metadata...

  EXPDP> Starting "SYS"."TSPITR_EXP_Asqx":  

  EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK

  EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE

  EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

  EXPDP> Master table "SYS"."TSPITR_EXP_Asqx" successfully loaded/unloaded

  EXPDP> ******************************************************************************

  EXPDP> Dump file set for SYS.TSPITR_EXP_Asqx is:

  EXPDP>   /oracle/app/db1/dbs/tspitr_Asqx_78684.dmp

  EXPDP> ******************************************************************************

  EXPDP> Datafiles required for transportable tablespace CRM:

  EXPDP>   /oracle/CRM/CRM/crm.dbf

  EXPDP> Job "SYS"."TSPITR_EXP_Asqx" successfully completed at 13:46:25

Export completed



contents of Memory Script:

{

# shutdown clone before import

shutdown clone immediate

# drop target tablespaces before importing them back

sql 'drop tablespace  CRM including contents keep datafiles';

}

executing Memory Script


database closed

database dismounted

Oracle instance shut down


sql statement: drop tablespace  CRM including contents keep datafiles


Performing import of metadata...

  IMPDP> Master table "SYS"."TSPITR_IMP_Asqx" successfully loaded/unloaded

  IMPDP> Starting "SYS"."TSPITR_IMP_Asqx":  

  IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK

  IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE

  IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

  IMPDP> Job "SYS"."TSPITR_IMP_Asqx" successfully completed at 13:47:38

Import completed



contents of Memory Script:

{

# make read write and offline the imported tablespaces

sql 'alter tablespace  CRM read write';

sql 'alter tablespace  CRM offline';

# enable autobackups after TSPITR is finished

sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';

}

executing Memory Script


sql statement: alter tablespace  CRM read write


sql statement: alter tablespace  CRM offline


sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;

auxiliary instance file /backup/temp01.dbf deleted

auxiliary instance file /backup/redo03.log deleted

auxiliary instance file /backup/redo02.log deleted

auxiliary instance file /backup/redo01.log deleted

auxiliary instance file /backup/sysaux01.dbf deleted

auxiliary instance file /backup/undotbs01.dbf deleted

auxiliary instance file /backup/system01.dbf deleted

auxiliary instance file /backup/control04.ctl deleted

Finished recover at 2014-02-13 13:47:56


RMAN> exit


這裏需要注意如果基於表空間的時間點恢復執行成功則

a 由SET NEWNAME 指定恢復文件新路徑在目標數據庫控制文件中重新註冊

b 輔助集控制文件,日誌文件,數據文件被刪除

c 輔助集實例shutdown  


13 驗證數據



SQL> select tablespace_name,status from dba_tablespaces;


TABLESPACE_NAME                STATUS

------------------------------ ---------

SYSTEM                         ONLINE

SYSAUX                         ONLINE

TEMP                           ONLINE

USERS                          ONLINE

JXC                            ONLINE

POS                            ONLINE

USER01                         ONLINE

ERP                            ONLINE

UNDOTBS3                       ONLINE

ZX                             ONLINE

CRM                            OFFLINE


11 rows selected.


SQL> alter tablespace crm online;


Tablespace altered.



SQL> select count(*) from jiujian.t_jiujian;


 COUNT(*)

----------

       20


SQL> select count(*) from zx.t_zx;


 COUNT(*)

----------

       40


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章