DG_11g部署

前提

主库服务器上已安装数据库软件并创建实例
备库服务器上已安装数据库软件
主、备服务器/etc/hosts文中必须包含主备节点信息如下:

[root@db01:]$ more /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

## OracleBegin
192.168.40.55	db01
192.168.40.56	db02

环境准备

DATABASE_ROLE DB_NAME IPADDR OS Version DB version
Primary fuwa 192.168.40.55 Red Hat7.6 11.2.0.4.0
Standby wafu 192.168.40.56 Red Hat7.6 11.2.0.4.0

主库配置

主库开启归档,开启强制日志,关闭闪回,删除外部表

--开启归档,若已开启归档跳过该步骤
archive log list;
shutdown immediate
startup mount;
alter database archivelog;
alter system set log_archive_dest_1='location=/oradb/arch' scope=spfile; 
alter database open;
--强制日志写 no-->yes
select force_logging from v$database; 
alter database force logging;
--关闭闪回  no
select flashback_on from v$database;
--删除外部表
##xxx_external_locations 可以知道当前所有的目录对象以及相关的外部表,还会查询出这些外部表所对应的操作系统文件的名字。
##select * from all_external_locations;
##select * from user_external_locations;
##select * from dba_external_locations;

主库创建standby logfile

配置原则:
①standby logfile大小要和redo logfile大小相同;
②standby logfile要比redo logfile多一组,目前redo logfile是3组,因此创建4组standby logfile;
③为了安全,standby logfile可以包含多个member。

--查询日志组
set linesize 999
select group#,member from v$logfile order by 1;
    GROUP# MEMBER
---------- ----------------------------------------------------------------------
	 3 /data/oradata/fuwa/redo03.log
	 2 /data/oradata/fuwa/redo02.log
	 1 /data/oradata/fuwa/redo01.log

--查询日志大小
select group#,bytes/1024/1024 size_M from v$log;
    GROUP#     SIZE_M
---------- ----------
	 1	          50
	 2	          50
	 3	          50

#创建standby logfile
alter database add standby logfile group 4('/data/oradata/fuwa/redo04.log') size 50M;
alter database add standby logfile group 5('/data/oradata/fuwa/redo05.log') size 50M;
alter database add standby logfile group 6('/data/oradata/fuwa/redo06.log') size 50M;
alter database add standby logfile group 7('/data/oradata/fuwa/redo07.log') size 50M;

--查询日志组
select group#,member from v$logfile order by 1;
    GROUP# MEMBER
---------- --------------------------------------------------
	 1 /u01/app/oracle/oradata/dhh/redo01.log
	 2 /u01/app/oracle/oradata/dhh/redo02.log
	 3 /u01/app/oracle/oradata/dhh/redo03.log
	 4 /u01/app/oracle/oradata/dhh/redo04.log
	 5 /u01/app/oracle/oradata/dhh/redo05.log
	 6 /u01/app/oracle/oradata/dhh/redo06.log
	 7 /u01/app/oracle/oradata/dhh/redo07.log

SQL> select group#,thread#,sequence#,bytes,status from v$standby_log;
    GROUP#    THREAD#  SEQUENCE#      BYTES STATUS
---------- ---------- ---------- ---------- --------------------
	 4	    0	       0   52428800 UNASSIGNED
	 5	    0	       0   52428800 UNASSIGNED
	 6	    0	       0   52428800 UNASSIGNED
	 7	    0	       0   52428800 UNASSIGNED

主库配置listener

--查看监听参数是否是默认监听,如果是空值则是默认监听,跳过该步骤
show parameter local_listener
---修改local_listener为默认监听
alter system set local_listener='';
show parameter local_listener
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string

--配置监听文件listener.ora    host值:主机名或者ip地址
cp /data/u01/app/oracle/product/11.2.0/db/network/admin/listener.ora /data/u01/app/oracle/product/11.2.0/db/network/admin/listener.orabak


vi /data/u01/app/oracle/product/11.2.0/db/network/admin/listener.ora
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db01)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
sid_list_listener=
  (sid_list=
    (sid_desc=
      (global_dbname=fuwa)
      (ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/db)
      (sid_name=fuwa))
   )

ADR_BASE_LISTENER = /u01/app/oracle

主库配置tnsnames

vi /data/u01/app/oracle/product/11.2.0/db/network/admin/tnsnames.ora
FUWA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = fuwa)
    )
  )

wafu =             #备库服务名
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.56)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = wafu) #备库服务名
    )
  )

ADR_BASE_LISTENER = /data/u01/app/oracle

主库修改参数

生成pfile

startup
create pfile from spfile;
shutdown immediate

修改参数

参数模板可以在官方文档中查到,把其中的名称用自己的数据库名称替换即可。

#参数文件中追加如下内容
su - oracle
cd $ORACLE_HOME/dbs
vi initfuwa.ora
#Primary Role Initialization Parameters
DB_UNIQUE_NAME=fuwa  #主库
LOG_ARCHIVE_CONFIG='DG_CONFIG=(fuwa,wafu)'  #主库,备库
LOG_ARCHIVE_DEST_1=
 'LOCATION=/data/oradata/archivelog/  
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)  #所有角色
  DB_UNIQUE_NAME=fuwa'  #主库
LOG_ARCHIVE_DEST_2=
 'SERVICE=wafu ASYNC  #备库
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)  #主角色
  DB_UNIQUE_NAME=wafu'   #备库
LOG_ARCHIVE_DEST_STATE_1=ENABLE  #必须是启用
LOG_ARCHIVE_DEST_STATE_2=ENABLE  #必须是启用
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf  #格式和库里保持一致
LOG_ARCHIVE_MAX_PROCESSES=30

#Standby Role Initialization Parameters
FAL_SERVER=wafu  #备库
DB_FILE_NAME_CONVERT='wafu','fuwa'  #备库,主库
LOG_FILE_NAME_CONVERT='wafu','fuwa'   #备库,主库
STANDBY_FILE_MANAGEMENT=AUTO

通过pfile重新生成spfile并启动数据库

create spfile from pfile;
startup
shutdown immediate

拷贝相关文件至备库

拷贝参数文件、密码文件、监听文件志备库

参数文件 密码文件 备注
源端 initfuwa.ora orapwfuwa 名字不同
目标 initwafu.ora orapwwafu
cd /data/u01/app/oracle/product/11.2.0/db/dbs
scp initfuwa.ora [email protected]:/data/u01/app/oracle/product/11.2.0/db/dbs/initwafu.ora
scp orapwfuwa [email protected]:/data/u01/app/oracle/product/11.2.0/db/dbs/orapwwafu
cd /data/u01/app/oracle/product/11.2.0/db/network/admin
scp tnsnames.ora [email protected]:/data/u01/app/oracle/product/11.2.0/db/network/admin

备库配置

备库创建静态监听并启动监听

--创建静态监听
cd /data/u01/app/oracle/product/11.2.0/db/network/admin
vi listener.ora
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = db02)(PORT = 1521))
    )
  )

sid_list_listener=
  (sid_list=
    (sid_desc=
      (global_dbname=wafu)
      (ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/db)
      (sid_name=wafu))
   )

ADR_BASE_LISTENER = /data/u01/app/oracle

--重启监听
lsnrctl
stop listener 
start listener
status listener  #返回如下:UNKNOWN即静态监听
Services Summary...
Service "wafu" has 1 instance(s).
  Instance "wafu", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

备库参数修改

修改备库pfile

把主库名称修改为备库名称,备库名称修改为主库名称,但参数文件中的db_name要和主库名称一致。

cd $ORACLE_HOME/dbs
cp initwafu.ora  initwafu.orabak
vi initwafu.ora
wafu.__db_cache_size=2130706432
wafu.__java_pool_size=16777216
wafu.__large_pool_size=33554432
wafu.__oracle_base='/data/u01/app/oracle'#ORACLE_BASE set from environment
wafu.__pga_aggregate_target=671088640
wafu.__sga_target=2650800128
wafu.__shared_io_pool_size=0
wafu.__shared_pool_size=452984832
wafu.__streams_pool_size=0
*._b_tree_bitmap_plans=FALSE
*._cleanup_rollback_entries=2000
*._datafile_write_errors_crash_instance=FALSE
*._index_partition_large_extents='FALSE'
*._memory_imm_mode_without_autosga=FALSE
*._optimizer_adaptive_cursor_sharing=FALSE
*._optimizer_extended_cursor_sharing='NONE'
*._optimizer_extended_cursor_sharing_rel='NONE'
*._optimizer_null_aware_antijoin=FALSE
*._optimizer_use_feedback=FALSE
*._partition_large_extents='FALSE'
*._PX_use_large_pool=TRUE
*._undo_autotune=FALSE
*._use_adaptive_log_file_sync='FALSE'
*.audit_file_dest='/data/u01/app/oracle/admin/wafu/adump'
*.audit_trail='NONE'
*.compatible='11.2.0.4.0'
*.control_file_record_keep_time=31
*.control_files='/data/oradata/wafu/control01.ctl','/data/u01/app/oracle/fast_recovery_area/wafu/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/data/oradata'
*.db_domain=''
*.db_files=5000
*.db_name='wafu'    #主备保持一致
*.db_recovery_file_dest='/data/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.deferred_segment_creation=FALSE
*.diagnostic_dest='/data/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=wafuXDB)'
*.enable_ddl_logging=TRUE
*.event='28401 trace name context forever,level 1','10949 trace name context forever,level 1'
*.log_archive_dest_1='location=/data/oradata/archivelog'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=1000
*.parallel_max_servers=64
*.pga_aggregate_target=659554304
*.processes=2000
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_limit=TRUE
*.resource_manager_plan='force:'
*.sec_case_sensitive_logon=FALSE
*.session_cached_cursors=300
*.sga_max_size=2638217216
*.sga_target=2638217216
*.undo_retention=10800
*.undo_tablespace='UNDOTBS1'

#Primary Role Initialization Parameters
DB_UNIQUE_NAME=wafu   #备库
LOG_ARCHIVE_CONFIG='DG_CONFIG=(wafu,fuwa)'  #备库,主库
LOG_ARCHIVE_DEST_1=
 'LOCATION=/data/oradata/archivelog/  
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=wafu'  #备库
LOG_ARCHIVE_DEST_2=
 'SERVICE=fuwa ASYNC  #主库
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 
  DB_UNIQUE_NAME=fuwa'  #主库
LOG_ARCHIVE_DEST_STATE_1=ENABLE  #必须启动
LOG_ARCHIVE_DEST_STATE_2=ENABLE #必须启动
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf  #格式
LOG_ARCHIVE_MAX_PROCESSES=30

#Standby Role Initialization Parameters
FAL_SERVER=fuwa  #主库
DB_FILE_NAME_CONVERT='fuwa','wafu'  #主库,备库
LOG_FILE_NAME_CONVERT='fuwa','wafu'  #主库,备库
STANDBY_FILE_MANAGEMENT=AUTO

备库按照参数文件创建目录

mkdir -p /data/u01/app/oracle/admin/wafu/adump
mkdir -p /data/oradata/wafu
mkdir -p /data/u01/app/oracle/fast_recovery_area/wafu
mkdir -p /data/oradata/archivelog

备库通过pfile生成spfile并启动数据库至nomount

su - oracle
sqlplus / as sysdba
create spfile from pfile;
startup nomount;

使用RMAN auxiliary恢复数据库

主库上操作
主库为open状态,备库为nomount 监听为启动状态
语法:rman target sys/密码@master auxiliary sys/密码@slave

#rman连接主备库
rman target 'sys/"top@123"'@fuwa auxiliary 'sys/"top@123"'@wafu
#说明:1个双引号扩密码,1个单引号扩 用户名+密码,即: '用户名/"密码"'@服务名
#复制
duplicate target database for standby from active database dorecover nofilenamecheck;
duplicate target database for standby from active database nofilenamecheck;

附录:详细步骤

#rman连接主备库
[oracle@db01:/data]$ rman target 'sys/"top@123"'@fuwa auxiliary 'sys/"top@123"'@wafu

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Sep 11 19:43:28 2023

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

connected to target database: FUWA (DBID=2239739138)
connected to auxiliary database: FUWA (not mounted)

#复制
RMAN> duplicate target database for standby from active database dorecover nofilenamecheck;
Starting Duplicate Db at 11-SEP-23
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  '/data/u01/app/oracle/product/11.2.0/db/dbs/orapwfuwa' auxiliary format 
 '/data/u01/app/oracle/product/11.2.0/db/dbs/orapwwafu'   ;
}
executing Memory Script

Starting backup at 11-SEP-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=88 device type=DISK
Finished backup at 11-SEP-23

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/data/oradata/wafu/control01.ctl';
   restore clone controlfile to  '/data/u01/app/oracle/fast_recovery_area/wafu/control02.ctl' from 
 '/data/oradata/wafu/control01.ctl';
}
executing Memory Script

Starting backup at 11-SEP-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/data/u01/app/oracle/product/11.2.0/db/dbs/snapcf_fuwa.f tag=TAG20230911T194415 RECID=2 STAMP=1147290256
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 11-SEP-23

Starting restore at 11-SEP-23
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 11-SEP-23

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 
 "/data/oradata/wafu/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to 
 "/data/oradata/wafu/system01.dbf";
   set newname for datafile  2 to 
 "/data/oradata/wafu/sysaux01.dbf";
   set newname for datafile  3 to 
 "/data/oradata/wafu/undotbs01.dbf";
   set newname for datafile  4 to 
 "/data/oradata/wafu/users01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/data/oradata/wafu/system01.dbf"   datafile 
 2 auxiliary format 
 "/data/oradata/wafu/sysaux01.dbf"   datafile 
 3 auxiliary format 
 "/data/oradata/wafu/undotbs01.dbf"   datafile 
 4 auxiliary format 
 "/data/oradata/wafu/users01.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /data/oradata/wafu/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 11-SEP-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/data/oradata/fuwa/system01.dbf
output file name=/data/oradata/wafu/system01.dbf tag=TAG20230911T194422
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/data/oradata/fuwa/sysaux01.dbf
output file name=/data/oradata/wafu/sysaux01.dbf tag=TAG20230911T194422
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/data/oradata/fuwa/undotbs01.dbf
output file name=/data/oradata/wafu/undotbs01.dbf tag=TAG20230911T194422
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=/data/oradata/fuwa/users01.dbf
output file name=/data/oradata/wafu/users01.dbf tag=TAG20230911T194422
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 11-SEP-23

sql statement: alter system archive log current

contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/data/oradata/archivelog/1_10_1147204804.dbf" auxiliary format 
 "/data/oradata/archivelog/1_10_1147204804.dbf"   ;
   catalog clone archivelog  "/data/oradata/archivelog/1_10_1147204804.dbf";
   switch clone datafile all;
}
executing Memory Script

Starting backup at 11-SEP-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=10 RECID=6 STAMP=1147290288
output file name=/data/oradata/archivelog/1_10_1147204804.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 11-SEP-23

cataloged archived log
archived log file name=/data/oradata/archivelog/1_10_1147204804.dbf RECID=1 STAMP=1147290290

datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=1147290290 file name=/data/oradata/wafu/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=1147290290 file name=/data/oradata/wafu/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=1147290290 file name=/data/oradata/wafu/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=1147290290 file name=/data/oradata/wafu/users01.dbf

contents of Memory Script:
{
   set until scn  988587;
   recover
   standby
   clone database
    delete archivelog
   ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 11-SEP-23
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 10 is already on disk as file /data/oradata/archivelog/1_10_1147204804.dbf
archived log file name=/data/oradata/archivelog/1_10_1147204804.dbf thread=1 sequence=10
media recovery complete, elapsed time: 00:00:00
Finished recover at 11-SEP-23
Finished Duplicate Db at 11-SEP-23
RMAN> exit
Recovery Manager complete.

开启备库,并启用日志实时应用

备库操作

6、开启备库,并启用日志实时应用
##打开备库
alter database open;

##备库启用日志实时应用
alter database recover managed standby database using current logfile disconnect from session;

DataGuard搭建完成
参考链接:https://www.cnblogs.com/NextAction/p/7366670.html

查看主备库状态

--主库信息
set linesize 999
select name,open_mode,database_role,protection_mode,switchover_status from v$database;
NAME		OPEN_MODE	   DATABASE_ROLE    PROTECTION_MODE	 SWITCHOVER_STATUS  
FUWA		READ WRITE		 PRIMARY	  MAXIMUM PERFORMANCE  TO STANDBY

--备库信息
set linesize 999
select name,open_mode,database_role,protection_mode,switchover_status from v$database;
NAME		OPEN_MODE	   DATABASE_ROLE    PROTECTION_MODE	 SWITCHOVER_STATUS  
FUWA		READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM PERFORMANCE  NOT ALLOWED

常用命令

--查看相关的进程:备库没有RFS进程,主库没有LNS进程
select process, status, thread#,sequence#, block#, blocks from v$managed_standby;
SELECT name, value, datum_time, time_computed FROM V$DATAGUARD_STATS WHERE name like 'apply lag';

--查看状态
主库   
set linesize 999
select name,open_mode,database_role,protection_mode,switchover_status from v$database;
NAME		OPEN_MODE	   DATABASE_ROLE    PROTECTION_MODE	 SWITCHOVER_STATUS  
FUWA		READ WRITE		 PRIMARY	  MAXIMUM PERFORMANCE  TO STANDBY

备库
set linesize 999
select name,open_mode,database_role,protection_mode,switchover_status from v$database;
NAME		OPEN_MODE	   DATABASE_ROLE    PROTECTION_MODE	 SWITCHOVER_STATUS  
FUWA		READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM PERFORMANCE  NOT ALLOWED

--打开传输与应用日志模式,备库
alter database recover managed standby database using current logfile disconnect ;
或
alter database recover managed standby database disconnect from session ;

--主库mount状态,将所有未传送的redo传送给从库,target_db_name使用db_unique_name
alter system flush redo to target_db_name;

--主库参数修改
alter system set log_archive_config='DG_CONFIG=(fuwa,wafu)';
alter system set log_archive_dest_1='LOCATION=/data/oradata/archivelog  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=fuwa' scope=spfile;
alter system set log_archive_dest_2='SERVICE=wafu ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=wafu';
alter system set db_unique_name='fuwa' scope=spfile;

--备库参数修改
alter system set log_archive_config='DG_CONFIG=(wafu,fuwa)';
alter system set log_archive_dest_1='LOCATION=/data/oradata/archivelog  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=wafu' scope=spfile;
alter system set log_archive_dest_2='SERVICE=fuwa ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=fuwa';
alter system set db_unique_name='wafu' scope=spfile;

问题

1.database name ‘FUWA’ in control file is not ‘WAFU’

属于配置错误

1.问题描述
[oracle@db01:/data/u01/app/oracle/product/11.2.0/db/network/admin]$ rman target 'sys/"top@123"'@fuwa auxiliary 'sys/"top@123"'@wafu

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Sep 11 19:34:14 2023

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

connected to target database: FUWA (DBID=2239739138)
connected to auxiliary database: WAFU (not mounted)

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

Starting Duplicate Db at 11-SEP-23
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  '/data/u01/app/oracle/product/11.2.0/db/dbs/orapwfuwa' auxiliary format 
 '/data/u01/app/oracle/product/11.2.0/db/dbs/orapwwafu'   ;
}
executing Memory Script

Starting backup at 11-SEP-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=90 device type=DISK
Finished backup at 11-SEP-23

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/data/oradata/wafu/control01.ctl';
   restore clone controlfile to  '/data/u01/app/oracle/fast_recovery_area/wafu/control02.ctl' from 
 '/data/oradata/wafu/control01.ctl';
}
executing Memory Script

Starting backup at 11-SEP-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/data/u01/app/oracle/product/11.2.0/db/dbs/snapcf_fuwa.f tag=TAG20230911T193647 RECID=1 STAMP=1147289808
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 11-SEP-23

Starting restore at 11-SEP-23
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 11-SEP-23

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 09/11/2023 19:36:54
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/11/2023 19:36:54
RMAN-11003: failure during parse/execution of SQL statement: alter database mount standby database
ORA-01103: database name 'FUWA' in control file is not 'WAFU'

2.原因
备库参数文件db_name和主库参数文件db_name参数不一致

3.解决办法
备库
1)更改备库参数文件db_name和主库参数文件db_name参数一致
2)重新生成spfile参数文件
shutdown immediate
create spfile from pfile;
startup nomount;

你可能感兴趣的:(oracle,数据库)