16.3 实现用户管理的 TSPITR

在Oracle Database 10g 中,通过结合辅助数据库、EXP 和IMP,DBA 可以实现TSPIRT。

(1) 建立辅助例程服务。

C:/>oradim -new -sid auxi -intpwd oracle
实例已创建。

(2) 建立辅助例程参数文件。

1. 连接到主数据库建立参数文件。

C:/>sqlplus sys/orcl@orcl as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 1月 10 11:51:08 2009

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

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> create pfile='%oracle_home%/database/initauxi.ora' from spfile;

文件已创建。

2. 编辑参数文件 initauxi.ora

db_unique_name=auxiorcl
control_files=d:/auxi/control01.ctl
db_file_name_convert=('d:/orcl','d:/auxi')
log_file_name_convert=('d:/orcl','d:/auxi','c:/orcl','c:/auxi')

(3) 复制恢复集数据文件和辅助集文件。

SQL> host copy d:/orcl/bak/system01.dbf d:/auxi
已复制         1 个文件。

SQL> host copy d:/orcl/bak/undotbs01.dbf d:/auxi
已复制         1 个文件。

SQL> host copy d:/orcl/bak/tbs03.dbf d:/auxi
已复制         1 个文件。

SQL> host copy d:/orcl/bak/orcl.ctl d:/auxi/control01.ctl
已复制         1 个文件。

(4) 启动辅助例程并装载辅助数据库。 

C:/>set oracle_sid=auxi

C:/>sqlplus sys/oracle as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 1月 10 12:08:56 2009

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

已连接到空闲例程。

SQL> startup nomount pfile=%oracle_home%/database/initauxi.ora
ORACLE 例程已经启动。

Total System Global Area  444596224 bytes
Fixed Size                  1249464 bytes
Variable Size             130027336 bytes
Database Buffers          306184192 bytes
Redo Buffers                7135232 bytes
SQL> alter database mount clone database;

数据库已更改。

(5) 使恢复集和辅助数据文件联机。  

SQL> alter database datafile 'd:/auxi/system01.dbf' online;

数据库已更改。

SQL> alter database datafile 'd:/auxi/undotbs01.dbf' online;

数据库已更改。

SQL> alter database datafile 'd:/auxi/tbs03.dbf' online;

数据库已更改。

(6) 恢复辅助数据库到TRPITR 时间点。

SQL> recover database until time '2009-01-10 11:36:45' using backup controlfile
ORA-00279: ?? 944491 (? 01/10/2009 10:59:16 ??) ???? 1 ????
ORA-00289: ??: C:/ORCL/ARCHIVE/47AE3449_00032_001_674818253.ARC
ORA-00280: ?? 944491 (???? 1) ??? #32 ?

指定日志: { =suggested | filename | AUTO | CANCEL}
auto
ORA-00279: ?? 944758 (? 01/10/2009 11:02:30 ??) ???? 1 ????
ORA-00289: ??: C:/ORCL/ARCHIVE/47AE3449_00033_001_674818253.ARC
ORA-00280: ?? 944758 (???? 1) ??? #33 ?
ORA-00278: ??????????? 'C:/ORCL/ARCHIVE/47AE3449_00032_001_674818253.ARC'

ORA-00279: ?? 944995 (? 01/10/2009 11:09:39 ??) ???? 1 ????
ORA-00289: ??: C:/ORCL/ARCHIVE/47AE3449_00034_001_674818253.ARC
ORA-00280: ?? 944995 (???? 1) ??? #34 ?
ORA-00278: ??????????? 'C:/ORCL/ARCHIVE/47AE3449_00033_001_674818253.ARC'

ORA-00279: ?? 945074 (? 01/10/2009 11:12:25 ??) ???? 1 ????
ORA-00289: ??: C:/ORCL/ARCHIVE/47AE3449_00035_001_674818253.ARC
ORA-00280: ?? 945074 (???? 1) ??? #35 ?
ORA-00278: ??????????? 'C:/ORCL/ARCHIVE/47AE3449_00034_001_674818253.ARC'

ORA-00279: ?? 945077 (? 01/10/2009 11:12:29 ??) ???? 1 ????
ORA-00289: ??: C:/ORCL/ARCHIVE/47AE3449_00036_001_674818253.ARC
ORA-00280: ?? 945077 (???? 1) ??? #36 ?
ORA-00278: ??????????? 'C:/ORCL/ARCHIVE/47AE3449_00035_001_674818253.ARC'

ORA-00279: ?? 945080 (? 01/10/2009 11:12:35 ??) ???? 1 ????
ORA-00289: ??: C:/ORCL/ARCHIVE/47AE3449_00037_001_674818253.ARC
ORA-00280: ?? 945080 (???? 1) ??? #37 ?
ORA-00278: ??????????? 'C:/ORCL/ARCHIVE/47AE3449_00036_001_674818253.ARC'

ORA-00308: ???????? 'C:/ORCL/ARCHIVE/47AE3449_00037_001_674818253.ARC'
ORA-27041: ??????
OSD-04002: ????????????
O/S-Error: (OS 2) ??????????????????????

(7) 用RESETLOGS 选项打开数据库,并检查恢复结果。

SQL> alter database open resetlogs;

数据库已更改。

SQL> select * from scott.customers;

   CUST_ID CUST_NAME
---------- ----------
         1 SCOTT
         2 SMITH

(8) 在辅助数据库上建立临时表空间。 

SQL> alter tablespace temp add tempfile 'd:/auxi/temp.dbf' size 10M;

表空间已更改。

(9) 导出辅助数据库的恢复集表空间。 

C:/>exp 'sys/oracle as sysdba' point_in_time_recover=y tablespaces=tbs03 file=d:
/auxi/dump/tbs03.dmp

Export: Release 10.2.0.1.0 - Production on 星期六 1月 10 12:25:41 2009

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
注: 将不导出表数据 (行)

即将导出表空间时间点恢复对象...
对于表空间 TBS03...
. 正在导出簇定义
. 正在导出表定义
. . 正在导出表                       CUSTOMERS
. 正在导出引用完整性约束条件
. 正在导出触发器
. 终止时间点恢复
成功终止导出, 没有出现警告。

(10) 使主数据库的恢复集表空间脱机。 

C:/>sqlplus sys/orcl@orcl as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 1月 10 12:26:51 2009

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

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> alter tablespace tbs03 offline;

表空间已更改。

SQL> host copy d:/auxi/tbs03.dbf d:/orcl/tbs03.dbf
已复制         1 个文件。

(11) 导入恢复集表空间到主数据库。

C:/>imp 'sys/orcl@orcl as sysdba' point_in_time_recover=y datafiles=d:/orcl/tbs0
3.dbf file=d:/auxi/dump/tbs03.dmp

Import: Release 10.2.0.1.0 - Production on 星期六 1月 10 12:31:11 2009

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

经由常规路径由 EXPORT:V10.02.01 创建的导出文件
即将导入表空间时间点恢复对象...
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. 正在将 SYS 的对象导入到 SYS
. 正在将 SCOTT 的对象导入到 SCOTT
. . 正在导入表                     "CUSTOMERS"
. 正在将 SYS 的对象导入到 SYS
成功终止导入, 没有出现警告。

(12) 使恢复集表空间联机,并检查恢复结果。 

C:/>sqlplus sys/orcl@orcl as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 1月 10 12:32:14 2009

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

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> alter tablespace tbs03 online;

表空间已更改。

SQL> select * from scott.customers;

   CUST_ID CUST_NAME
---------- ----------
         1 SCOTT
         2 SMITH

SQL> select * from scott.sales;

        ID CUST_NAME  SALES_AMOUNT
---------- ---------- ------------
         1 SCOTT              8000
         2 SMITH             10000
         3 SCOTT              6000
         4 BLAKE             67000

SQL> select * from scott.employee;
select * from scott.employee
                    *
第 1 行出现错误:
ORA-00942: 表或视图不存在

(13) 删除辅助例程。 

C:/>oradim -delete -sid auxi
实例已删除。

C:/>rd d:/auxi /s
d:/auxi, 是否确认(Y/N)? y

C:/>rd c:/auxi /s
c:/auxi, 是否确认(Y/N)? y

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值