当前位置: 代码迷 >> 综合 >> RHEL 7.6 安装oracle database 19c dataguard on ASM Part5: Dataguard配置
  详细解决方案

RHEL 7.6 安装oracle database 19c dataguard on ASM Part5: Dataguard配置

热度:84   发布时间:2024-01-12 23:32:13.0

RHEL 7.6 安装oracle database 19c dataguard on ASM Part1: 基础环境配置

RHEL 7.6 安装oracle database 19c dataguard on ASM Part2: Grid Infrastructure配置

RHEL 7.6 安装oracle database 19c dataguard on ASM Part3: ASM磁盘组配置

RHEL 7.6 安装oracle database 19c dataguard on ASM Part4: Database配置

 

9 DataGuard配置

Database DB_UNIQUE_NAME Oracle Net Service Name
Primary eighteenc eighteenc
Physical standby nodetwodg nodetwodg

 

 

 

 

[root@node2dg ~]# more /etc/hosts10.6.0.139	node2
10.6.0.137	node2dg

主库启动到force logging

set line 188
col name for a20
col open_mode for a20
select name,open_mode from v$pdbs;col force_logging for a20
select force_logging from v$database;alter database force logging;

主库启动归档模式

show con_namearchive log list;show  parameter recovery;

注:归档路径“USE_DB_RECOVERY_FILE_DEST”,db_recovery_file_dest=+ARCH

主库添加standby redo logfile

Oracle 12c开始,online redo log 和控制文件是保存在CDB中的,PDB中只有运行需要的数据文件,所以我们这里加standby redo log,也是在CDB中加。

查看 Primary 库的 REDO 相关信息:

show con_nameselect  group#, members, bytes/1024/1204 file_MB  from v$log;select  member from  v$logfile;

添加 4(3+1)个standby  logfile:

alter database add standby logfile '+DATA/NINETEENC/stdredo01.log' size 200M;
alter database add standby logfile '+DATA/NINETEENC/stdredo02.log' size 200M;
alter database add standby logfile '+DATA/NINETEENC/stdredo03.log' size 200M;
alter database add standby logfile '+DATA/NINETEENC/stdredo04.log' size 200M;

配置监听

主库

NINETEENC =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = node2)(PORT = 1521))(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))))ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON		# line added by Agent
VALID_NODE_CHECKING_REGISTRATION_LISTENER=ON		# line added by Agent

备库

vi /app/product/19.2.0/crs/network/admin/listener.ora

#Backup file is  /app/product/19.2.0/crs/srvm/admin/listener.ora.bak.nodedg line added by Agent
# listener.ora Network Configuration File: /app/product/19.2.0/crs/network/admin/listener.ora
# Generated by Oracle configuration tools.NODEDG =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = node2dg)(PORT = 1522))))ADR_BASE_NODEDG = /app/gridSID_LIST_NODEDG =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = nineteen)(ORACLE_HOME = /app/oracle/product/19.2.0/dbhome_1)(SID_NAME = nodetwodg)))#ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON		# line added by Agent
#VALID_NODE_CHECKING_REGISTRATION_LISTENER=ON		# line added by Agent

主备库配置tnsnames文件

nineteenc =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.6.0.139)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = nineteenc)))nodetwodg =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.6.0.137)(PORT = 1522)))(CONNECT_DATA =(SERVICE_NAME = nineteen)(RU=A)))

重新装载监听配置文件 

lsnrctl reloadlsnrctl start nodedg

配置监听service

netmgr

点选方才创建的监听器,选择Database Services菜单 

点选“add database”

填入Global Database Name和本地实例的SID信息,并确认ORACLE HOME Directory(应是Grid Infrastructure的Home目录)正确后点选Save Network Configuration。 

 查看nodedg监听状态

注: 1.SID使用字母,尽可能不要使用‘字母&数字&字母’的模式(node2dg)。

         2.监听名不要与SID相同。

备库创建必要的目录

mkdir -p /app/oracle/admin/nodetwodg/adump

主库创建pfile 文件并修改pfile 内容

create pfile from spfile;

主库配置initeighteenc.ora,添加下面内容

#add for primary database
*.db_name='nineteen'
*.db_unique_name='nineteenc'
*.log_archive_config='dg_config=(nineteenc,nodetwodg)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=nineteenc'
*.log_archive_dest_2='service=nodetwodg valid_for=(online_logfiles,primary_role) lgwr affirm sync db_unique_name=nodetwodg'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'
*.fal_server='nodetwodg'
*.DB_FILE_NAME_CONVERT='nineteenc','nodetwodg'
*.LOG_FILE_NAME_CONVERT='nineteenc','nodetwodg'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=nineteencXDB)'

重启主库

shutdown immediate;startup pfile ='/app/oracle/product/19.2.0/dbhome_1/dbs/initnineteenc.ora';create spfile from pfile;

参数文件,密码文件copy至备库

scp -r /app/oracle/product/19.2.0/dbhome_1/dbs/initnineteenc.ora oracle@node2dg:/app/oracle/product/19.2.0/dbhome_1/dbs/initnodetwodg.orascp -r /app/oracle/product/19.2.0/dbhome_1/dbs/orapwnineteenc oracle@node2dg:/app/oracle/product/19.2.0/dbhome_1/dbs/orapwnodetwodg

配置备库initdg.ora,添加下面内容

#add for physical standby database
*.db_name='nineteen'
*.db_unique_name='nodetwodg'
*.log_archive_config='dg_config=(nineteenc,nodetwodg)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=nodetwodg'
*.log_archive_dest_2='service=nineteenc valid_for=(online_logfiles,primary_role) lgwr affirm sync db_unique_name=nineteenc'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'
*.fal_server='nineteenc'
*.DB_FILE_NAME_CONVERT='nineteenc','nodetwodg'
*.LOG_FILE_NAME_CONVERT='nineteenc','nodetwodg'#主备库sid不同进行配置调整
*.dispatchers='(PROTOCOL=TCP) (SERVICE=nodetwodgXDB)'
*.audit_file_dest='/app/oracle/admin/nodetwodg/adump'
*.control_files='+DATA/NODETWODG/control01.ctl','+DATA/NODETWODG/control02.ctl'

启动备库至nomount

startup nomount pfile='/app/oracle/product/19.2.0/dbhome_1/dbs/initnodetwodg.ora';create spfile from pfile;

备库ASM磁盘组创建相关目录

#切换grid用户su - grid#asm磁盘组CLI界面asmcmd#切换data目录cd data#创建目录mkdir nodetwodg/pdb01 nodetwodg/pdbseed

 

开始进行Active duplicate

#链接主备库
rman target sys/oracle@nineteenc auxiliary sys/oracle@nodetwodg#构建DG
duplicate target database for standby from active database nofilenamecheck dorecover;

注:主备库ASM的目录需要一致,备库不存在需要手动创建

打开备库、应用apply

--- 查看备库状态col name for a15
col open_mode for a10
col database_role for a18
col db_unique_name for a15
col cdb for a10
select name,open_mode,database_role,db_unique_name,cdb from v$database;--- 查看CDB/PDB状态select con_id,dbid,con_uid,name,open_mode,restricted from v$pdbs;

打开备库

#打开备库
alter database open;#查看PDB
show pdbs;#打开扩展库
alter pluggable database pdb01 open;

查看PDB service状态

set lines 100
col name format a20
col network_name format a20
col pdb format a20
select service_id,name,network_name,global_service,pdb,enabled from dba_services;

查看主备库状态

启动real-time apply

alter database recover managed standby database using current logfile disconnect from session;

验证日志应用

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 

  相关解决方案