rman duplicate操作手冊

yingyifeng306發表於2021-05-06

說明

資料庫為 12.2.0.1.0RAC 環境,目標升級為 12.2.0.1.11 環境,作業系統為 RHEL6.6

原環境:

資料庫模式

RAC

IP 地址分配


32BIT/64BIT

64 bit

作業系統版本

RHEL5.3

ORACLE 版本

12.2.0.1

ORACLE_SID


 

目標環境:

資料庫模式

RAC

IP 地址分配


32BIT/64BIT

64 bit

作業系統版本

RHEL6.6

ORACLE 版本

12.2.0.1

ORACLE_SID


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

前期輔助例項安裝

前提:裝好資料庫軟體,不建立資料庫,且有 oracle 使用者,首先建立輔助例項

為輔助例項建立密碼檔案

直接從原生產複製密碼檔案至複製庫端

 

建立必要的目錄

[oracle@node2 admin]$ mkdir -p /oracle/app/admin/ora11g/adump

[oracle@node2 admin]$ mkdir -p /oracle/app/oradata/ora11g/

 

配置靜態監聽

[oracle@node2 admin]$ vi listener.ora

 

        (GLOBAL_DBNAME = woo.com)

# listener.ora Network Configuration File: /oracle/app/product/11.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

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

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

  )

SID_LIST_LISTENER =

(SID_LIST =

  (SID_DESC =

    (SID_NAME = orcl)

    (ORACLE_HOME = /oracle/app/product/12.2.0/db_1)

    (GLOBAL_DBNAME = orcl)

  )

)

 

配置所有節點 tnsname 資訊如下 :

ORCL =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

orcldg =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

建立輔助例項的初始化引數檔案

將在原生產上建立的 pfile 複製到複製庫,引數和原生產庫保持一致,並啟動到 nomount 狀態

 

生產端產生 pfile

 

SQL> create pfile='/tmp/upgrade/initora11g.ora' from spfile;

 

File created.

將引數檔案複製到複製庫相應位置

 

啟動資料庫到 nomount 狀態

[oracle@node2 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 24 11:29:05 2017

 

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

 

Connected to an idle instance.

 

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  839282688 bytes

Fixed Size                  2257880 bytes

Variable Size             545262632 bytes

Database Buffers          289406976 bytes

Redo Buffers                2355200 bytes

 

SQL> create spfile from pfile;

 

File created.

 

複製資料庫

同時連線到目標庫和複製庫

[oracle@node2 ~]$ rman target sys/oracle@orcl auxiliary sys/oracle@orcldg

 

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Mar 24 11:40:58 2017

 

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

 

PL/SQL package SYS.DBMS_BACKUP_RESTORE version 11.02.00.02 in TARGET database is not current

PL/SQL package SYS.DBMS_RCVMAN version 11.02.00.02 in TARGET database is not current

connected to target database: ORA11G (DBID=40693715)

connected to auxiliary database: ORA11G (not mounted)

RMAN>

 

 

複製資料庫

RMAN> duplicate target database for standby from active database nofilenamecheck; 

 

Starting Duplicate Db at 24-MAR-17

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=20 device type=DISK

 

contents of Memory Script:

{

   backup as copy reuse

   targetfile  '/oracle/app/product/11.2.0/db_1/dbs/orapwora11g' auxiliary format

 '/oracle/app/product/11.2.0/db_1/dbs/orapwora11g'   ;

}

executing Memory Script

 

Starting backup at 24-MAR-17

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=33 device type=DISK

Finished backup at 24-MAR-17

 

contents of Memory Script:

{

   backup as copy current controlfile for standby auxiliary format  '/oracle/app/oradata/ora11g/control01.ctl';

   restore clone controlfile to  '/oracle/app/oradata/ora11g/control02.ctl' from

 '/oracle/app/oradata/ora11g/control01.ctl';

}

executing Memory Script

 

Starting backup at 24-MAR-17

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

copying standby control file

output file name=/oracle/app/product/11.2.0/db_1/dbs/snapcf_ora11g.f tag=TAG20170324T150456 RECID=6 STAMP=939481497

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 24-MAR-17

 

Starting restore at 24-MAR-17

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: copied control file copy

Finished restore at 24-MAR-17

 

contents of Memory Script:

{

   sql clone 'alter database mount standby database';

}

executing Memory Script

 

sql statement: alter database mount standby database

 

contents of Memory Script:

{

   set newname for tempfile  1 to

 "/oracle/app/oradata/ora11g/temp01.dbf";

   switch clone tempfile all;

   set newname for datafile  1 to

 "/oracle/app/oradata/ora11g/system01.dbf";

   set newname for datafile  2 to

 "/oracle/app/oradata/ora11g/sysaux01.dbf";

   set newname for datafile  3 to

 "/oracle/app/oradata/ora11g/undotbs01.dbf";

   set newname for datafile  4 to

 "/oracle/app/oradata/ora11g/users01.dbf";

   backup as copy reuse

   datafile  1 auxiliary format

 "/oracle/app/oradata/ora11g/system01.dbf"   datafile

 2 auxiliary format

 "/oracle/app/oradata/ora11g/sysaux01.dbf"   datafile

 3 auxiliary format

 "/oracle/app/oradata/ora11g/undotbs01.dbf"   datafile

 4 auxiliary format

 "/oracle/app/oradata/ora11g/users01.dbf"   ;

   sql 'alter system archive log current';

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed tempfile 1 to /oracle/app/oradata/ora11g/temp01.dbf in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting backup at 24-MAR-17

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

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

output file name=/oracle/app/oradata/ora11g/system01.dbf tag=TAG20170324T150504

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00002 name=/oracle/app/oradata/ora11g/sysaux01.dbf

output file name=/oracle/app/oradata/ora11g/sysaux01.dbf tag=TAG20170324T150504

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:19

channel ORA_DISK_1: starting datafile copy

input datafile file number=00003 name=/oracle/app/oradata/ora11g/undotbs01.dbf

output file name=/oracle/app/oradata/ora11g/undotbs01.dbf tag=TAG20170324T150504

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=/oracle/app/oradata/ora11g/users01.dbf

output file name=/oracle/app/oradata/ora11g/users01.dbf tag=TAG20170324T150504

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 24-MAR-17

 

sql statement: alter system archive log current

 

contents of Memory Script:

{

   switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy RECID=6 STAMP=939481171 file name=/oracle/app/oradata/ora11g/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=7 STAMP=939481171 file name=/oracle/app/oradata/ora11g/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=8 STAMP=939481171 file name=/oracle/app/oradata/ora11g/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=9 STAMP=939481171 file name=/oracle/app/oradata/ora11g/users01.dbf

Finished Duplicate Db at 24-MAR-17

 

至此,資料庫已經複製到新環境

 

複製期間的歸檔日誌

SQL> recover standby database;

auto

 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23732248/viewspace-2770907/,如需轉載,請註明出處,否則將追究法律責任。

相關文章