部署RAC到单实例ADG(11G)

服务器信息

主库RAC环境信息

主库RAC基本环境

节点1

节点2

OS

centos 7.9

centos 7.9

数据库版本

11.2.0.4

11.2.0.4

规格

1C4G

1C4G

主机名

racdb01

racdb02

public ip

192.168.40.135

192.168.40.145

vip

192.168.40.13

192.168.40.14

private ip

192.168.183.135

192.168.183.145

scanip

192.168.40.100

scan name

orcl-scan

ORACLE_HOME

/u01/app/oracle/product/11.2.0/db

db_name

topnet

topnet

db_unique_name

topnet

topnet

instance_name

topnet1

topnet2

端口

1521

1521

主库RAC文件路径环境

--查看所有数据文件位置
select file_name from dba_data_files
union all
select file_name from dba_temp_files
union all
select name from v$controlfile
union all
select name from v$archived_log;FILE_NAME
--------------------------------------------------------------------------------
+DATA/topnet/datafile/users.268.1172044125
+DATA/topnet/datafile/undotbs1.267.1172044125
+DATA/topnet/datafile/sysaux.269.1172044125
+DATA/topnet/datafile/system.261.1172044125
+DATA/topnet/datafile/undotbs2.279.1172044263
+DATA/topnet/tempfile/temp.278.1172044205
+DATA/topnet/controlfile/current.260.1172044201
+ARCH/topnet/controlfile/current.317.11720442018 rows selected.

主机

数据文件路径

控制文件

归档日志文件

orcl01

+DATA/topnet/datafile/

+DATA/topnet/tempfile/

+DATA/topnet/controlfile/

+ARCH

orcl02

主库RAC的hosts文件

[oracle@orcl01:/home/oracle]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6## OracleBegin## RAC1 IP's: orcl01## RAC1 Public IP
192.168.40.200 orcl01
## RAC1 Virtual IP
192.168.40.202 orcl01-vip
## RAC1 Private IP
192.168.183.200 orcl01-priv## RAC2 IP's: orcl02## RAC2 Public IP
192.168.40.201 orcl02
## RAC2 Virtual IP
192.168.40.203 orcl02-vip
## RAC2 Private IP
192.168.183.201 orcl02-priv## SCAN IP
192.168.40.205 orcl-scan

备库环境规划

OS

centos 7.9

数据库版本

11.2.0.4

规格

1C4G

主机名

topnetdg

ip

192.168.40.52

端口

1521

ORACLE_HOME

/u01/app/oracle/product/11.2.0/db

db_name

dxjdg

db_unique_name

dxjdg

instance_name

dxjdg

备库数据文件存放路径

/oradata/topnetdg/datafile

备库联机日志文件文件存放路径

/oradata/topnetdg/onlinelog

备库临时表空间文件存放路径

/oradata/topnetdg/tempfile

备库控制文件存放路径

/oradata/topnetdg/controlfile

备库归档文件存放路径

/oradata/topnetdg/archivelog

备库相关日志存放路径

/oradata/topnetdg/adump

备库相关日志存放路径

/oradata/topnetdg/dpdump

备库相关日志存放路径

/oradata/topnetdg/hdump

备库相关日志存放路径

/oradata/topnetdg/pfile

备库闪回空间放路径

/u01/app/oracle/fast_recover_area

部署前准备工作

主库RAC

主库归档开启

确保主库开启归档,若未开启归档则按以下步骤进行开启归档,若已开启归档,则忽略该步骤。

--检查主库是否开启归档
SQL> archive log list;
Database log mode	       No Archive Mode  未开启归档
Automatic archival	       Disabled
Archive destination	       USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     4
Current log sequence	       5--更改归档参数
alter system set log_archive_dest_1='location=+ARCH' scope=spfile sid='*';  --关闭实例
srvctl stop database -d topnet -o immediate   #1个节点操纵,两个节点的数据库实例都会关闭--将一个节点启动到mount状态
srvctl start instance -d topnet -i topnet1 -o mount--开启归档
alter database archivelog;
alter database open;--查看归档
sqlplus / as sysdba
SQL> archive log list;
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       +ARCH
Oldest online log sequence     4
Next log sequence to archive   5
Current log sequence	       5--启动第2个节点
srvctl start instance -d topnet -i topnet2

主库force logging模式开启

在节点RAC1执行,查看数据库的模式

--在节点RAC1执行,查看数据库的模式   force_logging为NO  说明未开启force logging模式
set linesize 999
col open_mode for a15
col protection_mode for a30
col database_role for a15
select log_mode,open_mode,protection_mode,database_role,switchover_status,guard_status,force_logging from v$database;LOG_MODE     OPEN_MODE		  PROTECTION_MODE      DATABASE_ROLE	SWITCHOVER_STATUS    GUARD_S FOR
------------ -------------------- -------------------- ---------------- -------------------- ------- ---
ARCHIVELOG   READ WRITE 	  MAXIMUM PERFORMANCE  PRIMARY		NOT ALLOWED	     NONE    NO

在节点RAC1上执行:

--开启force logging模式
alter database force logging;--查看数据库的模式 force_logging为YES  说明已开启force logging模式
set linesize 999
col open_mode for a15
col protection_mode for a30
col database_role for a15
select log_mode,open_mode,protection_mode,database_role,switchover_status,guard_status,force_logging from v$database;LOG_MODE     OPEN_MODE		  PROTECTION_MODE      DATABASE_ROLE	SWITCHOVER_STATUS    GUARD_S FOR
------------ -------------------- -------------------- ---------------- -------------------- ------- ---
ARCHIVELOG   READ WRITE 	  MAXIMUM PERFORMANCE  PRIMARY		NOT ALLOWED	     NONE    YES

主库创建standby redo log 文件

主库RAC1节点sqlplus执行查看现有日志组情况

--查看现有日志组情况
set linesize 999
col member format a50;
select a.thread#,a.group#,a.bytes/1024/1024,b.member from v$log a,v$logfile b where a.group#=b.group#;THREAD#     GROUP# A.BYTES/1024/1024 MEMBER
---------- ---------- ----------------- --------------------------------------------------1	    2		     50 +DATA/topnet/onlinelog/group_2.268.11720485471	    2		     50 +DATA/topnet/onlinelog/group_2.267.11720485471	    1		     50 +DATA/topnet/onlinelog/group_1.257.11720485471	    1		     50 +DATA/topnet/onlinelog/group_1.279.11720485472	    3		     50 +DATA/topnet/onlinelog/group_3.256.11720485792	    3		     50 +DATA/topnet/onlinelog/group_3.270.11720485792	    4		     50 +DATA/topnet/onlinelog/group_4.272.11720485792	    4		     50 +DATA/topnet/onlinelog/group_4.265.11720485798 rows selected.

每个 thread 都需要创建,standby redo log 比 redo log 多一组,大小相同

--查看是否配置OMF
SQL> show parameter db_create_file_destNAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
db_create_file_dest		     string			       +DATA--若配置的有OMF,按以下步骤添加standby logfile
alter database add standby logfile thread 1 group 11  size 50m;
alter database add standby logfile thread 1 group 12  size 50m;
alter database add standby logfile thread 1 group 13  size 50m;alter database add standby logfile thread 2 group 21  size 50m;
alter database add standby logfile thread 2 group 22  size 50m;
alter database add standby logfile thread 2 group 23  size 50m;--若未配置OMF,按以下步骤添加standby logfile,由于上面每组2个redo成员,故standby logfile每组也对应2个redo成员
alter database add standby logfile thread 1 group 11 ('+DATA','+DATA') size 50m;
alter database add standby logfile thread 1 group 12 ('+DATA','+DATA') size 50m;
alter database add standby logfile thread 1 group 13 ('+DATA','+DATA') size 50m;alter database add standby logfile thread 2 group 21 ('+DATA','+DATA') size 50m;
alter database add standby logfile thread 2 group 22 ('+DATA','+DATA') size 50m;
alter database add standby logfile thread 2 group 23 ('+DATA','+DATA') size 50m;

创建完查看日志组

--查看日志组
set pagesize 999
select group#,type,member from v$logfile order by 2;GROUP# TYPE 		 MEMBER
---------- --------------------- --------------------------------------------------2 ONLINE		   +DATA/topnet/onlinelog/group_2.268.11720485472 ONLINE		   +DATA/topnet/onlinelog/group_2.267.11720485471 ONLINE		   +DATA/topnet/onlinelog/group_1.257.11720485471 ONLINE		   +DATA/topnet/onlinelog/group_1.279.11720485473 ONLINE		   +DATA/topnet/onlinelog/group_3.256.11720485793 ONLINE		   +DATA/topnet/onlinelog/group_3.270.11720485794 ONLINE		   +DATA/topnet/onlinelog/group_4.272.11720485794 ONLINE		   +DATA/topnet/onlinelog/group_4.265.117204857911 STANDBY		 +DATA/topnet/onlinelog/group_11.263.117204898712 STANDBY		 +DATA/topnet/onlinelog/group_12.258.117204898713 STANDBY		 +DATA/topnet/onlinelog/group_13.277.117204898721 STANDBY		 +DATA/topnet/onlinelog/group_21.264.117204899722 STANDBY		 +DATA/topnet/onlinelog/group_22.262.117204899723 STANDBY		 +DATA/topnet/onlinelog/group_23.259.117204899914 rows selected.

主库参数修改

--查看name参数
SQL> show parameter db_nameNAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
db_name 			     string			       topnetSQL> show parameter db_unique_nameNAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
db_unique_name			     string			       topnetSQL> show parameter instance_nameNAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
instance_name			     string			       topnet1SQL> show parameter service_nameNAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
service_names			     string			       topnet

DB_NAME备库要与主库保持一致,

DB_UNIQUE_NAME要有所区别,不能一样,

参数DG_CONFIG和LOG_ARCHIVE_CONFIG中会用到db_unique_name

log_archive_dest_2里的service=后面跟的是服务名,就是写到TNSNAMES.ORA里的

主库修改参数如下,在RAC1节点执行

alter system set log_archive_config='dg_config=(topnet,topnetdg)' sid='*';
alter system set log_archive_dest_1='location=+ARCH valid_for=(all_logfiles,all_roles) db_unique_name=topnet' sid='*';
alter system set log_archive_dest_2='service=topnetdg async noaffirm valid_for=(online_logfiles,primary_role) db_unique_name=topnetdg' scope=both sid='*';
alter system set standby_file_management=auto scope=both sid='*';
alter system set fal_client='topnet' scope=both sid='*';
alter system set fal_server='topnetdg' scope=both sid='*';
alter system set log_archive_max_processes=10 scope=both;
alter system set db_file_name_convert='/oradata/topnetdg/datafile','+DATA/topnet/datafile','/oradata/topnetdg/tempfile','+DATA/topnet/tempfile' scope=spfile sid='*';
alter system set log_file_name_convert='/oradata/topnetdg/onlinelog','+DATA/orcl/onlinelog' scope=spfile sid='*';

关闭数据库使参数生效

(这里关库重启主要是为了让db_file_name_convert和log_file_name_convert立即生效!这两个参数如果这里不配置也可以!等需要的时候再配置。如果配置了该参数没有立即重启库,以后可能会出现1个实例崩溃后无法正常启动,提示参数不致!!!!)

srvctl stop database -d topnet -o immediate

启动数据库实例

srvctl start database -d topnet -o open

主库创建pfile备份文件

由于主库是RAC,RAC和单点的pfile文件不同。RAC每个节点的pfile文件是指向共享磁盘spfile文件的一个链接,如下:

--切换到$ORACLE_HOME/dbs目录
cd /u01/app/oracle/product/11.2.0/db/dbs--查看RAC的pfile参数文件内容
strings inittopnet1.ora  
SPFILE='+DATA/topnet/spfiletopnet.ora'--创建spfile文件对应的pfile参数文件  RAC任一节点执行均可,本文档在节点1执行
su - oracle
sqlplus / as sysdba
create pfile='/home/oracle/pfile_topnet1_20240620.ora' from spfile;

主库修改监听文件tnsnames.ora

su - oracle
cd $ORACLE_HOME/network/admin
cp tnsnames.ora tnsnames.ora_bak_20240620[oracle@orcl01:/u01/app/oracle/product/11.2.0/db/network/admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.TOPNET =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = orcl-scan)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = topnet)))TOPNETDG =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.52 )(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = topnetdg)))

备库单点

备库创建目录

cd /oradata
mkdir -p topnetdg/datafile
mkdir -p topnetdg/onlinelog
mkdir -p topnetdg/tempfile
mkdir -p topnetdg/controlfile
mkdir -p topnetdg/archivelog[oracle@topnetdg:/home/oracle]$ cd $ORACLE_BASE
[oracle@topnetdg:/u01/app/oracle]$ pwd
/u01/app/oracle
[oracle@topnetdg:/u01/app/oracle]$ ls
cfgtoollogs checkpoints diag oradata product 
[oracle@topnetdg:/u01/app/oracle]$ mkdir -p admin/topnetdg/adump
[oracle@topnetdg:/u01/app/oracle]$ mkdir -p admin/topnetdg/dpdump
[oracle@topnetdg:/u01/app/oracle]$ mkdir -p admin/topnetdg/hdump
[oracle@topnetdg:/u01/app/oracle]$ mkdir -p admin/topnetdg/pfile
[oracle@topnetdg:/u01/app/oracle]$ mkdir -p /u01/app/oracle/fast_recover_area

备库创建口令文件

拷贝主库RAC两个节点任意一个节点的口令文件到备库的$ORACLE_HOME/dbs目录下(本文档是在主库RAC1节点执行),然后在备库重命名口令文件

--在主库RAC1节点执行,拷贝主库RAC两个节点任意一个节点的口令文件到备库的$ORACLE_HOME/dbs目录下
su - oracle
cd $ORACLE_HOME/dbs
scp orapwtopnet1 oracle@192.168.40.52:/u01/app/oracle/product/11.2.0/db/dbs/--在备库重命名口令文件  口令文件命令格式orapw+sid
cd $ORACLE_HOME/dbs
mv orapwtopnet1 orapwtopnetdg

备库创建参数文件

拷贝主库RAC两个节点任意一个节点新创建的pfile参数文件到备库的$ORACLE_HOME/dbs目录下(本文档是在主库RAC1节点执行),然后在备库上修改参数文件

--在主库RAC1节点执行,拷贝主库RAC两个节点任意一个节点的参数文件到备库的$ORACLE_HOME/dbs目录下
su - oracle
cd $ORACLE_HOME/dbs
scp pfile_topnet1_20240620.ora oracle@192.168.40.52:/home/oracle/

注意备库参数文件中db_files参数要与主库RAC的db_files参数进行一下比较,要等于或多于主库RAC的db_files参数值。

注意db_file_name_convert参数:如果主库RAC的数据文件在多个路径下且有重名的数据文件情况下,此时注意修改该参数值不要在同一个文件夹下!!

修改后内容如下:

[oracle@topnetdg:/home/oracle]$ cat pfile_topnet1_20240620.ora
*.audit_file_dest='/u01/app/oracle/admin/topnetdg/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/oradata/topnetdg/controlfile/control01.ctl','/oradata/topnetdg/controlfile/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_name_convert='+DATA/topnet/datafile','/oradata/topnetdg/datafile','+DATA/topnet/tempfile','/oradata/topnetdg/tempfile'
*.db_name='topnet'
*.db_recovery_file_dest='/u01/app/oracle/fast_recover_area'
*.db_recovery_file_dest_size=4621074432
*.db_files=1024
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=topnetdgXDB)'
*.fal_client='topnetdg'
*.fal_server='topnet'
*.log_archive_config='dg_config=(topnet,topnetdg)'
*.log_archive_dest_1='location=/oradata/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=topnetdg'
*.log_archive_dest_2='service=topnet async noaffirm valid_for=(online_logfiles,primary_role) db_unique_name=topnet'
*.log_archive_max_processes=10
*.log_file_name_convert='+DATA/topnet/onlinelog','/oradata/topnetdg/onlinelog'
*.log_archive_format='%t_%s_%r.dbf'
*.db_unique_name='topnetdg'
*.service_names='topnetdg'
*.undo_tablespace='UNDOTBS1'
*.memory_target=1645215744
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.standby_file_management='AUTO'

备库创建监听文件

listener.ora文件

增加静态监听内容:SID_LIST_LISTENER部分为静态监听内容

[oracle@topnetdg:/u01/app/oracle/product/11.2.0/db/network/admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.52)(PORT = 1521))))SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db)(SID_NAME = topnetdg)))ADR_BASE_LISTENER = /u01/app/oracle
tnsnames.ora文件

可将主库RAC节点1上的tnsnames.ora文件拷贝到备库,然后进行修改,修改后如下:

[oracle@orcl01:/u01/app/oracle/product/11.2.0/db/network/admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.TOPNET =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.200)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = topnet)))TOPNETDG =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.52 )(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = topnetdg)))
备库重启监听服务
lsnrctl stop
lsnrctl start

若跳过该步骤,后面rman连接主备库时会报错:

[oracle@topnetdg:/home/oracle]$ rman target sys/oracle@topnet auxiliary sys/oracle@topnetdgRecovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 20 11:31:19 2024Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.connected to target database: TOPNET (DBID=3403746080)
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-12514: TNS:listener does not currently know of service requested in connect descriptor

部署过程

备库启动实例至nomount状态

--通过pfile参数启库到nomount状态
idle 20-JUN-24> startup nomount  pfile='/home/oracle/pfile_topnet1_20240620.ora';
ORACLE instance started.Total System Global Area 1653518336 bytes
Fixed Size		    2253784 bytes
Variable Size		 1006636072 bytes
Database Buffers	  637534208 bytes
Redo Buffers		    7094272 bytes--通过pfile文件创建spfile文件
create spfile from pfile='/home/oracle/pfile_topnet1_20240620.ora';--关库
shutdown abort--spfile参数文件启库
startup nomount--验证启库是通过spfile文件
set linesize 999
show parameter pfileNAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ------------------------------
spfile				     string			       /u01/app/oracle/product/11.2.0/db/dbs/spfiletopnetdg.ora--依据spfile参数文件  创建$ORACLE_HOME/dbs目录下的pfile文件
create pfile from spfile;

启动的同时可以查看数据库日志观察数据库的操作:

su - oracle
cd $ORACLE_BASE/diag/rdbms/topnetdg/topnetdg/trace
tail -300f alert_topnetdg.log

tnsping后面跟的是tnsnames.ora文件中配置的网络名

RMAN复制主库RAC数据到备库,进行同步

RMAN复制主库RAC数据到备库,进行同步,数据同步完成后备库从startup nomount变成mount状态。

验证主备库网络

--备库验证主备库网络
tnsping topnet
tnsping topnetdg

输出的详细结果如下:


[oracle@topnetdg:/home/oracle]$ tnsping topnetdgTNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 20-JUN-2024 11:29:02Copyright (c) 1997, 2013, Oracle.  All rights reserved.Used parameter files:
/u01/app/oracle/product/11.2.0/db/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.52)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = topnetdg)))
OK (0 msec)

rman连接主备库

[oracle@topnetdg:/home/oracle]$ rman target sys/oracle@topnet auxiliary sys/oracle@topnetdgRecovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 20 11:35:13 2024Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.connected to target database: TOPNET (DBID=3403746080)
connected to auxiliary database (not started)
问题处理
rman连接主备库时会报错
--问题描述
rman连接主备库时会报错
[oracle@topnetdg:/home/oracle]$ rman target sys/oracle@topnet auxiliary sys/oracle@topnetdgRecovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 20 11:31:19 2024Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.connected to target database: TOPNET (DBID=3403746080)
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-12514: TNS:listener does not currently know of service requested in connect descriptor--解决办法
检查主备库网络,都显示ok,说明主备库网络无问题
tnsping topnet
tnsping topnetdg重启备库监听
lsnrctl stop
lsnrctl start

复制主库数据到备库

复制主库数据到备库,有2种场景可选,视情况进行选择。

场景1:默认复制数据到备库未开启并行
duplicate target database for standby from active database nofilenamecheck;

详细过程如下:

RMAN> duplicate target database for standby from active database nofilenamecheck;Starting Duplicate Db at 20-JUN-24
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISKcontents of Memory Script:
{backup as copy reusetargetfile  '/u01/app/oracle/product/11.2.0/db/dbs/orapwtopnet1' auxiliary format'/u01/app/oracle/product/11.2.0/db/dbs/orapwtopnetdg'   ;
}
executing Memory ScriptStarting backup at 20-JUN-24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=64 instance=topnet1 device type=DISK
Finished backup at 20-JUN-24contents of Memory Script:
{backup as copy current controlfile for standby auxiliary format  '/oradata/topnetdg/controlfile/control01.ctl';restore clone controlfile to  '/oradata/topnetdg/controlfile/control02.ctl' from'/oradata/topnetdg/controlfile/control01.ctl';
}
executing Memory ScriptStarting backup at 20-JUN-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/db/dbs/snapcf_topnet1.f tag=TAG20240620T123540 RECID=1 STAMP=1172147741
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 20-JUN-24Starting restore at 20-JUN-24
using channel ORA_AUX_DISK_1channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 20-JUN-24contents of Memory Script:
{sql clone 'alter database mount standby database';
}
executing Memory Scriptsql statement: alter database mount standby databasecontents of Memory Script:
{set newname for tempfile  1 to"/oradata/topnetdg/tempfile/temp.269.1172048549";switch clone tempfile all;set newname for datafile  1 to"/oradata/topnetdg/datafile/system.275.1172048469";set newname for datafile  2 to"/oradata/topnetdg/datafile/sysaux.260.1172048469";set newname for datafile  3 to"/oradata/topnetdg/datafile/undotbs1.278.1172048469";set newname for datafile  4 to"/oradata/topnetdg/datafile/users.281.1172048469";set newname for datafile  5 to"/oradata/topnetdg/datafile/undotbs2.261.1172048561";backup as copy reusedatafile  1 auxiliary format"/oradata/topnetdg/datafile/system.275.1172048469"   datafile2 auxiliary format"/oradata/topnetdg/datafile/sysaux.260.1172048469"   datafile3 auxiliary format"/oradata/topnetdg/datafile/undotbs1.278.1172048469"   datafile4 auxiliary format"/oradata/topnetdg/datafile/users.281.1172048469"   datafile5 auxiliary format"/oradata/topnetdg/datafile/undotbs2.261.1172048561"   ;sql 'alter system archive log current';
}
executing Memory Scriptexecuting command: SET NEWNAMErenamed tempfile 1 to /oradata/topnetdg/tempfile/temp.269.1172048549 in control fileexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting backup at 20-JUN-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/topnet/datafile/system.275.1172048469
output file name=/oradata/topnetdg/datafile/system.275.1172048469 tag=TAG20240620T123549
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/topnet/datafile/sysaux.260.1172048469
output file name=/oradata/topnetdg/datafile/sysaux.260.1172048469 tag=TAG20240620T123549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATA/topnet/datafile/undotbs1.278.1172048469
output file name=/oradata/topnetdg/datafile/undotbs1.278.1172048469 tag=TAG20240620T123549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/topnet/datafile/undotbs2.261.1172048561
output file name=/oradata/topnetdg/datafile/undotbs2.261.1172048561 tag=TAG20240620T123549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/topnet/datafile/users.281.1172048469
output file name=/oradata/topnetdg/datafile/users.281.1172048469 tag=TAG20240620T123549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 20-JUN-24sql statement: alter system archive log currentcontents of Memory Script:
{switch clone datafile all;
}
executing Memory Scriptdatafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=1172147784 file name=/oradata/topnetdg/datafile/system.275.1172048469
datafile 2 switched to datafile copy
input datafile copy RECID=2 STAMP=1172147784 file name=/oradata/topnetdg/datafile/sysaux.260.1172048469
datafile 3 switched to datafile copy
input datafile copy RECID=3 STAMP=1172147784 file name=/oradata/topnetdg/datafile/undotbs1.278.1172048469
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=1172147784 file name=/oradata/topnetdg/datafile/users.281.1172048469
datafile 5 switched to datafile copy
input datafile copy RECID=5 STAMP=1172147784 file name=/oradata/topnetdg/datafile/undotbs2.261.1172048561
Finished Duplicate Db at 20-JUN-24
场景2:复制数据到备库开启并行
run 
{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
allocate auxiliary channel c1 type disk;
allocate auxiliary channel c2 type disk;
allocate auxiliary channel c3 type disk;
allocate auxiliary channel c4 type disk;
duplicate target database for standby from active database nofilenamecheck;
}

详细过程未做实验。

问题处理
RMAN-04006&ORA-27101
--问题描述
复制主库RAC数据向备份时提示如下报错
RMAN> duplicate target database for standby from active database nofilenamecheck;Starting Duplicate Db at 20-JUN-24
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 06/20/2024 12:32:58
RMAN-05501: aborting duplication of target database
RMAN-06403: could not obtain a fully authorized session
RMAN-04006: error from auxiliary database: ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory--问题原因
备库未启动至nomount状态--解决办法
启动备库
startup nomount

查看复制完数据后备库状态

RMAN复制主库RAC数据到备库,进行同步,数据同步完成后备库从startup nomount变成mount状态。

--查看备库情况
idle 20-JUN-24> set linesize 999
idle 20-JUN-24> select dbid,name,open_mode,database_role from v$database;DBID NAME 									    OPEN_MODE							 DATABASE_ROLE
---------- -------------------------------------------------------------------------------- ------------------------------------------------------------ ------------------------------------------------
3403746080 TOPNET									    MOUNTED							 PHYSICAL STANDBY

同步数据

--mount模式启动主备库实时同步(ADG)
alter database recover managed standby database using current logfile disconnect from session;

打开备库至open状态

--取消备库同步主库数据
idle 20-JUN-24> alter database recover managed standby database cancel;Database altered.--打开备库至open状态   open备库前必须先停止数据同步
idle 20-JUN-24> alter database open;Database altered.--查看备库状态   OPEN_MODE 由mount 转变成了 READ ONLYidle 20-JUN-24> select dbid,name,open_mode,database_role from v$database;DBID NAME 									    OPEN_MODE							 DATABASE_ROLE
---------- -------------------------------------------------------------------------------- ------------------------------------------------------------ ------------------------------------------------
3403746080 TOPNET									    READ ONLY							 PHYSICAL STANDBY--备库open库后,备库开启实时同步主库数据  OPEN_MODE 由READ ONLY 转变成了 READ ONLY WITH APPLY
idle 20-JUN-24> alter database recover managed standby database using current logfile disconnect from session;Database altered.idle 20-JUN-24> select dbid,name,open_mode,database_role from v$database;DBID NAME 									    OPEN_MODE							 DATABASE_ROLE
---------- -------------------------------------------------------------------------------- ------------------------------------------------------------ ------------------------------------------------
3403746080 TOPNET									    READ ONLY WITH APPLY					 PHYSICAL STANDBY

验证主备库数据同步

主库创建测试数据

--创建用户
create user pijiake identified by pijiake;
grant resource,connect to pijiake;--构建测试数据
create table pijiake.t1 as select level as id from dual connect by level<=10;--查询测试数据
select count(*) from pijiake.t1;

备库观察数据是否同步

主备库数据查询一样即主备库ADG部署完成。

--查询测试数据
select count(*) from pijiake.t1;

同步管理

查看主备库状态

--主库信息   switchover显示to standby或者session active为正常
set linesize 999
col open_mode for a30
select name,open_mode,database_role,protection_mode,switchover_status from v$database;NAME			       OPEN_MODE		      DATABASE_ROLE				       PROTECTION_MODE						    SWITCHOVER_STATUS
------------------------------ ------------------------------ ------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------------------
TOPNET			       READ WRITE		      PRIMARY					       MAXIMUM PERFORMANCE					    TO STANDBY--备库信息
set linesize 999
col open_mode for a30
select name,open_mode,database_role,protection_mode,switchover_status from v$database;NAME										 OPEN_MODE			DATABASE_ROLE					 PROTECTION_MODE					      SWITCHOVER_STATUS
-------------------------------------------------------------------------------- ------------------------------ ------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------------------
TOPNET										 READ ONLY WITH APPLY		PHYSICAL STANDBY				 MAXIMUM PERFORMANCE					      NOT ALLOWED

备库停止同步进程

--停止同步进程
sqlplus / as sysdba
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

备库开启实时同步

方法1:使用alter database recover managed standby database delay 120 disconnect from session;
方法2:使用alter system set log_archive_dest_3='service=db3 lgwr async delay=120 valid_for= (all_logfiles,all_roles) db_unique_name=db3';
在ADG服务器上启动一个vip,此vip是RAC的service-ip/scan-ip,这样可省去应用程序修改库连接配置和重启的时间,大大缩减业务中断时长。
观察数据同步延迟情况可以通过查看视图v$standby_event_histogram。

同步验证日志查看

在主库上进行日志切换

ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time FROM v$archived_log ORDER BY sequence#;
ALTER SYSTEM SWITCH LOGFILE;

在从库上执行如下语句查看日志是否同步切换到最新

ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;

查看切换状态,是否有GAP或目标不可达的情况发生

select switchover_status from v$database;

主库返回to standby或session active,备库返回NOT ALLOWED表示无问题。

日志切换

alter system archive log current;

ADG同步延迟

--观察数据同步延迟
select * from v$standby_event_histogram;

查询当前SCN号

select  to_char(current_scn) from v$database;

查询是否同步

sqlplus / as sysdba
SELECT * FROM V$ARCHIVE_GAP;
SELECT max(sequence#) from v$archived_log where applied='YES';
SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY;

参考链接:搭建记录:duplicate搭建oracle rac到单实例搭建物理DG_V7 - 墨天轮

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/30692.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【开关电源】Buck 降压电路

文章目录 前言基本组成工作原理电路特点工作模式设计与实现 前言 Buck降压电路&#xff0c;也称为降-降&#xff08;step-down&#xff09;转换器&#xff0c;是一种直流-直流&#xff08;DC-DC&#xff09;电源转换器&#xff0c;用于将输入电压转换为较低的输出电压。这种电…

小林图解系统-二.硬件结构 2.7为什么0.1+0.2不等于0.3?

为什么负数要用补码表示&#xff1f; 十进制转二进制&#xff1a;除2取余法 [整数类型]的数字在计算机的存储方式&#xff1a;int类型&#xff0c;32位&#xff0c;最高位[符号标志位]&#xff0c;正数符号位0&#xff0c;负数的符号位1&#xff0c;剩余的31位则表示2进制数据…

计算机网络 —— 应用层(电子邮件)

计算机网络 —— 应用层&#xff08;电子邮件&#xff09; 电子邮件发送电子邮件的过程SMTP特性工作流程 电子邮件格式MIME关键组件工作方式 POP/IMAPPOP&#xff08;邮局协议&#xff09;IMAP&#xff08;因特网邮件访问协议&#xff09; 基于万维网的电子邮箱特点优势常见的基…

gorm 一对多

type Author struct {AID int gorm:"primary_key;AUTO_INCREMENT"Name stringAge stringSex string//关联关系Article []Article gorm:"ForeignKey:Auid;AssociationForeignKey:AID" } type Article struct {ArId int gorm:"primary_key;AUTO_I…

TF-IDF在现代搜索引擎优化策略中的作用

TF-IDF&#xff08;Term Frequency-Inverse Document Frequency&#xff09;是一种用于文本挖掘和信息检索的统计方法&#xff0c;用来评估一个词语对于一个文档或一个语料库的重要程度。TF-IDF算法结合了词频&#xff08;TF&#xff09;和逆文档频率&#xff08;IDF&#xff0…

软考高级资格是否等于高级工程师或者是否拥有职称?

软考采用"考试取代评审"的方式&#xff0c;一旦通过考试&#xff0c;就不再需要进行相应的职称认定和评审工作。取得考试通过证书意味着具备了相应工作岗位的水平和职称资格。软考的初级、中级、高级分别对应着技术员/助理工程师、工程师和高级工程师这些职称。 大多…

osi七层参考模型和tcp/ip模型的区别与相似之处

osi七层参考模型&#xff1a; 2.tcp/ip四层参考模型&#xff1a; osi七层参考模型与tcp/ip四层参考模型的相似与区别&#xff1a; 相同点&#xff1a; 2者都是模型化层次化 下层对上层提供服务支持 每层协议彼此相互独立 不同点&#xff1a;OSI先有模型才有协议 TCP/IP先有…

MK米客方德 SD NAND 功耗对比

在这个数据驱动的时代&#xff0c;MK米客方德在工业存储领域不断突破&#xff0c;凭借卓越的产品和服务赢得了广泛的客户认可。我们自主研发的嵌入式存储芯片已实现规模化量产&#xff0c;而我们最新一代的工业级SD NAND—AST系列也已正式推出。 该产品采用LGA-8(6*8mm)封装&am…

为什么选择飞速(FS)25G SFP28光模块?

25G SFP28光模块是一种传输速率为25Gbps的光模块。与传统的10G光模块相比&#xff0c;它具有更高的端口密度&#xff0c;可以通过减少TOR交换机和线缆的数量来节省运营成本。同时&#xff0c;25G光模块为中小型数据中心提供更节能高效的选择&#xff0c;非常适合连接中小型数据…

.NET C# 使用GDAL读取FileGDB要素类

.NET C# 使用GDAL读取FileGDB要素类 目录 .NET C# 使用GDAL读取FileGDB要素类1 环境2 Nuget3 Code 1 环境 VisualStudio2022 .NET6 GDAL 3.7.5 2 Nuget 3 Code using OSGeo.OGR; using OSGeo.OSR;namespace TestGDAL {internal class Program{static void Main(string[] a…

浅谈配置元件之Java默认请求

浅谈配置元件之Java默认请求 1.简介 “Java默认请求”&#xff08;虽然直接名为"Java Request"更常见&#xff09;是一个高级配置元件&#xff0c;它允许用户通过Java代码自定义请求逻辑&#xff0c;为测试提供了极高的灵活性和扩展性。 2.Java请求组件概述 在JM…

Ubuntu/Linux系统安装JDK1.8(带jdk1.8资源和操作教程)

文章目录 前言一、JDK1.8下载二、上传三、安装四、配置环境变量五、查看总结 前言 &#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;Ubuntu/Linux jdk1.8安装包&#xff…

【机器学习】【深度学习】MXnet神经网络图像风格迁移学习简介

使用部分 一、编程环境 编程环境使用Windows11上的Anaconda环境&#xff0c;Python版本为3.6. 关于Conda环境的建立和管理&#xff0c;可以参考我的博客&#xff1a;【Anaconda】【Windows编程技术】【Python】Anaconda的常用命令及实操 二、项目结构&#xff08;代码非原创…

Hive期末总结

hive的概念&#xff0c;谁开发的 Apache Hive 是一个Apache 软件基金会维护的开源项目 Facebook贡献 hive是一个基于hadoop的数据仓库工具&#xff08;对数据汇总查询和分析的工具&#xff09; hive执行原理 Hive通过给用户提供的一系列交互接口&#xff0c;接收到用户的指令…

关于面试被面试官暴怼:“几年研究生白读” 的前因后果

中午一个网友来信说自己和面试官干起来了,看完他的描述真是苦笑不得,这年头是怎么了,最近互联网CS消息满天飞,怎么连面试官都SB起来了呢? 大概是这样的:这位网友面试时被问及了Serializable接口的底层实现原理,因为这是一个标识性的空接口,大部分同学在学习时都秉持着会…

【Mybatis-plus】查询及更新为null或空字符串

前言 查询为 null 或者 空字符串时&#xff0c;可以使用 or() 关键字。 提示&#xff1a;以下是本篇文章正文内容&#xff0c;下面案例可供参考 查询 使用 LambdaQueryWrapper 查询 parentCode 为 null 或者 空字符串 的数据。 LambdaQueryWrapper<CompanyEntity> qu…

使用Vue+Antv-X6实现一个输送线可视化编辑器(支持拖拽、自定义连线、自定义节点等)

最近公司有这样的业务&#xff0c;要实现一个类似流程图的编辑器&#xff0c;可以拖拉拽之类的&#xff0c;网上寻找了一番&#xff0c;最终决定使用Antv-X6这个图形引擎&#xff0c;非常强大&#xff0c;文档多看几遍也就能上手使用了。感觉还不错就写个使用心得期望能帮助到同…

React 通信:深层传递(Props、Context、Children Jsx)

在之前的文章 探讨&#xff1a;围绕 props 阐述 React 通信 中总结了关于“父子”组件传值&#xff0c;但是当需要在组件树中深层传递参数以及需要在组件间复用相同的参数时&#xff0c;传递 props 就会变得很麻烦。 实际案例&#xff1a; 下述展示有两种状态&#xff1a;① 详…

数据治理的七大核心技术 全面了解数据治理必读篇

在当今的数字化时代&#xff0c;数据已成为企业最宝贵的资产之一&#xff0c;其价值不仅体现在数据量的巨大&#xff0c;更在于数据的深度和宽度。随着大数据、云计算、物联网&#xff08;IoT&#xff09;和人工智能&#xff08;AI&#xff09;等技术的不断进步&#xff0c;企业…

Jenkins 发测试邮件报错 553 Mail from must equal authorized user

Jenkins 发测试邮件报错 553 Mail from must equal authorized user 报错信息报错原因解决办法 报错信息 org.eclipse.angus.mail.smtp.SMTPSenderFailedException: 553 Mail from must equal authorized user at org.eclipse.angus.mail.smtp.SMTPTransport.mailFrom(SMTPTra…