首页 > 其他分享 >19c DG broke搭建

19c DG broke搭建

时间:2025-01-13 10:24:03浏览次数:1  
标签:00 set database standby DG orcl stdy broke 19c

目录

环境细节

ENV Detail Primary Standby
DB Unique orcl orclstby
DB Name orcl orcl
hostname:Server IP db1:192.168.32.172 db2:192.168.32.172

hosts已经配置好

主库配置

1.开启归档和附加日志

shutdown immediate;
startup mount;
alter database archivelog;
alter database open;



alter database force logging;
-- Make sure at least one logfile is present.
alter system switch logfile;



SQL> select FORCE_LOGGING,log_mode from v$database;
FORCE_LOGGING LOG_MODE
————————————— ————
YES                    ARCHIVELOG

2.添加备库日志

Create standby redo logs on the primary database (in case of switchovers). The standby redo logs should be at least as big as the largest online redo log and there should be one extra group per thread compared the online redo logs. In my case, the following standby redo logs must be created on both servers.

在主数据库上创建备用重做日志(在switchovers的情况下)。备用重做日志应该至少与最大的在线重做日志一样大,并且与在线重做日志相比,每个线程应该有一个额外的组

备用的redo日志大小和redo大小一样,每个thread对应一个standbylogfile,oracle建议主库多一个

个人测试,备用redo组的大小和主库比不能一个大一个小,可能会导致备库间歇性的同步慢

#查询日志组数
select thread#,group#,members,bytes/1024/1024/1024 from v$log order by thread#;
select thread#,group#,bytes/1024/1024/1024 from v$standby_log;
SELECT group#, members, bytes/1024/1024, status FROM v$log;


#如果使用OMF
alter database add standby logfile thread 1 group 10 size 200m;
alter database add standby logfile thread 1 group 11 size 200m;
alter database add standby logfile thread 1 group 12 size 200m;
alter database add standby logfile thread 1 group 13 size 200m;


#如果未使用OMF
alter database add standby logfile thread 1 group 10 ('/u01/oradata/cdb1/standby_redo01.log') size 200m;
alter database add standby logfile thread 1 group 11 ('/u01/oradata/cdb1/standby_redo02.log') size 200m;
alter database add standby logfile thread 1 group 12 ('/u01/oradata/cdb1/standby_redo03.log') size 200m;
alter database add standby logfile thread 1 group 13 ('/u01/oradata/cdb1/standby_redo04.log') size 200m;

#如果是RAC,则对于的两个thread都要添加

3.如果使用闪回

4.检测参数配置

dbname和db_unique

备库的dbname和主库可以相同,但db_unique_name不同

SQL> show parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      orcl
SQL> show parameter db_unique_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      orcl

ALTER SYSTEM SET log_archive_config='dg_config=(orcl,orcl_stdy)' SCOPE=both;
ALTER SYSTEM SET log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=orcl' SCOPE=both;
ALTER SYSTEM SET log_archive_dest_2='service=orcl_stdy async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_stdy' SCOPE=both;
alter system set log_archive_dest_state_1=enable; 
alter system set log_archive_dest_state_2=enable; 

#默认alter system set log_archive_max_processes=4; 
#默认alter system set remote_login_passwordfile='EXCLUSIVE' scope=spfile;

ALTER SYSTEM SET fal_server='orcl_stdy' SCOPE=both;
ALTER SYSTEM SET fal_client='orcl' SCOPE=both;
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=both;

tns配置,两台一样

添加:

orcl =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

orcl_stdy =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db2)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl_stdy)
    )
  )

listener.ora

添加

实际环境中注意sid_name

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
  )


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/19.3/dbhome_1)
      (SID_NAME = orcl)
    )

    (SID_DESC =
      (GLOBAL_DBNAME = orclstd)
      (ORACLE_HOME = /u01/app/oracle/product/19.3/dbhome_1)
      (SID_NAME = orcl)
    )

  )

ADR_BASE_LISTENER = /u01/app/oracle

备库

拷贝密码文件,或者重建

orapwd file=orapwdb19c password=orac#123 entries=10

参数文件,rman duplicate搭建备库

#可以主库上导出,修改相关参数后给备库使用,
create pfile='/home/oracle/pfile.bak' from spfile;
startup nomount pfile='/u01/app/oracle/product/19.3/dbhome_1/dbs/initorcl.ora';
#我这里直接使用自己的,在配置dg_broke时会自动修改备库参数



#登录测试
[oracle@db2 ~]$ rman target sys/Oracle123@orcl auxiliary sys/Oracle123@orcl_stdy

Recovery Manager: Release 19.0.0.0.0 - Production on Fri Jan 3 09:27:17 2025
Version 19.3.0.0.0

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

connected to target database: ORCL (DBID=1716960432)
connected to auxiliary database: ORCL (not mounted)

RMAN>
duplicate target database
  for standby
  from active database
  dorecover
  spfile
    set db_unique_name='orcl_stdy' COMMENT 'Is standby'
  nofilenamecheck;

参考:

#手动修改db_unique_name='orcl_stdy'后,使用:
duplicate target database for standby nofilenamecheck from active database;

#(上门和下面这种会将数据路径默认转换到oradata下的ORCL_STDY)
duplicate target database
  for standby
  from active database
  dorecover
  spfile
    set db_unique_name='orcl_stdy' COMMENT 'Is standby'
  nofilenamecheck;

#手动尝试多次后,发现/u01/app/oracle/oradata下面生成的数据文件目录名是db_unique_name的值
#暂且记录,后续在研究

#如果需要转换文件位置,提前在参数文件设置,或者复制时设置(log_file_name_convert不设置,日志默认是在$ORACLE_HOME/dbs下)
duplicate target database
  for standby
  from active database
  dorecover
  spfile
    set db_unique_name='orcl_stdy' COMMENT 'Is standby'
    set db_file_name_convert='/original/directory/path1/','/new/directory/path1/','/original/directory/path2/','/new/directory/path2/'
    set log_file_name_convert='/original/directory/path1/','/new/directory/path1/','/original/directory/path2/','/new/directory/path2/'


参考:

#备库至少在nomount
#rman target sys/Oracle123@orcl auxiliary sys/Oracle123@orcl_stdy
#或者
#rman target sys/Oracle123@orcl auxiliary /


#或者参数文件修改后
#rman target sys/Oracle123@orcl auxiliary sys/Oracle123@orcl_stdy
#duplicate target database for standby nofilenamecheck from active database;


set项参数注意配置
run
{
allocate channel p1 type disk;
allocate channel p2 type disk;
allocate channel p3 type disk;
allocate channel p4 type disk;
allocate auxiliary channel s1 type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'db19c','db19cstby'
set db_name='db19c'
set db_unique_name='db19cstby'
set db_file_name_convert='/u01/app/oracle/oradata/DB19C','/u01/app/oracle/oradata/DB19CSTBY'
set log_file_name_convert='/u01/app/oracle/oradata/DB19C','/u01/app/oracle/oradata/DB19CSTBY'
set control_files='/u01/app/oracle/oradata/DB19CSTBY/standby1.ctl'
set log_archive_max_processes='5'
set fal_client='db19cstby'
set fal_server='db19c'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(db19c,db19cstby)'
set compatible='19.0.0.0.0'
set memory_target='6420m'
nofilenamecheck;
}

#parameter_value_convert 'orcl','orcl_stdy'

run
{
allocate channel p1 type disk;
allocate channel p2 type disk;
allocate channel p3 type disk;
allocate channel p4 type disk;
allocate auxiliary channel s1 type disk;
duplicate target database for standby from active database
spfile
set db_name='orcl'
set db_unique_name='orcl_stdy'
set fal_client='orcl_stdy'
set fal_server='orcl'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(orcl,orcl_stdy)'
set compatible='19.0.0.0.0'
nofilenamecheck;
}


FOR STANDBY:这告诉DUPLICATE命令将用于备用,因此它不会强制更改DBID。
FROM ACTIVE DATABASE:副本将直接从源数据文件创建,不需要额外的备份步骤。
DORECOVER:副本将包括恢复步骤,将备用数据恢复到当前时间点。
SPFILE:允许我们在从源服务器复制SPFILE时重置SPFILE中的值。
NOFILENAMECHECK:不检查目标文件位置。

配置BREOK

上面已完成后已经有了主备库,现在使用Data Guard Broker来管理

启用Data Guard Broker

#主备都启用

alter system set dg_broker_start=true;

主库上注册

[oracle@db1 ~]$ dgmgrl sys/Oracle123@orcl
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Fri Jan 3 11:25:01 2025
Version 19.3.0.0.0

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

Welcome to DGMGRL, type "help" for information.
Connected to "orcl"
Connected as SYSDBA.

#注册
#create configuration my_dg_config as primary database is orcl connect identifier is orcl;

DGMGRL> create configuration my_dg_config as primary database is orcl connect identifier is orcl;
Configuration "my_dg_config" created with primary database "orcl"


添加备库

add database orcl_stdy as connect identifier is orcl_stdy;


DGMGRL> add database orcl_stdy as connect identifier is orcl_stdy;
Database "orcl_stdy" added

启用

enable configuration;

DGMGRL> enable configuration;
Enabled.
##查看配置
DGMGRL> show configuration;

Configuration - my_dg_config

  Protection Mode: MaxPerformance
  Members:
  orcl      - Primary database
    orcl_stdy - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 32 seconds ago)

#查看数据库
DGMGRL> show database orcl

Database - orcl

  Role:               PRIMARY
  Intended State:     TRANSPORT-ON
  Instance(s):
    orcl

Database Status:
SUCCESS
#查看备库
DGMGRL> show database orcl_stdy

Database - orcl_stdy

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 1 second ago)
  Apply Lag:          0 seconds (computed 1 second ago)
  Average Apply Rate: 2.00 KByte/s
  Real Time Query:    OFF
  Instance(s):
    orcl

Database Status:
SUCCESS





#ORA-16778: redo transport error for one or more members可以尝试切一下日志

检查状态

Primary Side:-

SQL> select status,instance_name,database_role,protection_mode from v$database,v$instance;
STATUS INSTANCE_NAME DATABASE_ROLE PROTECTION_MODE
———— —————- —————- ——————–
OPEN          chennai              PRIMARY                  MAXIMUM AVAILABILITY

Standby Side:-

SQL> select status,instance_name,database_role,protection_mode from v$database,v$instance;
STATUS INSTANCE_NAME DATABASE_ROLE PROTECTION_MODE
———— —————- —————- ——————–
OPEN   delhi  PHYSICAL           STANDBY                 MAXIMUM AVAILABILITY

SQL> SELECT database_role, open_mode FROM v$database;

DATABASE_ROLE OPEN_MODE
—————- ——————–
PHYSICAL STANDBY READ ONLY WITH APPLY

switchover和failover

后面在补充

补充

备库上启动停止MRP

-- Stop managed recovery.
alter database recover managed standby database cancel;

-- Start managed recovery.
alter database recover managed standby database disconnect;

启停

dg broke下启动:
两边先启动监听,主库startup,备库startup,dg broke会自动恢复

DG进程

#会在mount后启动,DMON进程
[oracle@db1 ~]$ ps -ef | grep dmon
oracle    2017     1  0 09:48 ?        00:00:00 ora_dmon_orcl
oracle    9694  1752  0 10:08 pts/1    00:00:00 grep --color=auto dmon
[oracle@db2 ~]$ ps -ef | grep dmon
oracle    2325     1  0 09:49 ?        00:00:00 ora_dmon_orcl
oracle    3733  1981  0 10:08 pts/0    00:00:00 grep --color=auto dmon



ALTER DATABASE   MOUNT
2025-01-13T09:48:55.497516+08:00
Using default pga_aggregate_limit of 2048 MB
2025-01-13T09:48:57.232568+08:00
.... (PID:2030): Redo network throttle feature is disabled at mount time
2025-01-13T09:48:57.246339+08:00
Successful mount of redo thread 1, with mount id 1718089349
2025-01-13T09:48:57.246961+08:00
Database mounted in Exclusive Mode
Lost write protection disabled
.... (PID:2030): Using STANDBY_ARCHIVE_DEST parameter default value as USE_DB_RECOVERY_FILE_DEST [krsd.c:18157]
Completed: ALTER DATABASE   MOUNT
2025-01-13T09:48:57.335477+08:00
ALTER DATABASE OPEN
Data Guard Broker initializing...
2025-01-13T09:49:01.511182+08:00
Starting Data Guard Broker (DMON)
Starting background process INSV
2025-01-13T09:49:01.536098+08:00
INSV started with pid=38, OS id=2065
2025-01-13T09:49:04.658757+08:00
Starting background process NSV2
2025-01-13T09:49:04.683831+08:00
NSV2 started with pid=39, OS id=2088
2025-01-13T09:49:05.543795+08:00
Data Guard Broker initialization complete
Data Guard: verifying database primary role...
2025-01-13T09:49:08.052335+08:00
Starting background process RSM0
2025-01-13T09:49:08.076495+08:00
RSM0 started with pid=40, OS id=2116
2025-01-13T09:49:08.614298+08:00
Data Guard: broker startup completed
Data Guard: primary database controlfile verified
Ping without log force is disabled:
  instance mounted in exclusive mode.

标签:00,set,database,standby,DG,orcl,stdy,broke,19c
From: https://www.cnblogs.com/shipment/p/18668031

相关文章

  • 关于安卓edge无法播放Wordpress上传的mp4视频问题
    使用默认插件上传后,电脑端可以播放视频,其他手机浏览器均可播放视频,但是安卓edge无法加载视频。大概是如下图样子:经查发现电脑打开页面会显示站点部分不安全的提示,说明edge端做了一些阻挡处理,导致视频无法播放。找了一些资料后,发现可以自行修改加载视频的代码框架,于是修改如下:......
  • Kafka 是一个分布式流式平台,主要用于处理大规模、高吞吐量的消息传递、日志收集和实时
    Kafka集群是什么?Kafka是一个分布式流式平台,主要用于处理大规模、高吞吐量的消息传递、日志收集和实时数据流。Kafka集群是由多个Kafka服务器(称为Broker)组成的,它们共同工作以实现消息的高可用性、可靠性、可扩展性和容错性。Kafka集群的目的是确保消息的持久化和高效传输,同......
  • 为AI聊天工具添加一个知识系统 之30 概念整体运营平台:中间架构层的broker service的AP
    本文要点本项目(为AI聊天工具增加知识系统)通过完善“公路”的整体概念框架 最终(在外部)为三类公共运营性交通工具((高速-轿车taxi/中速--公交车bus/低速-卡车truck))提供运营平台。该平台对内通过明确交通路线上的三种“端”(end/stop/start)的一般术语框架作为程序的形式化规......
  • Knowledge Editing through Chain-of-Thought
    题目通过思路链进行知识编辑论文地址:https://arxiv.org/abs/2412.17727摘要    大型语言模型(LLM)在广泛的自然语言处理(NLP)任务中表现出卓越的能力。然而,由于频繁重新训练的成本很高,让这些模型与不断发展的世界知识保持同步仍然是一项重大挑战。为了应对这......
  • [CF1019C] Sergey's problem 做题记录
    小清新构造题,会就会,不会就不会。link注意到走两步很特殊,尝试从走一步拼出来,考虑归纳法:随便选择一个点\(x\),然后删掉\(x\)和所有\(y\)满足存在边\((x,y)\)。设剩下的图的答案集合为\(S\),若不存在\(z\inS\)满足存在边\((z,x)\),则将\(x\)加入\(S\)。否则......
  • qt 实现窗口置顶,qtdesigner创建的widget窗口集成程序里的用法
    参考https://blog.csdn.net/Larry_Yanan/article/details/123518788.ui文件如下新建的ui文件,编译一下就会生成对应的ui_xxx.h文件,文件内就有对应的namespaceUi声明的变量,这个变量要在mainwindow.h中声明,然后在mainwindow.cpp中new出来,具体使用如下mainwindow.h#ifnde......
  • Hyperledger Fabric v2.5.8 Endorsement failure
    2025-01-0916:47:36.545UTC016aWARN[vscc]Validate->Endorsmentpolicyfailureerror="validationofendorsementpolicyforchaincodefabcarintx12:0failed:implicitpolicyevaluationfailed-1sub-policiesweresatisfied,butthispolicyr......
  • [20250109]19c使用or_expand提示遇到的问题.txt
    [20250109]19c使用or_expand提示遇到的问题.txt--//生产系统使用19c,在使用or_expand提示时遇到的问题,在测试环境演示并做分析。1.环境:1.环境:SCOTT@book01p>@ver2==============================PORT_STRING                  :x86_64/Linux2.4.xxVERSION......
  • [20250109]19c使用or_expand提示遇到的问题2.txt
    [20250109]19c使用or_expand提示遇到的问题2.txt--//上午在21c下测试使用or_expand提示,生产系统遇到要复杂的多,测试复杂的例子是否可以使用。1.环境:SCOTT@book01p>@ver2==============================PORT_STRING                  :x86_64/Linux2.4.xxVE......
  • linux网桥(Linux Bridge)的一些个人记录
    目录1.LinuxBridge简述2.网桥创建创建配置持久化在Debian/Ubuntu系统上:在CentOS/RHEL系统上:启用和验证3.关于linux网桥不转发ip帧的问题原因解决配置持久化4.查看网桥学习交换表手动添加或删除条目添加条目删除条目配置静态条目设置条目的老化时间持久化配置5.关于linux网桥......