zoukankan      html  css  js  c++  java
  • 16.4.3 手工辅助例程实现 TSPITR

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

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

    1. 连接到主数据库建立参数文件。
    2. 编辑参数文件。
    3. 启动辅助例程。
    4. 执行 TSPITR。
    5. 使恢复集表空间联机。
    6. 删除辅助例程以及相关文件。

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

    C:\>sqlplus sys/demo@demo as sysdba

    SQL*Plus: Release 10.2.0.3.0 - Production on 星期六 1月 24 21:48:02 2009

    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

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

    SQL> create pfile='d:\initauxi.ora' from spfile;

    文件已创建。

    编辑:

    DB_UNIQUE_NAME=_demo
    CONTROL_FILES=d:\auxi\control01.ctl
    DB_FILE_NAME_CONVERT=('d:\demo','d:\auxi')
    LOG_FILE_NAME_CONVERT=('d:\demo','d:\auxi','c:\demo','c:\auxi')

     

    SQL> exit
    从 Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options 断开

    C:\>set oracle_sid=auxi

    C:\>sqlplus sys/oracle as sysdba

    SQL*Plus: Release 10.2.0.3.0 - Production on 星期六 1月 24 21:55:32 2009

    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

    已连接到空闲例程。

    SQL> startup nomount pfile=d:\initauxi.ora
    ORACLE 例程已经启动。

    Total System Global Area  289406976 bytes
    Fixed Size                  1290184 bytes
    Variable Size              96469048 bytes
    Database Buffers          184549376 bytes
    Redo Buffers                7098368 bytes
    SQL> connect colin/colin@demo
    已连接。
    SQL> select * from tab01;

    未选定行
    SQL> insert into tab01 values(1);

    已创建 1 行。

    SQL> insert into tab01 values(2);

    已创建 1 行。

    SQL> commit;

    提交完成。

    SQL> conn sys/demo@demo as sysdba
    已连接。
    SQL> archive log list;
    数据库日志模式            存档模式
    自动存档             启用
    存档终点            d:\demo\archive
    最早的联机日志序列     89
    下一个存档日志序列   91
    当前日志序列           91
    SQL> alter system switch logfile;

    系统已更改。

    SQL> alter system switch logfile;

    系统已更改。

    SQL> truncate table colin.tab01;

    表被截断。

    SQL> exit
    从 Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options 断开

    C:\>set oracle_sid=auxi

    C:\>rman target sys/demo@demo auxiliary sys/oracle

    恢复管理器: Release 10.2.0.3.0 - Production on 星期六 1月 24 22:04:05 2009

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

    连接到目标数据库: DEMO (DBID=3420134445)
    已连接到辅助数据库: DEMO (未装载)

    RMAN> run
    2> {
    3> allocate auxiliary channel c1 device type disk;
    4> recover tablespace tbs01 until logseq 92;
    5> }

    使用目标数据库控制文件替代恢复目录
    分配的通道: c1
    通道 c1: sid=157 devtype=DISK

    启动 recover 于 24-1月 -09
    RMAN-05026: 警告: 假定以下表空间集适用于指定的时间点

    表空间列表要求具有 UNDO 段
    表空间 SYSTEM
    表空间 UNDOTBS1

    内存脚本的内容:
    {
    # set the until clause
    set until  logseq 92 thread 1;
    # restore the controlfile
    restore clone controlfile;
    # mount the controlfile
    sql clone 'alter database mount clone database';
    # archive current online log for tspitr to a resent until time
    sql 'alter system archive log current';
    # avoid unnecessary autobackups for structural changes during TSPITR
    sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
    }
    正在执行内存脚本

    正在执行命令: SET until clause

    启动 restore 于 24-1月 -09

    通道 c1: 正在开始恢复数据文件备份集
    通道 c1: 正在复原控制文件
    通道 c1: 正在读取备份段 D:\DEMO\BAK\DEMO.CTL
    通道 c1: 已恢复备份段 1
    段句柄 = D:\DEMO\BAK\DEMO.CTL 标记 = TAG20090115T171224
    通道 c1: 恢复完成, 用时: 00:00:02
    输出文件名=D:\AUXI\CONTROL01.CTL
    完成 restore 于 24-1月 -09

    sql 语句: alter database mount clone database

    sql 语句: alter system archive log current

    sql 语句: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

    内存脚本的内容:
    {
    # generated tablespace point-in-time recovery script
    # set the until clause
    set until  logseq 92 thread 1;
    plsql <<<-- tspitr_2
    declare
      sqlstatement       varchar2(512);
      offline_not_needed exception;
      pragma exception_init(offline_not_needed, -01539);
    begin
      sqlstatement := 'alter tablespace '||  'TBS01' ||' offline for recover';
      krmicd.writeMsg(6162, sqlstatement);
      krmicd.execSql(sqlstatement);
    exception
      when offline_not_needed then
        null;
    end; >>>;
    # set a destination filename for restore
    set newname for datafile  1 to
    "D:\AUXI\SYSTEM01.DBF";
    # set a destination filename for restore
    set newname for datafile  2 to
    "D:\AUXI\UNDOTBS01.DBF";
    # set a destination tempfile
    set newname for tempfile  1 to
    "D:\AUXI\TEMP01.DBF";
    # set a destination filename for restore
    set newname for datafile  5 to
    "C:\DEMO\TBS01.DBF";
    # rename all tempfiles
    switch clone tempfile all;
    # restore the tablespaces in the recovery set plus the auxilliary tablespaces
    restore clone datafile  1, 2, 5;
    switch clone datafile all;
    #online the datafiles restored or flipped
    sql clone "alter database datafile  1 online";
    #online the datafiles restored or flipped
    sql clone "alter database datafile  2 online";
    #online the datafiles restored or flipped
    sql clone "alter database datafile  5 online";
    # make the controlfile point at the restored datafiles, then recover them
    recover clone database tablespace  "TBS01", "SYSTEM", "UNDOTBS1" delete archivel
    og;
    alter clone database open resetlogs;
    # PLUG HERE the creation of a temporary tablespace if export fails due to lack
    # of temporary space.
    # For example in Unix these two lines would do that:
    #sql clone "create tablespace aux_tspitr_tmp
    #           datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
    }
    正在执行内存脚本

    正在执行命令: SET until clause

    sql 语句: alter tablespace TBS01 offline for recover

    正在执行命令: SET NEWNAME

    正在执行命令: SET NEWNAME

    正在执行命令: SET NEWNAME

    正在执行命令: SET NEWNAME

    启动 restore 于 24-1月 -09

    通道 c1: 正在开始恢复数据文件备份集
    通道 c1: 正在指定从备份集恢复的数据文件
    正将数据文件00001恢复到D:\AUXI\SYSTEM01.DBF
    正将数据文件00002恢复到D:\AUXI\UNDOTBS01.DBF
    通道 c1: 正在读取备份段 D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\DEMO\BACKUP
    SET\2009_01_15\O1_MF_NNNDF_TAG20090115T171052_4PXZDXGV_.BKP
    通道 c1: 已恢复备份段 1
    段句柄 = D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\DEMO\BACKUPSET\2009_01_15\
    O1_MF_NNNDF_TAG20090115T171052_4PXZDXGV_.BKP 标记 = TAG20090115T171052
    通道 c1: 恢复完成, 用时: 00:00:56
    通道 c1: 正在开始恢复数据文件备份集
    通道 c1: 正在指定从备份集恢复的数据文件
    正将数据文件00005恢复到C:\DEMO\TBS01.DBF
    通道 c1: 正在读取备份段 D:\DEMO\BAK\DEMO_68_1.BAK
    通道 c1: 已恢复备份段 1
    段句柄 = D:\DEMO\BAK\DEMO_68_1.BAK 标记 = TAG20090124T214036
    通道 c1: 恢复完成, 用时: 00:00:02
    完成 restore 于 24-1月 -09

    数据文件 5 已转换成数据文件副本
    输入数据文件副本 recid=40 stamp=677023588 文件名=C:\DEMO\TBS01.DBF

    sql 语句: alter database datafile  1 online

    sql 语句: alter database datafile  2 online

    sql 语句: alter database datafile  5 online

    启动 recover 于 24-1月 -09

    正在开始介质的恢复

    存档日志线程 1 序列 77 已作为文件 C:\DEMO\ARCHIVE\ARC00077_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 78 已作为文件 C:\DEMO\ARCHIVE\ARC00078_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 79 已作为文件 C:\DEMO\ARCHIVE\ARC00079_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 80 已作为文件 C:\DEMO\ARCHIVE\ARC00080_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 81 已作为文件 C:\DEMO\ARCHIVE\ARC00081_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 82 已作为文件 C:\DEMO\ARCHIVE\ARC00082_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 83 已作为文件 C:\DEMO\ARCHIVE\ARC00083_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 84 已作为文件 C:\DEMO\ARCHIVE\ARC00084_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 85 已作为文件 C:\DEMO\ARCHIVE\ARC00085_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 86 已作为文件 C:\DEMO\ARCHIVE\ARC00086_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 87 已作为文件 C:\DEMO\ARCHIVE\ARC00087_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 88 已作为文件 C:\DEMO\ARCHIVE\ARC00088_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 89 已作为文件 C:\DEMO\ARCHIVE\ARC00089_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 90 已作为文件 C:\DEMO\ARCHIVE\ARC00090_0676208632.001 存在于
    磁盘上
    存档日志线程 1 序列 91 已作为文件 C:\DEMO\ARCHIVE\ARC00091_0676208632.001 存在于
    磁盘上
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00077_0676208632.001 线程 =1 序列 =77
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00078_0676208632.001 线程 =1 序列 =78
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00079_0676208632.001 线程 =1 序列 =79
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00080_0676208632.001 线程 =1 序列 =80
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00081_0676208632.001 线程 =1 序列 =81
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00082_0676208632.001 线程 =1 序列 =82
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00083_0676208632.001 线程 =1 序列 =83
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00084_0676208632.001 线程 =1 序列 =84
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00085_0676208632.001 线程 =1 序列 =85
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00086_0676208632.001 线程 =1 序列 =86
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00087_0676208632.001 线程 =1 序列 =87
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00088_0676208632.001 线程 =1 序列 =88
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00089_0676208632.001 线程 =1 序列 =89
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00090_0676208632.001 线程 =1 序列 =90
    存档日志文件名 =C:\DEMO\ARCHIVE\ARC00091_0676208632.001 线程 =1 序列 =91
    介质恢复完成, 用时: 00:00:26
    完成 recover 于 24-1月 -09

    数据库已打开

    内存脚本的内容:
    {
    # export the tablespaces in the recovery set
    host 'exp userid =\"sys/oracle@ as sysdba\" point_in_time_recover=y tablespaces=

    TBS01 file=
    tspitr_a.dmp';
    # shutdown clone before import
    shutdown clone immediate
    # import the tablespaces in the recovery set
    host 'imp userid =\"sys/demo@demo as sysdba\" point_in_time_recover=y file=
    tspitr_a.dmp';
    # online/offline the tablespace imported
    sql "alter tablespace  TBS01 online";
    sql "alter tablespace  TBS01 offline";
    # enable autobackups in case user does open resetlogs from RMAN after TSPITR
    sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
    }
    正在执行内存脚本

    Export: Release 10.2.0.3.0 - Production on 星期六 1月 24 22:07:28 2009

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

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

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

    数据库已关闭
    数据库已卸载
    Oracle 实例已关闭

    Import: Release 10.2.0.3.0 - Production on 星期六 1月 24 22:07:51 2009

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

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

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

    sql 语句: alter tablespace  TBS01 online

    sql 语句: alter tablespace  TBS01 offline

    sql 语句: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
    已删除辅助实例文件 D:\AUXI\CONTROL01.CTL
    已删除辅助实例文件 D:\AUXI\SYSTEM01.DBF
    已删除辅助实例文件 D:\AUXI\UNDOTBS01.DBF
    已删除辅助实例文件 D:\AUXI\TEMP01.DBF
    已删除辅助实例文件 D:\AUXI\REDO01.LOG
    已删除辅助实例文件 C:\AUXI\REDO01.LOG
    已删除辅助实例文件 D:\AUXI\REDO02.LOG
    已删除辅助实例文件 C:\AUXI\REDO02.LOG
    已删除辅助实例文件 D:\AUXI\REDO03.LOG
    已删除辅助实例文件 C:\AUXI\REDO03.LOG
    完成 recover 于 24-1月 -09

    RMAN> sql 'alter tablespace tbs01 online';

    使用目标数据库控制文件替代恢复目录
    sql 语句: alter tablespace tbs01 online

    RMAN> backup tablespace tbs01 format='d:\demo\bak\%d_%s_%p.bak';

    启动 backup 于 24-1月 -09
    分配的通道: ORA_DISK_1
    通道 ORA_DISK_1: sid=136 devtype=DISK
    通道 ORA_DISK_1: 启动全部数据文件备份集
    通道 ORA_DISK_1: 正在指定备份集中的数据文件
    输入数据文件 fno=00005 name=C:\DEMO\TBS01.DBF
    通道 ORA_DISK_1: 正在启动段 1 于 24-1月 -09
    通道 ORA_DISK_1: 已完成段 1 于 24-1月 -09
    段句柄=D:\DEMO\BAK\DEMO_69_1.BAK 标记=TAG20090124T220955 注释=NONE
    通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:01
    完成 backup 于 24-1月 –09

    RMAN> exit

    恢复管理器完成。

    C:\>sqlplus colin/colin@demo

    SQL*Plus: Release 10.2.0.3.0 - Production on 星期六 1月 24 22:11:44 2009

    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

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

    SQL> select * from tab01;

             C
    ----------
             1
             2

    SQL> exit
    从 Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options 断开

    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

    C:\>del d:\*auxi*.*

  • 相关阅读:
    4.1.4协变和逆变 不常用
    4.1.33匿名方法Lambda语法
    4.1.1委托和广播
    1.4.3用户定义异常类
    1.4.2异常处理
    1.3.6接口判断及显式实现比较
    常用正则表达式
    git
    Pod 操作
    C语言指针的初始化和赋值
  • 原文地址:https://www.cnblogs.com/yiwuya/p/1380873.html
Copyright © 2011-2022 走看看