zoukankan      html  css  js  c++  java
  • 【Oracle】RMAN duplicate复制库

    基础环境:

    • 172.17.4.60 操作系统:Linux 6.4 数据库:Oracle11gR2 (源数据库)
    • 172.17.4.61 操作系统:Linux 6.4 数据库:Oracle11gR2 (测试库)

    目的:从源数据库以RMAN的物理恢复的方式,恢复至测试库中。
    如何验证,在源数据库,插入几条数据如下:

    SYS@oradb> create user zsd identified by zsd;
    
    User created.
    
    SYS@oradb> grant dba to zsd;
    
    Grant succeeded.
    
    SYS@oradb> conn zsd/zsd;
    Connected.
    
    ZSD@oradb> create table t1(name varchar2(20));
    
    Table created.
    
    ZSD@oradb> insert into t1 values('zsd');
    
    1 row created.
    
    ZSD@oradb> insert into t1 values('lzh');
    
    1 row created.
    
    ZSD@oradb> insert into t1 values('zjf');
    
    1 row created.
    
    ZSD@oradb> commit;
    
    Commit complete.
    
    ZSD@oradb> select * from t1;
    
    NAME
    --------------------
    zsd
    lzh
    zjf
    

    Step 0.基础环境的host配置

    两台服务器都需要做如下配置。

    [oracle@db1 ~]$ cat /etc/hosts
    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    172.17.4.60 db1
    172.17.4.61 db2
    

    源数据库端(172.17.4.60):

    [oracle@db1 ~]$ cat /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=db1
    

    测试数据库端(172.17.4.61):

    [oracle@db2 ~]$ cat /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=db2
    

    Step 1.修改环境变量

    [oracle@db dbs]$ cd ~
    [oracle@db ~]$ vi .bash_profile 
    

    修改ORACLE_SID与源数据库一致,如下:
    ORACLE_SID=oradb

    Step 2.建立pfile dummy文件

    [oracle@db ~]$ cd $ORACLE_HOME/dbs
    [oracle@db dbs]$ vi dummy.ora
    db_name='zsddummy'
    

    Step 3.从源数据库(172.17.4.60)复制口令文件至测试库(172.17.4.61)。

    [oracle@db dbs]$ pwd
    /u01/app/product/11.2.0/db_1/dbs
    [oracle@db dbs]$ scp 172.17.4.60:/u01/app/product/11.2.0/db_1/dbs/orapworadb ./
    
    
    [oracle@db dbs]$ ls -lht
    总用量 20K
    -rw-r-----. 1 oracle oinstall 1.5K 12月 29 15:48 orapworadb
    -rw-r--r--. 1 oracle oinstall   19 12月 29 15:44 dummy.ora
    -rw-rw----. 1 oracle oinstall 1.6K 12月 29 15:27 hc_oradb.dat
    -rw-r-----. 1 oracle oinstall   24 5月  15 2017 lkORADB
    -rw-r--r--. 1 oracle oinstall 2.8K 5月  15 2009 init.ora
    

    Step 4.创建相应目录

    • 4.1 审计目录

    源数据库端(172.17.4.60):

    SYS@oradb> show parameter audit_file_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    audit_file_dest                      string      /u01/app/admin/oradb/adump
    

    测试数据库端(172.17.4.61):

    [oracle@db oradb]$ mkdir -p /u01/app/admin/oradb/adump
    
    • 4.2 快速恢复区目录

    源数据库端(172.17.4.60):

    SYS@oradb> show parameter db_recovery_file_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_recovery_file_dest                string      /u01/app/fast_recovery_area
    db_recovery_file_dest_size           big integer 4182M
    

    测试数据库端(172.17.4.61):

    [oracle@db oradb]$ mkdir -p /u01/app/fast_recovery_area
    
    • 4.3 数据目录

    源数据库端(172.17.4.60):

    SYS@oradb> select name from v$dbfile;
    
    NAME
    --------------------------------------------------------------------------------
    /u01/app/oradata/oradb/users01.dbf
    /u01/app/oradata/oradb/undotbs01.dbf
    /u01/app/oradata/oradb/sysaux01.dbf
    /u01/app/oradata/oradb/system01.dbf
    

    测试数据库端(172.17.4.61):

    [oracle@db oradb]$ mkdir -p /u01/app/oradata/oradb/
    [oracle@db oradb]$ ls -ld /u01/app/oradata/oradb/
    drwxr-x---. 2 oracle oinstall 4096 12月 29 15:27 /u01/app/oradata/oradb/
    

    Step 5.net服务

    测试数据库端(172.17.4.61):

    [oracle@db2 ~]$ cat /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    # listener.ora Network Configuration File: /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = db2)(PORT = 1521))
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        )
      )
    SID_LIST_LISTENER =  
    (SID_LIST =  
      (SID_DESC =  
      (GLOBAL_DBNAME = oradb.zsd.com)
      (ORACLE_HOME=/u01/app/product/11.2.0/db_1)
      (SID_NAME = oradb)
      )
    )
    ADR_BASE_LISTENER = /u01/app
    

    测试库的监听启动:

    [oracle@db2 admin]$ lsnrctl start
    
    LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 29-DEC-2018 16:03:01
    
    Copyright (c) 1991, 2013, Oracle.  All rights reserved.
    
    Starting /u01/app/product/11.2.0/db_1/bin/tnslsnr: please wait...
    
    TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    System parameter file is /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    Log messages written to /u01/app/diag/tnslsnr/db/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db2)(PORT=1521)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db2)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    Start Date                29-DEC-2018 16:03:01
    Uptime                    0 days 0 hr. 0 min. 10 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    Listener Log File         /u01/app/diag/tnslsnr/db/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db2)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    Services Summary...
    Service "oradb.zsd.com" has 1 instance(s).
      Instance "oradb", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully
    

    源数据端:172.17.4.60

    [oracle@db1 ~]$ cat /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    # listener.ora Network Configuration File: /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        )
      )
    SID_LIST_LISTENER =  
    (SID_LIST =  
      (SID_DESC =  
      (GLOBAL_DBNAME = oradb.zsd.com)
      (SID_NAME = oradb)
      )
    )
    ADR_BASE_LISTENER = /u01/app
    

    源数据端的监听启动:

    [oracle@db admin]$ lsnrctl start
    
    LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 29-DEC-2018 16:06:02
    
    Copyright (c) 1991, 2013, Oracle.  All rights reserved.
    
    Starting /u01/app/product/11.2.0/db_1/bin/tnslsnr: please wait...
    
    TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    System parameter file is /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    Log messages written to /u01/app/diag/tnslsnr/db/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db1)(PORT=1521)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db1)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    Start Date                29-DEC-2018 16:06:03
    Uptime                    0 days 0 hr. 0 min. 11 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/product/11.2.0/db_1/network/admin/listener.ora
    Listener Log File         /u01/app/diag/tnslsnr/db/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db1)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    Services Summary...
    Service "oradb.zsd.com" has 1 instance(s).
      Instance "oradb", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully
    

    两端配置tns文件(60和61配置的相同)

    vi $ORACLE_HOME/network/admin/tnsnames.ora
    
    ZSDDB =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = oradb.zsd.com)
        )
      )
    
    aux =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = db2)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = oradb.zsd.com)
        )
      )
    

    源数据端(172.17.4.60)连接测试库

    [oracle@db1 ~]$ tnsping aux
    
    TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 29-DEC-2018 16:16:52
    
    Copyright (c) 1997, 2013, Oracle.  All rights reserved.
    
    Used parameter files:
    
    
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = db2)(PORT = 1521))) (CONNECT_DATA = 
    
    (SERVICE_NAME = oradb.zsd.com)))
    OK (0 msec)
    [oracle@db1 ~]$ sqlplus sys/oracle@aux as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 29 16:17:06 2018
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    Connected to an idle instance.
    
    SYS@aux>
    

    测试端(172.17.4.61):测试源数据库

    [oracle@db2 ~]$ tnsping zsddb
    
    TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 29-DEC-2018 16:21:23
    
    Copyright (c) 1997, 2013, Oracle.  All rights reserved.
    
    Used parameter files:
    
    
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))) (CONNECT_DATA = 
    
    (SERVICE_NAME = oradb.zsd.com)))
    OK (70 msec)
    
    [oracle@db2 ~]$ sqlplus sys/oracle@zsddb as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 29 16:21:47 2018
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SYS@zsddb> 
    

    Step 6.测试数据库(172.17.4.61)以nomout的格式打开。

    [oracle@db2 ~]$ sqlplus / as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 29 16:23:55 2018
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    Connected to an idle instance.
    
    SYS@oradb> startup nomount pfile=$ORACLE_HOME/dbs/dummy.ora
    ORACLE instance started.
    
    Total System Global Area  263090176 bytes
    Fixed Size                  2252256 bytes
    Variable Size             205521440 bytes
    Database Buffers           50331648 bytes
    Redo Buffers                4984832 bytes
    

    测试端(172.17.4.61)rman连接源数据库和辅助库:

    [oracle@db2 ~]$ rman target sys/oracle@zsddb auxiliary sys/oracle@aux
    
    Recovery Manager: Release 11.2.0.4.0 - Production on Sat Dec 29 16:25:33 2018
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    connected to target database: ORADB (DBID=2697310494)
    connected to auxiliary database: ZSDDUMMY (not mounted)
    

    Step 7.开始 RMAN duplicate通过网络复制数据库

    测试端(172.17.4.61)开始 RMAN 通过网络复制数据库

    RMAN> duplicate target database to zsddb from active database spfile nofilenamecheck;
    

    日志如下:

    Starting Duplicate Db at 02-JAN-19
    using target database control file instead of recovery catalog
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=429 device type=DISK
    
    contents of Memory Script:
    {
       backup as copy reuse
       targetfile  '/u01/app/product/11.2.0/db_1/dbs/spfileoradb.ora' auxiliary format 
     '/u01/app/product/11.2.0/db_1/dbs/spfileoradb.ora'   ;
       sql clone "alter system set spfile= ''/u01/app/product/11.2.0/db_1/dbs/spfileoradb.ora''";
    }
    executing Memory Script
    
    Starting backup at 02-JAN-19
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=10 device type=DISK
    Finished backup at 02-JAN-19
    
    sql statement: alter system set spfile= ''/u01/app/product/11.2.0/db_1/dbs/spfileoradb.ora''
    
    contents of Memory Script:
    {
       sql clone "alter system set  db_name = 
     ''ZSDDB'' comment=
     ''duplicate'' scope=spfile";
       shutdown clone immediate;
       startup clone nomount;
    }
    executing Memory Script
    
    sql statement: alter system set  db_name =  ''ZSDDB'' comment= ''duplicate'' scope=spfile
    
    Oracle instance shut down
    
    connected to auxiliary database (not started)
    Oracle instance started
    
    Total System Global Area    1202556928 bytes
    
    Fixed Size                     2252704 bytes
    Variable Size                419430496 bytes
    Database Buffers             771751936 bytes
    Redo Buffers                   9121792 bytes
    
    contents of Memory Script:
    {
       sql clone "alter system set  db_name = 
     ''ORADB'' comment=
     ''Modified by RMAN duplicate'' scope=spfile";
       sql clone "alter system set  db_unique_name = 
     ''ZSDDB'' comment=
     ''Modified by RMAN duplicate'' scope=spfile";
       shutdown clone immediate;
       startup clone force nomount
       backup as copy current controlfile auxiliary format  '/u01/app/oradata/oradb/control01.ctl';
       restore clone controlfile to  '/u01/app/fast_recovery_area/oradb/control02.ctl' from 
     '/u01/app/oradata/oradb/control01.ctl';
       alter clone database mount;
    }
    executing Memory Script
    
    sql statement: alter system set  db_name =  ''ORADB'' comment= ''Modified by RMAN duplicate'' scope=spfile
    
    sql statement: alter system set  db_unique_name =  ''ZSDDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
    
    Oracle instance shut down
    
    Oracle instance started
    
    Total System Global Area    1202556928 bytes
    
    Fixed Size                     2252704 bytes
    Variable Size                419430496 bytes
    Database Buffers             771751936 bytes
    Redo Buffers                   9121792 bytes
    
    Starting backup at 02-JAN-19
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    copying current control file
    output file name=/u01/app/product/11.2.0/db_1/dbs/snapcf_oradb.f tag=TAG20190102T144945 RECID=2 STAMP=996504585
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 02-JAN-19
    
    Starting restore at 02-JAN-19
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=85 device type=DISK
    
    channel ORA_AUX_DISK_1: copied control file copy
    Finished restore at 02-JAN-19
    
    database mounted
    RMAN-05538: WARNING: implicitly using DB_FILE_NAME_CONVERT
    
    contents of Memory Script:
    {
       set newname for datafile  1 to 
     "/u01/app/oradata/oradb/system01.dbf";
       set newname for datafile  2 to 
     "/u01/app/oradata/oradb/sysaux01.dbf";
       set newname for datafile  3 to 
     "/u01/app/oradata/oradb/undotbs01.dbf";
       set newname for datafile  4 to 
     "/u01/app/oradata/oradb/users01.dbf";
       backup as copy reuse
       datafile  1 auxiliary format 
     "/u01/app/oradata/oradb/system01.dbf"   datafile 
     2 auxiliary format 
     "/u01/app/oradata/oradb/sysaux01.dbf"   datafile 
     3 auxiliary format 
     "/u01/app/oradata/oradb/undotbs01.dbf"   datafile 
     4 auxiliary format 
     "/u01/app/oradata/oradb/users01.dbf"   ;
       sql 'alter system archive log current';
    }
    executing Memory Script
    
    executing command: SET NEWNAME
    
    executing command: SET NEWNAME
    
    executing command: SET NEWNAME
    
    executing command: SET NEWNAME
    
    Starting backup at 02-JAN-19
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00001 name=/u01/app/oradata/oradb/system01.dbf
    output file name=/u01/app/oradata/oradb/system01.dbf tag=TAG20190102T144953
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00002 name=/u01/app/oradata/oradb/sysaux01.dbf
    output file name=/u01/app/oradata/oradb/sysaux01.dbf tag=TAG20190102T144953
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00003 name=/u01/app/oradata/oradb/undotbs01.dbf
    output file name=/u01/app/oradata/oradb/undotbs01.dbf tag=TAG20190102T144953
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00004 name=/u01/app/oradata/oradb/users01.dbf
    output file name=/u01/app/oradata/oradb/users01.dbf tag=TAG20190102T144953
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
    Finished backup at 02-JAN-19
    
    sql statement: alter system archive log current
    
    contents of Memory Script:
    {
       backup as copy reuse
       archivelog like  "/u01/app/fast_recovery_area/ORADB/archivelog/2019_01_02/o1_mf_1_12_g2rqto2s_.arc" auxiliary format 
     "/u01/app/fast_recovery_area/ZSDDB/archivelog/2019_01_02/o1_mf_1_12_%u_.arc"   ;
       catalog clone recovery area;
       switch clone datafile all;
    }
    executing Memory Script
    
    Starting backup at 02-JAN-19
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting archived log copy
    input archived log thread=1 sequence=12 RECID=7 STAMP=996504662
    output file name=/u01/app/fast_recovery_area/ZSDDB/archivelog/2019_01_02/o1_mf_1_12_0btmat2m_.arc RECID=0 STAMP=0
    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
    Finished backup at 02-JAN-19
    
    searching for all files in the recovery area
    
    List of Files Unknown to the Database
    =====================================
    File Name: /u01/app/fast_recovery_area/ZSDDB/archivelog/2019_01_02/o1_mf_1_12_0btmat2m_.arc
    cataloging files...
    cataloging done
    
    List of Cataloged Files
    =======================
    File Name: /u01/app/fast_recovery_area/ZSDDB/archivelog/2019_01_02/o1_mf_1_12_0btmat2m_.arc
    
    datafile 1 switched to datafile copy
    input datafile copy RECID=2 STAMP=996504659 file name=/u01/app/oradata/oradb/system01.dbf
    datafile 2 switched to datafile copy
    input datafile copy RECID=3 STAMP=996504659 file name=/u01/app/oradata/oradb/sysaux01.dbf
    datafile 3 switched to datafile copy
    input datafile copy RECID=4 STAMP=996504659 file name=/u01/app/oradata/oradb/undotbs01.dbf
    datafile 4 switched to datafile copy
    input datafile copy RECID=5 STAMP=996504659 file name=/u01/app/oradata/oradb/users01.dbf
    
    contents of Memory Script:
    {
       set until scn  1150015;
       recover
       clone database
        delete archivelog
       ;
    }
    executing Memory Script
    
    executing command: SET until clause
    
    Starting recover at 02-JAN-19
    using channel ORA_AUX_DISK_1
    
    starting media recovery
    
    archived log for thread 1 with sequence 12 is already on disk as file /u01/app/fast_recovery_area/ZSDDB/archivelog/2019_01_02/o1_mf_1_12_0btmat2m_.arc
    archived log file name=/u01/app/fast_recovery_area/ZSDDB/archivelog/2019_01_02/o1_mf_1_12_0btmat2m_.arc thread=1 sequence=12
    media recovery complete, elapsed time: 00:00:00
    Finished recover at 02-JAN-19
    Oracle instance started
    
    Total System Global Area    1202556928 bytes
    
    Fixed Size                     2252704 bytes
    Variable Size                419430496 bytes
    Database Buffers             771751936 bytes
    Redo Buffers                   9121792 bytes
    
    contents of Memory Script:
    {
       sql clone "alter system set  db_name = 
     ''ZSDDB'' comment=
     ''Reset to original value by RMAN'' scope=spfile";
       sql clone "alter system reset  db_unique_name scope=spfile";
       shutdown clone immediate;
       startup clone nomount;
    }
    executing Memory Script
    
    sql statement: alter system set  db_name =  ''ZSDDB'' comment= ''Reset to original value by RMAN'' scope=spfile
    
    sql statement: alter system reset  db_unique_name scope=spfile
    
    Oracle instance shut down
    
    connected to auxiliary database (not started)
    Oracle instance started
    
    Total System Global Area    1202556928 bytes
    
    Fixed Size                     2252704 bytes
    Variable Size                419430496 bytes
    Database Buffers             771751936 bytes
    Redo Buffers                   9121792 bytes
    sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ZSDDB" RESETLOGS ARCHIVELOG 
      MAXLOGFILES     16
      MAXLOGMEMBERS      3
      MAXDATAFILES      100
      MAXINSTANCES     8
      MAXLOGHISTORY      292
     LOGFILE
      GROUP   1  SIZE 50 M ,
      GROUP   2  SIZE 50 M ,
      GROUP   3  SIZE 50 M 
     DATAFILE
      '/u01/app/oradata/oradb/system01.dbf'
     CHARACTER SET ZHS16GBK
    
    
    contents of Memory Script:
    {
       set newname for tempfile  1 to 
     "/u01/app/oradata/oradb/temp01.dbf";
       switch clone tempfile all;
       catalog clone datafilecopy  "/u01/app/oradata/oradb/sysaux01.dbf", 
     "/u01/app/oradata/oradb/undotbs01.dbf", 
     "/u01/app/oradata/oradb/users01.dbf";
       switch clone datafile all;
    }
    executing Memory Script
    
    executing command: SET NEWNAME
    
    renamed tempfile 1 to /u01/app/oradata/oradb/temp01.dbf in control file
    
    cataloged datafile copy
    datafile copy file name=/u01/app/oradata/oradb/sysaux01.dbf RECID=1 STAMP=996504682
    cataloged datafile copy
    datafile copy file name=/u01/app/oradata/oradb/undotbs01.dbf RECID=2 STAMP=996504682
    cataloged datafile copy
    datafile copy file name=/u01/app/oradata/oradb/users01.dbf RECID=3 STAMP=996504682
    
    datafile 2 switched to datafile copy
    input datafile copy RECID=1 STAMP=996504682 file name=/u01/app/oradata/oradb/sysaux01.dbf
    datafile 3 switched to datafile copy
    input datafile copy RECID=2 STAMP=996504682 file name=/u01/app/oradata/oradb/undotbs01.dbf
    datafile 4 switched to datafile copy
    input datafile copy RECID=3 STAMP=996504682 file name=/u01/app/oradata/oradb/users01.dbf
    
    contents of Memory Script:
    {
       Alter clone database open resetlogs;
    }
    executing Memory Script
    
    database opened
    Finished Duplicate Db at 02-JAN-19
    

    最后,在测试库中,验证我的rman duplicate是否成功,查询验证数据,如下:

    [oracle@db2 ~]$ sqlplus "/as sysdba"
    
    SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 2 14:55:14 2019
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SYS@oradb> conn zsd/zsd;
    Connected.
    ZSD@oradb> select * from t1;
    
    NAME
    --------------------
    zsd
    lzh
    zjf
    

    enjoy!just for fun

  • 相关阅读:
    sql server 数据库优化显示执行计划
    你真的了解SQL的索引吗?
    温习Remoting基础
    sql 百万级数据库优化方案
    MYSQL——查看显示数据库
    输入框【普通输入框,邮箱输入框,验证码输入框,手机号码输入框】的测试用例规范
    一个完整的测试计划包含哪些内容?
    MYSQL——多表查询
    软件测试功能性需求(Functional requirement)+非功能性需求(Nonfunctional requirement)
    【自动化测试01】如何配置Android SDK环境变量
  • 原文地址:https://www.cnblogs.com/zhangshengdong/p/11725225.html
Copyright © 2011-2022 走看看