文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

12102 Using the DUPLICATE Command to Create a Standby Database

2024-04-02 19:55

关注

1   描述

利用rman duplicate同一主机上创建standby database.

2   操作环境

OEL7.2

Oracle database 12.1.0.2.0

DB_NAME=S12102

 

primary

standby

parameter

LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102,S12102D)'

LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102'

LOG_ARCHIVE_DEST_2='SERVICE=S12102D ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102D'

FAL_SERVER=S12102D

FAL_CLIENT=S12102

STANDBY_FILE_MANAGEMENT=AUTO

control_files='/u01/app/product/oradata/S12102D/control01.ctl','/u01/app/product/fast_recovery_area/S12102D/control02.ctl'

DB_UNIQUE_NAME='S12102D'

LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102D,S12102)'

LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'

LOG_ARCHIVE_DEST_2='SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102'

FAL_SERVER='S12102'

FAL_CLIENT='S12102D'

DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'

LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'

STANDBY_FILE_MANAGEMENT='AUTO'

Datafile dire

/u01/app/product/oradata/S12102

/u01/app/product/oradata/S12102D

 

3   过程设计

3.1  主库DG配置

3.2  操作系统用户DG环境配置

3.3  listener.ora与tnsnames.ora配置

3.4  rman duplicate

4   详细步骤操作

4.1  主库DG配置

shutdown immediate;

startup mount;

alter database archivelog;

alter database open;

create pfile from spfile;

 

ALTER DATABASE FORCE LOGGING;

ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo01.log') SIZE 50M;

ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo02.log') SIZE 50M;

ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo03.log') SIZE 50M;

ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/product/oradata/S12102/sredo04.log') SIZE 50M;

--standby redo是在备库上work的,主库也可以添加,方便日后switchover改maxprotected模式时使用。添加在主库,在创建DataGuard时,备库自然也就有了,比较省事。-- The standby redo log must have at least one more redo log group than the redo log at the redo source database, for each redo thread at the redo source database. At the redo source database, query the V$LOG view to determine how many redo log groups are in the redo log at the redo source database and query the V$THREAD view to determine how many redo threads exist at the redo source database.

 

alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102,S12102D)';

alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102';

alter system set LOG_ARCHIVE_DEST_2='SERVICE=S12102D ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102D' ;

alter system set FAL_SERVER=S12102D;

alter system set FAL_CLIENT=S12102;

alter system set STANDBY_FILE_MANAGEMENT=AUTO;

 

--此两项需要重启数据库生效

alter system set DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102D/','/u01/app/product/oradata/S12102' scope=spfile;

alter system set LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102D/','/u01/app/product/oradata/S12102' scope=spfile;

4.2  操作系统用户DG环境配置

cd $ORACLE_HOME/dbs

cp initS12102.ora initS12102D.ora

cp orapwS12102 orapwS12102D

chmod 775 $TNS_ADMIN

编辑standby db参数文件,创建standby database目录,配置standby系统环境变量略

4.3  listener.ora与tnsnames.ora配置(本环境使用GRID监听)

[grid@localhost 12.1.0.2.0:(+ASM) network ] $ cat listener.ora

# listener.ora Network Configuration File: /u01/app/product/admin/network/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = S12102)

      (ORACLE_HOME = /u01/app/product/database/12.1.0.2.0)

      (SID_NAME = S12102)

    )

    (SID_DESC =

      (GLOBAL_DBNAME = S12102D)

      (ORACLE_HOME = /u01/app/product/database/12.1.0.2.0)

      (SID_NAME = S12102D)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

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

    )

    (DESCRIPTION =

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

    )

  )

 

ADR_BASE_LISTENER = /u01/app/product

 

[grid@localhost 12.1.0.2.0:(+ASM) network ] $ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/product/admin/network/tnsnames.ora

# Generated by Oracle configuration tools.

 

S12102D =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = S12102D)

    )

  )

 

S12102 =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = S12102)

    )

  )

 

 

4.4  rman duplicate

--备库启到nomount状态略

 

rman target sys/oracle@S12102 auxiliary sys/oracle@S12102D

 

startup clone nomount;

 

run{

duplicate target database for standby from active database nofilenamecheck

SPFILE

set control_files='/u01/app/product/oradata/S12102D/control01.ctl','/u01/app/product/fast_recovery_area/S12102D/control02.ctl'

set DB_UNIQUE_NAME='S12102D'

set LOG_ARCHIVE_CONFIG='DG_CONFIG=(S12102D,S12102)'

set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'

set LOG_ARCHIVE_DEST_2='SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102'

set FAL_SERVER='S12102'

set FAL_CLIENT='S12102D'

set DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'

set LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'

set STANDBY_FILE_MANAGEMENT='AUTO';

}

 

下面是duplicate过程详细输出

[oracle@localhost 12.1.0.2.0:(S12102) bin ] $ rman target sys/oracle@S12102 auxiliary sys/oracle@S12102D

 

Recovery Manager: Release 12.1.0.2.0 - Production on Fri Jun 1 17:35:24 2018

 

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

 

connected to target database: S12102 (DBID=2197238228)

connected to auxiliary database (not started)

 

RMAN> startup clone nomount;

 

Oracle instance started

 

Total System Global Area    3070230528 bytes

 

Fixed Size                     2929112 bytes

Variable Size                754978344 bytes

Database Buffers            2298478592 bytes

Redo Buffers                  13844480 bytes

 

RMAN> run{

duplicate target database for standby from active database nofilenamecheck

SPFILE

set control_files='/u01/app/product/oradata/S12102D/control01.ctl','/u01/app/product/fast_recovery_area/S12102D/control02.ctl'

set DB_UNIQUE_NAME='S12102D'

set LOG_ARCHI2> 3> 4> 5> 6> VE_CONFIG='DG_CONFIG=(S12102D,S12102)'

set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'

set LOG_ARCHIVE_DEST_2='SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NA7> 8> ME=S12102'

set FAL_SERVER='S12102'

set FAL_CLIENT='S12102D'

set DB_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'

set LOG_FILE_NAME_CONVERT='/u01/app/product/oradata/S12102','/u01/app/product/oradata/S12102D'

set STA9> 10> 11> 12> 13> NDBY_FILE_MANAGEMENT='AUTO';

}

14>

Starting Duplicate Db at 01-JUN-2018 17:36:46

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=240 device type=DISK

 

contents of Memory Script:

{

   backup as copy reuse

   targetfile  '/u01/app/product/database/12.1.0.2.0/dbs/orapwS12102' auxiliary format

 '/u01/app/product/database/12.1.0.2.0/dbs/orapwS12102D'   ;

   restore clone from service  'S12102' spfile to

 '/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora';

   sql clone "alter system set spfile= ''/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora''";

}

executing Memory Script

 

Starting backup at 01-JUN-2018 17:36:47

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=37 device type=DISK

Finished backup at 01-JUN-2018 17:36:49

 

Starting restore at 01-JUN-2018 17:36:49

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service S12102

channel ORA_AUX_DISK_1: restoring SPFILE

output file name=/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 01-JUN-2018 17:36:50

 

sql statement: alter system set spfile= ''/u01/app/product/database/12.1.0.2.0/dbs/spfileS12102D.ora''

 

contents of Memory Script:

{

   sql clone "alter system set  control_files =

 ''/u01/app/product/oradata/S12102D/control01.ctl'', ''/u01/app/product/fast_recovery_area/S12102D/control02.ctl'' comment=

 '''' scope=spfile";

   sql clone "alter system set  db_unique_name =

 ''S12102D'' comment=

 '''' scope=spfile";

   sql clone "alter system set  LOG_ARCHIVE_CONFIG =

 ''DG_CONFIG=(S12102D,S12102)'' comment=

 '''' scope=spfile";

   sql clone "alter system set  LOG_ARCHIVE_DEST_1 =

 ''LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'' comment=

 '''' scope=spfile";

   sql clone "alter system set  LOG_ARCHIVE_DEST_2 =

 ''SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102'' comment=

 '''' scope=spfile";

   sql clone "alter system set  FAL_SERVER =

 ''S12102'' comment=

 '''' scope=spfile";

   sql clone "alter system set  FAL_CLIENT =

 ''S12102D'' comment=

 '''' scope=spfile";

   sql clone "alter system set  db_file_name_convert =

 ''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment=

 '''' scope=spfile";

   sql clone "alter system set  LOG_FILE_NAME_CONVERT =

 ''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment=

 '''' scope=spfile";

   sql clone "alter system set  STANDBY_FILE_MANAGEMENT =

 ''AUTO'' comment=

 '''' scope=spfile";

   shutdown clone immediate;

   startup clone nomount;

}

executing Memory Script

 

sql statement: alter system set  control_files =  ''/u01/app/product/oradata/S12102D/control01.ctl'', ''/u01/app/product/fast_recovery_area/S12102D/control02.ctl'' comment= '''' scope=spfile

 

sql statement: alter system set  db_unique_name =  ''S12102D'' comment= '''' scope=spfile

 

sql statement: alter system set  LOG_ARCHIVE_CONFIG =  ''DG_CONFIG=(S12102D,S12102)'' comment= '''' scope=spfile

 

sql statement: alter system set  LOG_ARCHIVE_DEST_1 =  ''LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=S12102D'' comment= '''' scope=spfile

 

sql statement: alter system set  LOG_ARCHIVE_DEST_2 =  ''SERVICE=S12102 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=S12102'' comment= '''' scope=spfile

 

sql statement: alter system set  FAL_SERVER =  ''S12102'' comment= '''' scope=spfile

 

sql statement: alter system set  FAL_CLIENT =  ''S12102D'' comment= '''' scope=spfile

 

sql statement: alter system set  db_file_name_convert =  ''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment= '''' scope=spfile

 

sql statement: alter system set  LOG_FILE_NAME_CONVERT =  ''/u01/app/product/oradata/S12102'', ''/u01/app/product/oradata/S12102D'' comment= '''' scope=spfile

 

sql statement: alter system set  STANDBY_FILE_MANAGEMENT =  ''AUTO'' comment= '''' scope=spfile

 

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area    3070230528 bytes

 

Fixed Size                     2929112 bytes

Variable Size                754978344 bytes

Database Buffers            2298478592 bytes

Redo Buffers                  13844480 bytes

 

contents of Memory Script:

{

   restore clone from service  'S12102' standby controlfile;

}

executing Memory Script

 

Starting restore at 01-JUN-2018 17:37:39

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=12 device type=DISK

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service S12102

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04

output file name=/u01/app/product/oradata/S12102D/control01.ctl

output file name=/u01/app/product/fast_recovery_area/S12102D/control02.ctl

Finished restore at 01-JUN-2018 17:37:44

 

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

 "/u01/app/product/oradata/S12102D/temp01.dbf";

   switch clone tempfile all;

   set newname for datafile  1 to

 "/u01/app/product/oradata/S12102D/system01.dbf";

   set newname for datafile  3 to

 "/u01/app/product/oradata/S12102D/sysaux01.dbf";

   set newname for datafile  4 to

 "/u01/app/product/oradata/S12102D/undotbs01.dbf";

   set newname for datafile  5 to

 "/u01/app/product/oradata/S12102D/example01.dbf";

   set newname for datafile  6 to

 "/u01/app/product/oradata/S12102D/users01.dbf";

   restore

   from service  'S12102'   clone database

   ;

   sql 'alter system archive log current';

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed tempfile 1 to /u01/app/product/oradata/S12102D/temp01.dbf in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting restore at 01-JUN-2018 17:37:50

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service S12102

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/product/oradata/S12102D/system01.dbf

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service S12102

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/product/oradata/S12102D/sysaux01.dbf

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service S12102

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/product/oradata/S12102D/undotbs01.dbf

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service S12102

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/product/oradata/S12102D/example01.dbf

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:06

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service S12102

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/product/oradata/S12102D/users01.dbf

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02

Finished restore at 01-JUN-2018 17:40:25

 

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=1 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/system01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=2 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/sysaux01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=3 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/undotbs01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=4 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/example01.dbf

datafile 6 switched to datafile copy

input datafile copy RECID=5 STAMP=977679627 file name=/u01/app/product/oradata/S12102D/users01.dbf

Finished Duplicate Db at 01-JUN-2018 17:40:46

 

RMAN>

5   个人总结

当监听由gird用户启动时,注意$TNS_ADMIN目录权限应为775。

6   资料参考引用

https://docs.oracle.com/database/121/SBYDB/rcmbackp.htm#SBYDB4987

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯