• 12C RMAN 备份参考v1


    windows bat

    1,C:dbautility man man.bat

    del C:dbautility manfull_db_* /q
    set TNSNAME=ceipuat
    rman target /@%TNSNAME% cmdfile=C:dbautility man man.cmd

    2.C:dbautility man man.cmd

    backup filesperset = 5 as compressed backupset database format 'C:dbautility manfull_db_%U'  plus archivelog  delete all input format 'C:dbautility manfull_db_arch_%U';

    step 0:

    backup scripts:

    backup filesperset = 5 as compressed backupset database format 'C:dbautility manfull_db_%U'  plus archivelog  delete all input format 'C:dbautility manfull_db_arch_%U';

    Step 1: 重启服务器后,oracle 会自动拉起,不需要 操作。

    检查健康方法:

    确认以下服务的状态是 正在运行 的状态

    OracleService****

    OracleOraDB11gHome1TNSListener***

    Step 2:

    确定数据库文件的目录都存在 (C:APPORACLEORADATAsidpdb_name or PDBSEED)

    rman target /

    restore controlfile from autobackup;

    (或者指定的有控制文件 备份的备份集)

    alter  database mount;

    restore database;

    restore arachivelog all;

    recover  database; 

    shutdown immediate;

    startup mount;

    alter database open resetlogs;

    12C引进了pdb的概念,使得rman的恢复相对来说复杂了一些,这里对pdb的常规备份和恢复进行了简单测试,供大家参考


    1.cdb启动和pdb关系测试

    [oracle@xifenfei tmp]$ sqlplus / as sysdba

      

    SQL*Plus: Release 12.1.0.0.2 Beta on Wed Dec 12 23:48:02 2012

      

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

      

      

    Connected to:

    Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit     

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

      

      

    SQL> startup

    ORACLE instance started.

      

    Total System Global Area  939495424 bytes

    Fixed Size                  2267128 bytes

    Variable Size             662702088 bytes

    Database Buffers          268435456 bytes

    Redo Buffers                6090752 bytes

    Database mounted.

    Database opened.

    SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

      

        CON_ID       DBID NAME                           OPEN_MODE

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

             2 4043918109 PDB$SEED                       READ ONLY

             3 2346805300 LX1                            MOUNTED

             4 2385557792 LX2                            MOUNTED

             5 1565384817 FF                             MOUNTED

      

    SQL> alter pluggable database all open;

      

    Pluggable database altered.

      

    SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

      

        CON_ID       DBID NAME                           OPEN_MODE

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

             2 4043918109 PDB$SEED                       READ ONLY

             3 2346805300 LX1                            READ WRITE

             4 2385557792 LX2                            READ WRITE

             5 1565384817 FF                             READ WRITE

    证明直接startup cdb里面的pdb不会自动open,需要手工进行open


    2.rman使用cdb备份数据库

    [oracle@xifenfei ~]$ rman target /

      

    Recovery Manager: Release 12.1.0.0.2        on Wed Dec 12 21:36:08 2012

      

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

      

    connected to target database: xifenfei (DBID=2412861330)

      

    RMAN> backup filesperset = 5 as compressed backupset database format '/tmp/full_db_%U';

      

    Starting backup at 12-DEC-12

    using target database control file instead of recovery catalog

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=259 device type=DISK

    channel ORA_DISK_1: starting compressed full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00001 name=/u01/app/oracle/oradata/xifenfei/system01.dbf

    input datafile file number=00010 name=/u01/app/oracle/oradata/xifenfei/LX2/system01.dbf

    input datafile file number=00011 name=/u01/app/oracle/oradata/xifenfei/LX2/sysaux01.dbf

    channel ORA_DISK_1: starting piece 1 at 12-DEC-12

    channel ORA_DISK_1: finished piece 1 at 12-DEC-12

    piece handle=/tmp/full_db_06nsn3uq_1_1 tag=TAG20121212T213626 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

    channel ORA_DISK_1: starting compressed full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00019 name=/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

    input datafile file number=00005 name=/u01/app/oracle/oradata/xifenfei/undotbs01.dbf

    input datafile file number=00007 name=/u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

    input datafile file number=00018 name=/u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

    input datafile file number=00008 name=/u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

    channel ORA_DISK_1: starting piece 1 at 12-DEC-12

    channel ORA_DISK_1: finished piece 1 at 12-DEC-12

    piece handle=/tmp/full_db_07nsn407_1_1 tag=TAG20121212T213626 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

    channel ORA_DISK_1: starting compressed full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00017 name=/u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

    input datafile file number=00002 name=/u01/app/oracle/oradata/xifenfei/pdbseed/system01.dbf

    input datafile file number=00004 name=/u01/app/oracle/oradata/xifenfei/pdbseed/sysaux01.dbf

    channel ORA_DISK_1: starting piece 1 at 12-DEC-12

    channel ORA_DISK_1: finished piece 1 at 12-DEC-12

    piece handle=/tmp/full_db_08nsn41l_1_1 tag=TAG20121212T213626 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15

    channel ORA_DISK_1: starting compressed full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00003 name=/u01/app/oracle/oradata/xifenfei/sysaux01.dbf

    input datafile file number=00016 name=/u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

    input datafile file number=00006 name=/u01/app/oracle/oradata/xifenfei/users01.dbf

    input datafile file number=00009 name=/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

    input datafile file number=00012 name=/u01/app/oracle/oradata/xifenfei/LX2/LX2_users01.dbf

    channel ORA_DISK_1: starting piece 1 at 12-DEC-12

    channel ORA_DISK_1: finished piece 1 at 12-DEC-12

    piece handle=/tmp/full_db_09nsn440_1_1 tag=TAG20121212T213626 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

    channel ORA_DISK_1: starting compressed 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 12-DEC-12

    channel ORA_DISK_1: finished piece 1 at 12-DEC-12

    piece handle=/tmp/full_db_0ansn45d_1_1 tag=TAG20121212T213626 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 12-DEC-12

      

    RMAN> list backup summary;

      

      

    List of Backups

    ===============

    Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

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

    1       B  F  A DISK        12-DEC-12       1       1       YES        TAG20121212T213250

    2       B  F  A DISK        12-DEC-12       1       1       YES        TAG20121212T213626

    3       B  F  A DISK        12-DEC-12       1       1       YES        TAG20121212T213626

    4       B  F  A DISK        12-DEC-12       1       1       YES        TAG20121212T213626

    5       B  F  A DISK        12-DEC-12       1       1       YES        TAG20121212T213626

    6       B  F  A DISK        12-DEC-12       1       1       YES        TAG20121212T213626

      

    RMAN> report schema;

      

    Report of database schema for database with db_unique_name xifenfei

      

    List of Permanent Datafiles

    ===========================

    File Size(MB) Tablespace           RB segs Datafile Name

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

    1    700      SYSTEM               ***     /u01/app/oracle/oradata/xifenfei/system01.dbf

    2    210      PDB$SEED:SYSTEM      ***     /u01/app/oracle/oradata/xifenfei/pdbseed/system01.dbf

    3    550      SYSAUX               ***     /u01/app/oracle/oradata/xifenfei/sysaux01.dbf

    4    165      PDB$SEED:SYSAUX      ***     /u01/app/oracle/oradata/xifenfei/pdbseed/sysaux01.dbf

    5    310      UNDOTBS1             ***     /u01/app/oracle/oradata/xifenfei/undotbs01.dbf

    6    5        USERS                ***     /u01/app/oracle/oradata/xifenfei/users01.dbf

    7    210      LX1:SYSTEM           ***     /u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

    8    165      LX1:SYSAUX           ***     /u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

    9    5        LX1:USERS            ***     /u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

    10   210      LX2:SYSTEM           ***     /u01/app/oracle/oradata/xifenfei/LX2/system01.dbf

    11   165      LX2:SYSAUX           ***     /u01/app/oracle/oradata/xifenfei/LX2/sysaux01.dbf

    12   5        LX2:USERS            ***     /u01/app/oracle/oradata/xifenfei/LX2/LX2_users01.dbf

    16   270      FF:SYSTEM            ***     /u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

    17   570      FF:SYSAUX            ***     /u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

    18   5        FF:USERS             ***     /u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

    19   341      FF:EXAMPLE           ***     /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

      

    List of Temporary Files

    =======================

    File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

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

    1    530      TEMP                 32767       /u01/app/oracle/oradata/xifenfei/temp01.dbf

    2    20       PDB$SEED:TEMP        32767       /u01/app/oracle/oradata/xifenfei/pdbseed/temp01.dbf

    3    20       LX1:TEMP             32767       /u01/app/oracle/oradata/xifenfei/LX1/temp01.dbf

    4    20       LX2:TEMP             32767       /u01/app/oracle/oradata/xifenfei/LX2/temp01.dbf

    5    20       FF:TEMP              32767       /u01/app/oracle/oradata/xifenfei/xfftemp01.dbf

    试验证明:通过rman通过cdb库的备份,可以实现对对应的cdb和所包含的pdb进行备份


    3.配置pdb访问tns

    [oracle@xifenfei ~]$ lsnrctl status

      

    LSNRCTL for Linux: Version 12.1.0.0.2        on 12-DEC-2012 22:33:27

      

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

      

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

    STATUS of the LISTENER

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

    Alias                     LISTENER

    Version                   TNSLSNR for Linux: Version 12.1.0.0.2       

    Start Date                12-DEC-2012 22:31:55

    Uptime                    0 days 0 hr. 1 min. 32 sec

    Trace Level               off

    Security                  ON: Local OS Authentication

    SNMP                      OFF

    Listener Parameter File   /u01/app/oracle/product/12.1/db_1/network/admin/listener.ora

    Listener Log File         /u01/app/oracle/diag/tnslsnr/xifenfei/listener/alert/log.xml

    Listening Endpoints Summary...

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

      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xifenfei)(PORT=5500))(Presentation=HTTP)(Session=RAW))

    Services Summary...

    Service "ff" has 1 instance(s).

      Instance "xff", status READY, has 1 handler(s) for this service...

    Service "xifenfei" has 1 instance(s).

      Instance "xff", status READY, has 1 handler(s) for this service...

    Service "lx1" has 1 instance(s).

      Instance "xff", status READY, has 1 handler(s) for this service...

    Service "lx2" has 1 instance(s).

      Instance "xff", status READY, has 1 handler(s) for this service...

    Service "xffXDB" has 1 instance(s).

      Instance "xff", status READY, has 1 handler(s) for this service...

    The command completed successfully

      

    [oracle@xifenfei admin]$ vi tnsnames.ora 

    lx1 =

      (DESCRIPTION =

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

        (CONNECT_DATA =

          (SERVER = DEDICATED)

          (SERVICE_NAME = lx1)

        )

      )

    ff =

      (DESCRIPTION =

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

        (CONNECT_DATA =

          (SERVER = DEDICATED)

          (SERVICE_NAME = ff)

        )

      )

    sqlplus访问pdb

    [oracle@xifenfei admin]$ sqlplus sys@lx1 as sysdba

      

    SQL*Plus: Release 12.1.0.0.2 Beta on Wed Dec 12 22:35:07 2012

      

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

      

    Enter password: 

      

    Connected to:

    Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit     

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

      

    SQL> show con_name;

      

    CON_NAME

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

    LX1

      

    SQL> create user xff identified by xifenfei;

      

    User created.

      

    SQL> GRANT SYSDBA TO XFF;

      

    Grant succeeded.

    4.rman备份pdb数据库

    [oracle@xifenfei admin]$ rman target xff/xifenfei@lx1

      

    Recovery Manager: Release 12.1.0.0.2        on Wed Dec 12 22:44:46 2012

      

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

      

    connected to target database: xifenfei (DBID=2412861330)

      

    RMAN> backup filesperset = 5 as compressed backupset database format '/tmp/lx1_db_%U';

      

    Starting backup at 12-DEC-12

    using target database control file instead of recovery catalog

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=256 device type=DISK

    channel ORA_DISK_1: starting compressed full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00007 name=/u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

    input datafile file number=00008 name=/u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

    input datafile file number=00009 name=/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

    channel ORA_DISK_1: starting piece 1 at 12-DEC-12

    channel ORA_DISK_1: finished piece 1 at 12-DEC-12

    piece handle=/tmp/lx1_db_0bnsn80f_1_1 tag=TAG20121212T224534 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

    Finished backup at 12-DEC-12

      

    RMAN> report schema;

      

    Report of database schema for database with db_unique_name xifenfei

      

    List of Permanent Datafiles

    ===========================

    File Size(MB) Tablespace           RB segs Datafile Name

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

    7    210      LX1:SYSTEM           ***     /u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

    8    165      LX1:SYSAUX           ***     /u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

    9    5        LX1:USERS            ***     /u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

      

    List of Temporary Files

    =======================

    File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

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

    3    20       LX1:TEMP             32767       /u01/app/oracle/oradata/xifenfei/LX1/temp01.dbf

    5.rman通过cdb备份pdb

    [oracle@xifenfei admin]$ rman target /

      

    Recovery Manager: Release 12.1.0.0.2        on Wed Dec 12 23:02:07 2012

      

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

      

    connected to target database: xifenfei (DBID=2412861330)

      

    RMAN> backup filesperset = 5 as compressed backupset pluggable database FF format '/tmp/ff_db_%U';

      

    Starting backup at 12-DEC-12

    using target database control file instead of recovery catalog

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=262 device type=DISK

    channel ORA_DISK_1: starting compressed full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    input datafile file number=00017 name=/u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

    input datafile file number=00019 name=/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

    input datafile file number=00016 name=/u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

    input datafile file number=00018 name=/u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

    channel ORA_DISK_1: starting piece 1 at 12-DEC-12

    channel ORA_DISK_1: finished piece 1 at 12-DEC-12

    piece handle=/tmp/ff_db_0cnsn8vm_1_1 tag=TAG20121212T230214 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26

    Finished backup at 12-DEC-12

    6.模拟pdb库全库恢复

    SQL> conn xff/xifenfei@lx1 as sysdba

    Connected.

      

    SQL> create table t_xifenfei as select * from dba_objects;

      

    Table created.

      

    SQL> select count(*) from t_xifenfei;

      

      COUNT(*)

    ----------

         19121

      

    --在pdb中不能切换日志(因为日志是全局的)

    SQL> alter system switch logfile;

    alter system switch logfile

    *

    ERROR at line 1:

    ORA-65040: operation not allowed from within a pluggable database

      

    SQL> shutdown immediate;

    Pluggable Database closed.

      

    --删除数据文件

    [oracle@xifenfei admin]$ rm /u01/app/oracle/oradata/xifenfei/LX1/*

      

    --rman基于cdb恢复pdb库

    [oracle@xifenfei ~]$ rman target /

      

    Recovery Manager: Release 12.1.0.0.2        on Wed Dec 12 23:11:22 2012

      

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

      

    connected to target database: xifenfei (DBID=2412861330)

      

    RMAN> restore pluggable database lx1;

      

    Starting restore at 12-DEC-12

    using target database control file instead of recovery catalog

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=25 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 00007 to /u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

    channel ORA_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

    channel ORA_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

    channel ORA_DISK_1: reading from backup piece /tmp/lx1_db_0bnsn80f_1_1

    channel ORA_DISK_1: piece handle=/tmp/lx1_db_0bnsn80f_1_1 tag=TAG20121212T224534

    channel ORA_DISK_1: restored backup piece 1

    channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

    Finished restore at 12-DEC-12

      

    RMAN> recover pluggable database lx1;

      

    Starting recover at 12-DEC-12

    using channel ORA_DISK_1

      

    starting media recovery

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

      

    Finished recover at 12-DEC-12

      

    RMAN> alter pluggable database lx1 open;

      

    Statement processed

      

    --验证恢复结果

    SQL> conn xff/xifenfei@lx1 as sysdba

    Connected.

      

    SQL> select count(*) from t_xifenfei;

      

      COUNT(*)

    ----------

         19121

    试验证明:对于pdb库的备份,使用rman可以在cdb级别进行还原和恢复


    7.模拟数据文件恢复

    SQL> create table t_xifenfei tablespace example

      2   as

      3    select * from dba_objects;

      

    Table created.

      

    SQL> select count(*) from t_xifenfei;

      

      COUNT(*)

    ----------

         89604

      

    SQL> col name for a60 

    SQL> set lines 134

    SQL> select file#,name from v$datafile;

      

         FILE# NAME

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

             5 /u01/app/oracle/oradata/xifenfei/undotbs01.dbf

            16 /u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

            17 /u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

            18 /u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

            19 /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

      

    --离线含测试数据的数据文件

    SQL> alter database datafile 19 offline;

      

    Database altered.

      

    --删除数据文件

    SQL> !rm /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

      

    SQL> !ls -l /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

    ls: /u01/app/oracle/oradata/xifenfei/xffexample01.dbf: No such file or directory

      

      

    --尝试pdb级别恢复

    [oracle@xifenfei ~]$ rman target sys/xifenfei@ff

      

    Recovery Manager: Release 12.1.0.0.2        on Wed Dec 12 23:29:03 2012

      

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

      

    connected to target database: xifenfei (DBID=2412861330)

      

    RMAN> restore datafile 19;

      

    Starting restore at 12-DEC-12

    using target database control file instead of recovery catalog

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=19 device type=DISK

      

    RMAN-00571: ===========================================================

    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

    RMAN-00571: ===========================================================

    RMAN-03002: failure of restore command at 12/12/2012 23:29:15

    RMAN-06026: some targets not found - aborting restore

    RMAN-06023: no backup or copy of datafile 19 found to restore

      

    --pdb级别不能识别对应数据文件(一种可能是我在cdb级别备份FF库,另一种可能bug)

    RMAN> list backup of datafile 19;

      

    specification does not match any backup in the repository

      

    --在cdb级别还原

    [oracle@xifenfei tmp]$ rman target /

      

    Recovery Manager: Release 12.1.0.0.2        on Wed Dec 12 23:44:21 2012

      

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

      

    connected to target database: xifenfei (DBID=2412861330)

      

    RMAN> list backup of datafile 19;

      

    using target database control file instead of recovery catalog

      

    List of Backup Sets

    ===================

      

      

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

    3       Full    76.81M     DISK        00:00:44     12-DEC-12      

            BP Key: 3   Status: AVAILABLE  Compressed: YES  Tag: TAG20121212T213626

            Piece Name: /tmp/full_db_07nsn407_1_1

      List of Datafiles in backup set 3

      File LV Type Ckp SCN    Ckp Time  Name

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

      19      Full 1860043    12-DEC-12 /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

      

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

    8       Full    189.52M    DISK        00:01:25     12-DEC-12      

            BP Key: 8   Status: AVAILABLE  Compressed: YES  Tag: TAG20121212T230214

            Piece Name: /tmp/ff_db_0cnsn8vm_1_1

      List of Datafiles in backup set 8

      File LV Type Ckp SCN    Ckp Time  Name

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

      19      Full 1860043    12-DEC-12 /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

      

    RMAN> restore datafile 19;

      

    Starting restore at 12-DEC-12

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=28 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 00019 to /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

    channel ORA_DISK_1: reading from backup piece /tmp/ff_db_0cnsn8vm_1_1

    channel ORA_DISK_1: piece handle=/tmp/ff_db_0cnsn8vm_1_1 tag=TAG20121212T230214

    channel ORA_DISK_1: restored backup piece 1

    channel ORA_DISK_1: restore complete, elapsed time: 00:00:45

    Finished restore at 12-DEC-12

      

    --cdb级别恢复数据文件

    RMAN> recover datafile 19;

      

    Starting recover at 12-DEC-12

    using channel ORA_DISK_1

      

    starting media recovery

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

      

    Finished recover at 12-DEC-12

      

    --cdb级别不能直接online

    RMAN> alter database datafile 19 online;

      

    RMAN-00571: ===========================================================

    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

    RMAN-00571: ===========================================================

    RMAN-03002: failure of sql statement command at 12/12/2012 23:46:15

    ORA-01516: nonexistent log file, data file, or temporary file "19"

      

    RMAN> alter pluggable database ff datafile 19 online;

      

    RMAN-00571: ===========================================================

    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

    RMAN-00571: ===========================================================

    RMAN-03002: failure of sql statement command at 12/12/2012 23:47:53

    ORA-65046: operation not allowed from outside a pluggable database

      

    --进入pdb库进行online

    SQL> alter database datafile 19 online;               

      

    Database altered.

      

    --验证数据

    SQL> select count(*) from t_xifenfei;

      

      COUNT(*)

    ----------

         89604

    试验证明:rman通过cdb级别操作,还是一步步恢复了pdb中离线异常的数据文件

    8.pdb数据库冷备恢复

     pdb数据库冷备恢复不需要完全关闭cdb数据库,只需要pdb数据库启动到mounted状态即可。

    1.确保需要冷备的pdb1的open mode是mounted状态
    SQL> show pdbs


        CON_ID CON_NAME  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    2 PDB$SEED  READ ONLY  NO
    3 PDB  READ WRITE NO
    4 PDB1  MOUNTED


    2.备份pdb1
    [oracle@ora12c cdb]$ cp -r pdb1 pdb_bak
    3.删除pdb1
    [oracle@ora12c cdb]$ rm -rf pdb1
    4.把pdb1数据库open
    SQL> alter pluggable database pdb1 open;
    alter pluggable database pdb1 open
    *
    ERROR at line 1:
    ORA-01157: cannot identify/lock data file 44 - see DBWR trace file
    ORA-01110: data file 44: '/u01/app/oracle/oradata/cdb/pdb1/pdb_users01.dbf'
    5.利用冷备还原
    [oracle@ora12c cdb]$ mv pdb_bak pdb1
    6.重新把pdb1数据库open。
    SQL> alter pluggable database pdb1 open;


    Pluggable database altered.


    SQL> show pdbs


        CON_ID CON_NAME  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    2 PDB$SEED  READ ONLY  NO
    3 PDB  READ WRITE NO
    4 PDB1  READ WRITE NO

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

     pdb数据库冷备恢复不需要完全关闭cdb数据库,只需要pdb数据库启动到mounted状态即可。

    1.确保需要冷备的pdb1的open mode是mounted状态
    SQL> show pdbs


        CON_ID CON_NAME  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    2 PDB$SEED  READ ONLY  NO
    3 PDB  READ WRITE NO
    4 PDB1  MOUNTED


    2.备份pdb1
    [oracle@ora12c cdb]$ cp -r pdb1 pdb_bak
    3.删除pdb1
    [oracle@ora12c cdb]$ rm -rf pdb1
    4.把pdb1数据库open
    SQL> alter pluggable database pdb1 open;
    alter pluggable database pdb1 open
    *
    ERROR at line 1:
    ORA-01157: cannot identify/lock data file 44 - see DBWR trace file
    ORA-01110: data file 44: '/u01/app/oracle/oradata/cdb/pdb1/pdb_users01.dbf'
    5.利用冷备还原
    [oracle@ora12c cdb]$ mv pdb_bak pdb1
    6.重新把pdb1数据库open。
    SQL> alter pluggable database pdb1 open;


    Pluggable database altered.


    SQL> show pdbs


        CON_ID CON_NAME  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    2 PDB$SEED  READ ONLY  NO
    3 PDB  READ WRITE NO
    4 PDB1  READ WRITE NO

  • 相关阅读:
    双向认证SSL原理
    p12证书转keystore签名
    Loadrunner对https协议(单双向SSL)的web端性能测试
    关于Unity中新版动画系统的使用
    关于Unity中旧版动画系统的使用
    关于Unity中Mesh网格的详解
    关于Unity中Time.deltaTime的使用
    关于Unity中的光照(七)
    关于Unity中的光照(六)
    关于Unity中的光照(五)
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/6269568.html
Copyright © 2020-2023  润新知