oracle 11g Active database duplicate

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 11g Active database duplicate相关的知识,希望对你有一定的参考价值。

测试使用 Active database duplicate在不同机器不同数据库实例复制数据库

环境:

Target DB:

IP:10.131.119.118 

HOSTNAME:CS-SI-DG01

ORACLE_SID:orcl


Auxiliary DB:

IP:10.131.119.119

HOSTNAME:CS-SI-DG02

ORACLE_SID:orclaux


1.将Target DB库的参数文件和密码文件scp到Auxiliary DB库

[[email protected] dbs]$ pwd

/u2/oracle/product/11.2.0/dbhome_1/dbs

[[email protected] dbs]$ scp initorcl.ora 10.131.119.119:/u2/oracle/product/11.2.0/dbhome_1/dbs

[email protected]‘s password: 

Permission denied, please try again.

[email protected]‘s password: 

stty: standard input: Invalid argument

spfileorcl.ora                                   100% 3584     3.5KB/s   00:00    

[[email protected] dbs]$ scp orapworcl 10.131.119.119:/u2/oracle/product/11.2.0/dbhome_1/dbs

[email protected]‘s password: 

stty: standard input: Invalid argument

orapworcl                                        100% 1536     1.5KB/s   00:00    


2.在Auxiliary DB库修改文件名与修改参数文件内容

[[email protected] dbs]$ pwd

/u2/oracle/product/11.2.0/dbhome_1/dbs

[[email protected] dbs]$ mv initorcl.ora initorclaux.ora 

[[email protected] dbs]$ mv orapworcl orapworclaux


[[email protected] dbs]$ cat initorclaux.ora 

*._undo_autotune=TRUE

*.audit_file_dest=‘/u2/oracle/admin/orclaux/adump‘

*.audit_trail=‘db‘

*.compatible=‘11.2.0.0.0‘

*.control_files=‘/oradata/orclaux/control01.ctl‘,‘/oradata/orclaux/control02.ctl‘#Restore Controlfile

*.db_block_size=8192

*.db_domain=‘‘

*.db_name=‘orclaux‘

*.db_recovery_file_dest=‘/u2/oracle/fast_recovery_area‘

*.db_recovery_file_dest_size=8589934592

*.diagnostic_dest=‘/u2/oracle‘

*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=orclauxXDB)‘

*.job_queue_processes=1000

*.log_archive_dest_1=‘location=/oradata/arch/orclaux‘

*.log_archive_dest_10=‘ ‘

*.memory_max_target=0

*.memory_target=0

*.open_cursors=300

*.pga_aggregate_target=171966464

*.processes=150

*.remote_login_passwordfile=‘EXCLUSIVE‘

*.session_cached_cursors=240

*.sga_target=335544320

*.undo_retention=60

*.undo_tablespace=‘UNDOTBS2‘

*.db_file_name_convert=(‘/oradata/orcl/‘,‘/oradata/orclaux/‘)

*.log_file_name_convert=(‘/oradata/orcl/‘,‘/oradata/orclaux/‘)


3.在Auxiliary DB库建立必要的目录

[[email protected] dbs]$ mkdir -p /u2/oracle/admin/orclaux/adump

[[email protected] dbs]$ mkdir -p /oradata/orclaux/

[[email protected] dbs]$ mkdir -p /oradata/arch/orclaux


4.在Auxiliary DB库启动到nomount状态


[[email protected] orclaux]$ export ORACLE_SID=orclaux

[[email protected] orclaux]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.3.0 Production on Sun Jan 24 11:32:47 2016


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


Connected to an idle instance.


SQL> startup nomount

ORACLE instance started.


Total System Global Area  509411328 bytes

Fixed Size                  2229824 bytes

Variable Size             285215168 bytes

Database Buffers          213909504 bytes

Redo Buffers                8056832 bytes


5.在Auxiliary DB库与Target DB库中配置监听与TNS

Target DB:

[[email protected] admin]$ cat listener.ora   --监听配置

# listener.ora Network Configuration File: /u2/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcl)

      (ORACLE_HOME = /u2/oracle/product/11.2.0/dbhome_1)

      (SID_NAME = orcl)

    )

  )


LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

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

    )

    (DESCRIPTION =

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

    )

  )


ADR_BASE_LISTENER = /u2/oracle


                               

[[email protected] admin]$ cat tnsnames.ora   --TNS配置

# tnsnames.ora Network Configuration File: /u2/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.



orclaux =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = orclaux)

    )

  )


[[email protected] admin]$ lsnrctl reload     --重新加载监听

 

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 24-JAN-2016 12:09:50


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


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

The command completed successfully


Auxiliary DB


[[email protected] admin]$ vi listener.ora      --监听配置


# listener.ora Network Configuration File: /u2/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orclaux)

      (ORACLE_HOME = /u2/oracle/product/11.2.0/dbhome_1)

      (SID_NAME = orclaux)

    )

  )


LISTENER =

  (DESCRIPTION =

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

  )


ADR_BASE_LISTENER = /u2/oracle


[[email protected] admin]$ cat tnsnames.ora    --TNS配置

# tnsnames.ora Network Configuration File: /u2/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = orcl)

    )

  )

orclaux =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = orclaux)

    )

  )



[[email protected] admin]$ lsnrctl reload        --重新加载监听


LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 24-JAN-2016 12:09:57


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


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

The command completed successfully


5.开始复制数据库


[[email protected] admin]$ export ORACLE_SID=orclaux

[[email protected] admin]$ rman target sys/[email protected] auxiliary sys/[email protected]    --连接目标库与辅助库

 

Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jan 24 12:38:54 2016


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


connected to target database: ORCL (DBID=1414106639)

connected to auxiliary database: ORCLAUX (not mounted)


RMAN> duplicate target database to orclaux from active database;      --复制目标数据库到orclaux实例

注意:如果两个数据库的目录结构一样,需要在末尾加上nofilenamecheck


Starting Duplicate Db at 24-JAN-16

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=134 device type=DISK


contents of Memory Script:

{

   sql clone "create spfile from memory";

}

executing Memory Script


sql statement: create spfile from memory


contents of Memory Script:

{

   shutdown clone immediate;

   startup clone nomount;

}

executing Memory Script


Oracle instance shut down


connected to auxiliary database (not started)

Oracle instance started


Total System Global Area     509411328 bytes


Fixed Size                     2229824 bytes

Variable Size                289409472 bytes

Database Buffers             209715200 bytes

Redo Buffers                   8056832 bytes


contents of Memory Script:

{

   sql clone "alter system set  db_name = 

 ‘‘ORCL‘‘ comment=

 ‘‘Modified by RMAN duplicate‘‘ scope=spfile";

   sql clone "alter system set  db_unique_name = 

 ‘‘ORCLAUX‘‘ comment=

 ‘‘Modified by RMAN duplicate‘‘ scope=spfile";

   shutdown clone immediate;

   startup clone force nomount

   backup as copy current controlfile auxiliary format  ‘/oradata/orclaux/control01.ctl‘;

   restore clone controlfile to  ‘/oradata/orclaux/control02.ctl‘ from 

 ‘/oradata/orclaux/control01.ctl‘;

   alter clone database mount;

}

executing Memory Script


sql statement: alter system set  db_name =  ‘‘ORCL‘‘ comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile


Oracle 11G Active DataGuard角色切换

Oracle11g Active Data Guard搭建管理

oracle 11g 安装

windows下安装oracle11g

Oracle11gR2使用RMAN duplicate复制数据库——active database duplicate

Active Data Guard