配置ORACLE 11G ADG

以前装过10g的,没有做笔记,昨天使用duplicate方法装了个11g ADG,过程艰辛,记录下:

一、环境配置

主库

IP地址:192.168.233.128/24

操作系统版本:rhel5.8 64bit

数据库版本:11.2.0.1 64bit

数据库sid名:orcl

数据库名:orcl

数据库db_unique_name:orcl1

主机名:pr

物理备库

IP地址:192.168.233.129/24

操作系统版本:rhel5.8 64bit

数据库版本:11.2.0.1 64bit

数据库sid名:orcl

数据库名:orcl

数据库db_unique_name:orcl2

主机名:st

二、修改主备库listener.ora,tnsnames.ora文件如下

[oracle@pr admin]$ more listener.ora
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = pr)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

[oracle@pr admin]$ more tnsnames.ora
orcl1=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.128)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl1)
    )
  )

orcl2=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.129)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl2)
    )
  )

[oracle@st admin]$ more listener.ora
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = st)(PORT = 1521))
    )
  )


SID_LIST_LISTENER =
 (SID_LIST =
 (SID_DESC =
 (GLOBAL_DBNAME = orcl2)
 (ORACLE_HOME = /export/11g/product)
 (SID_NAME = orcl)
 )
 )


[oracle@st admin]$ more tnsnames.ora
orcl1=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.128)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl1)
    )
  )

orcl2=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.129)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl2)
    )
  )

三、修改主库、备库的pfile文件,红色部分为新增加的部分。

[oracle@pr dbs]$ more initorcl.ora
orcl.__db_cache_size=142606336
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/export/11g'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=167772160
orcl.__sga_target=251658240
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=92274688
orcl.__streams_pool_size=0
*.audit_file_dest='/export/11g/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/export/11g/oradata/orcl/control01.ctl','/export/11g/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/export/11g/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/export/11g'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=417333248
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
*.db_unique_name='orcl1'
*.fal_client='orcl1'
 *.fal_server='orcl2'
 *.log_archive_config='DG_CONFIG=(orcl1,orcl2)'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST '
 *.log_archive_dest_2='SERVICE=orcl2 lgwr async valid_for=(online_logfile,primary_role) db_unique_name=orcl2'
 *.remote_login_passwordfile='EXCLUSIVE'
 *.standby_file_management='AUTO'

 DB_UNQUIE_NAME的会影响到Service_names,也会影响到动态监听的时候的service_name

[oracle@st dbs]$ more initorcl.ora
orcl.__db_cache_size=142606336
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/export/11g'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=167772160
orcl.__sga_target=251658240
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=92274688
orcl.__streams_pool_size=0
*.audit_file_dest='/export/11g/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/export/11g/oradata/orcl/control01.ctl','/export/11g/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/export/11g/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/export/11g'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=417333248
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
*.fal_client='orcl2'
 *.fal_server='orcl1'
 *.log_archive_config='DG_CONFIG=(orcl1,orcl2)'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST '
 *.log_archive_dest_2='SERVICE=orcl1 lgwr async valid_for=(online_logfile,primary_role) db_unique_name=orcl1'
 *.remote_login_passwordfile='EXCLUSIVE'
 *.standby_file_management='AUTO'
 *.db_unique_name='orcl2'

 valid_for=(all_logfiles,primary_role) :备库不能归档

valid_for=(all_logfiles,all_role) : 设置不了

四、在备库上创建相应的目录

如udump/,oradate/

五、将备库启动到nomount状态,然后连接主库进行duplicate操作

  1. [oracle@dg2 ~]$ lsnrctl start 
  2. [oracle@dg2 ~]$ orapwd file=$ORACLE_HOME/dbs/orapworclpassword=oracleentries=5
  3. [oracle@dg2 ~]$ sqlplus /nolog
  4. SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 22 13:36:53 2012 
  5. Copyright (c) 1982, 2011, Oracle.  All rights reserved. 
  6. SQL> conn /as sysdba 
  7. Connected to an idle instance. 
  8. SQL> create spfile frompfile='/export/11g/product/dbs/initorcl.ora'; 
  9. File created. 
  10. SQL> startup nomount 
  11. ORACLE instance started. 
  12. Total System Global Area  417546240 bytes 
  13. Fixed Size                  2228944 bytes 
  14. Variable Size             285216048 bytes 
  15. Database Buffers          121634816 bytes 
  16. Redo Buffers                8466432 bytes

[oracle@st dbs]rman targetsys/oracle@orcl1 auxiliarysys/oracle@orcl2

RMAN> duplicate target database for standby from activedatabase nofilenamecheck;

 

Starting Duplicate Db at 10-NOV-14

using target databasecontrol file instead of recovery catalog

allocated channel:ORA_AUX_DISK_1

channel ORA_AUX_DISK_1:SID=20 device type=DISK

 

contents of MemoryScript:

{

  backup as copy reuse

  targetfile '/export/11g/product/dbs/orapworcl' auxiliary format

 '/export/11g/product/dbs/orapworcl'   ;

}

executing Memory Script

 

Starting backup at 10-NOV-14

allocated channel:ORA_DISK_1

channel ORA_DISK_1:SID=43 device type=DISK

Finished backup at10-NOV-14

 

contents of MemoryScript:

{

  backup as copy current controlfile forstandby auxiliary format '/export/11g/oradata/orcl/control01.ctl';

  restore clone controlfile to '/export/11g/flash_recovery_area/orcl/control02.ctl' from

 '/export/11g/oradata/orcl/control01.ctl';

}

executing Memory Script

 

Starting backup at 10-NOV-14

using channel ORA_DISK_1

channel ORA_DISK_1:starting datafile copy

copying standby controlfile

output filename=/export/11g/product/dbs/snapcf_orcl.f tag=TAG20141110T094600 RECID=5STAMP=863257560

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

Finished backup at10-NOV-14

 

Starting restore at 10-NOV-14

using channelORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1:copied control file copy

Finished restore at10-NOV-14

 

contents of MemoryScript:

{

  sql clone 'alter database mount standbydatabase';

}

executing Memory Script

 

sql statement: alterdatabase mount standby database

 

contents of MemoryScript:

{

  set newname for tempfile  1 to

 "/export/11g/oradata/orcl/temp01.dbf";

  switch clone tempfile all;

  set newname for datafile  1 to

 "/export/11g/oradata/orcl/system01.dbf";

  set newname for datafile  2 to

 "/export/11g/oradata/orcl/sysaux01.dbf";

  set newname for datafile  3 to

 "/export/11g/oradata/orcl/undotbs01.dbf";

  set newname for datafile  4 to

 "/export/11g/oradata/orcl/users01.dbf";

  set newname for datafile  5 to

 "/export/11g/oradata/orcl/example01.dbf";

  backup as copy reuse

  datafile 1 auxiliary format

 "/export/11g/oradata/orcl/system01.dbf"   datafile

 2 auxiliary format

 "/export/11g/oradata/orcl/sysaux01.dbf"   datafile

 3 auxiliary format

 "/export/11g/oradata/orcl/undotbs01.dbf"   datafile

 4 auxiliary format

 "/export/11g/oradata/orcl/users01.dbf"   datafile

 5 auxiliary format

 "/export/11g/oradata/orcl/example01.dbf"   ;

  sql 'alter system archive log current';

}

executing Memory Script

 

executing command: SETNEWNAME

 

renamed tempfile 1 to/export/11g/oradata/orcl/temp01.dbf in control file

 

executing command: SETNEWNAME

 

executing command: SETNEWNAME

 

executing command: SETNEWNAME

 

executing command: SETNEWNAME

 

executing command: SETNEWNAME

 

Starting backup at 10-NOV-14

using channel ORA_DISK_1

channel ORA_DISK_1:starting datafile copy

input datafile filenumber=00001 name=/export/11g/oradata/orcl/system01.dbf

output filename=/export/11g/oradata/orcl/system01.dbf tag=TAG20141110T094610

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

channel ORA_DISK_1: startingdatafile copy

input datafile filenumber=00002 name=/export/11g/oradata/orcl/sysaux01.dbf

output filename=/export/11g/oradata/orcl/sysaux01.dbf tag=TAG20141110T094610

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

channel ORA_DISK_1:starting datafile copy

input datafile filenumber=00005 name=/export/11g/oradata/orcl/example01.dbf

output filename=/export/11g/oradata/orcl/example01.dbf tag=TAG20141110T094610

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

channel ORA_DISK_1:starting datafile copy

input datafile filenumber=00003 name=/export/11g/oradata/orcl/undotbs01.dbf

output filename=/export/11g/oradata/orcl/undotbs01.dbf tag=TAG20141110T094610

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

channel ORA_DISK_1:starting datafile copy

input datafile filenumber=00004 name=/export/11g/oradata/orcl/users01.dbf

output filename=/export/11g/oradata/orcl/users01.dbf tag=TAG20141110T094610

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

Finished backup at10-NOV-14

 

sql statement: altersystem archive log current

 

contents of MemoryScript:

{

  switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched todatafile copy

input datafile copyRECID=5 STAMP=863257693 file name=/export/11g/oradata/orcl/system01.dbf

datafile 2 switched todatafile copy

input datafile copyRECID=6 STAMP=863257694 file name=/export/11g/oradata/orcl/sysaux01.dbf

datafile 3 switched todatafile copy

input datafile copyRECID=7 STAMP=863257694 file name=/export/11g/oradata/orcl/undotbs01.dbf

datafile 4 switched todatafile copy

input datafile copyRECID=8 STAMP=863257694 file name=/export/11g/oradata/orcl/users01.dbf

datafile 5 switched todatafile copy

input datafile copyRECID=9 STAMP=863257694 file name=/export/11g/oradata/orcl/example01.dbf

Finished Duplicate Db at10-NOV-14

 

RMAN> exit

 

 

Recovery Managercomplete.

至此备库创建完成。

期间遇到很多的问题,现在总结如下:
1、执行[oracle@st dbs]rman target sys/oracle@orcl1 auxiliarysys/oracle@orcl2时候,提示不能连接到orcl1,但是能ping同pr,原来是防火墙没有开通过

2、tnsname.ora文件中service_name 与连接对端的监听中的service_name相对应。

3、备库中的配置了静态监听,具体原因参见:RMAN-04006: error from auxiliary database: ORA-01034: ORACLE not available_ITPUB博客

[qs-hddb2.800best.com_oracle:/u01/app/oracle/db/11.2$rman target 'sys/ora1Q23$AZ'@hddb auxiliary 'sys/ora1Q23$AZ'@hddb1

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Aug 13 19:30:40 2015

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

connected to target database: HDDB (DBID=880432607)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04006: error from auxiliary database: ORA-12528: TNS:listener: all appropriate instances are blocking new connections


连接被阻塞,查看监听

[qs-hddb2.800best.com_oracle:/u01/app/oracle/db/11.2/network/admin$lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 13-AUG-2015 19:30:36

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=qs-hddb2.800best.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                13-AUG-2015 18:50:15
Uptime                    0 days 0 hr. 40 min. 21 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/db/11.2/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/qs-hddb2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=qs-hddb2.800best.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "hddb1" has 1 instance(s).
  Instance "hddb1", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully


监听的状态确实是阻塞的,配置静态监听,重启监听,再次查看监听的状态:

Listener Log File         /u01/app/oracle/diag/tnslsnr/qs-hddb2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=qs-hddb2.800best.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "hddb1" has 2 instance(s).
  Instance "hddb1", status UNKNOWN, has 1 handler(s) for this service...
  Instance "hddb1", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully
[qs-hddb2.800best.com_oracle:/u01/app/oracle/db/11.2/network/admin$


有一个服务的状态是unknow ,再次连接成功

4、执行duplicate target database for standby from active database nofilenamecheck;运行过程中出现了以下错误,是因为缺少文中的第四步,没有在备库上创建相应的目录。

RMAN> duplicate target database for standby from active database;

Starting Duplicate Db at 10-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK

……省略

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/export/11g/oradata/orcl/control01.ctl';
   restore clone controlfile to  '/export/11g/flash_recovery_area/orcl/control02.ctl' from
 '/export/11g/oradata/orcl/control01.ctl';
}
executing Memory Script

Starting backup at 10-NOV-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 11/10/2014 09:24:29
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 11/10/2014 09:24:29
ORA-17628: Oracle error 19505 returned by remote Oracle server

5、执行duplicate target database for standby from active database nofilenamecheck;,运行过程中出现了以下错误,是因为没有使用nofilenamecheck。

RMAN> duplicate target database for standby from active database;

Starting Duplicate Db at 10-NOV-14
using channel ORA_AUX_DISK_1

…… …… 省略

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 11/10/2014 09:33:14
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary file name /export/11g/oradata/orcl/example01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary file name /export/11g/oradata/orcl/users01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary file name /export/11g/oradata/orcl/undotbs01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary file name /export/11g/oradata/orcl/sysaux01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary file name /export/11g/oradata/orcl/system01.dbf conflicts with a file used by the target database

6、出现以下错误是备库参数 db_name 的值与主库不一致。 


sql statement: alter database mount standby database
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/06/2019 12:28:56
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of sql command on clone_default channel at 09/06/2019 12:28:56
RMAN-11003: failure during parse/execution of SQL statement: alter database mount standby database
ORA-01103: database name 'ORCL' in control file is not 'ORCLST'

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

huangliang0703

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值