zoukankan      html  css  js  c++  java
  • 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 ?

    指定日志: {<RET>=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

  • 相关阅读:
    Linux信号列表
    ubuntu nfs server的安装
    【转】 澄清:make oldconfig
    鸟哥的私房菜
    【转】WIN XP下pppoe服务器的搭建与使用
    《Win32多线程程序设计》学习笔记 第4章 同步控制之 事件(Event Objects) 和 interlocked variables
    《Win32多线程程序设计》学习笔记 第4章 同步控制之 信号量(Semaphores)
    《C++编程规范》学习笔记(2)
    《Win32多线程程序设计》学习笔记 第5章 不要让线程成为脱缰野马
    《C++编程规范》学习笔记(4)编程风格
  • 原文地址:https://www.cnblogs.com/yiwuya/p/1373424.html
Copyright © 2011-2022 走看看