现有dgbroker管理的dg下添加一台从库且互相切换
环境:
OS:Centos 7
DB:11.2.0.4
说明:
当前环境一主一从,主从都采用dbbroker管理,现在新添加一台从库,组成1主2从的架构
当前架构:
slnngk->slava
重新部署后:
slnngk->slava
slnngk->slavb
1.主库添加到归档到新从库的参数
alter system set log_archive_config='dg_config=(slnngk,slavea,slaveb)' scope=both; ##填写主备库的db_unique_name
alter system set log_archive_dest_3= 'service=tnsslaveb async valid_for=(online_logfiles,primary_role) db_unique_name=slaveb' scope=both; ##这里service填写配置的备库2的tns,db_unique_name填写备库2的db_unique_name.
alter system set log_archive_dest_state_3=enable scope=both; ##启用归档路径2
2.新从库采用网络复制的方式进行初始化
步骤省略
3.创建spfile启动
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0.4/db_1/dbs/initslaveb.ora';
SQL> startup mount
ORACLE instance started.
Total System Global Area 3140026368 bytes
Fixed Size 2257352 bytes
Variable Size 704646712 bytes
Database Buffers 2415919104 bytes
Redo Buffers 17203200 bytes
Database mounted.
3.新从库切换到应用日志模式
alter database recover managed standby database using current logfile disconnect from session;
4.新从库修改dgbroker参数
alter system set dg_broker_config_file1='/u01/app/oracle/product/11.2.0.4/db_1/dbs/dr1slaveb.dat';
alter system set dg_broker_config_file2='/u01/app/oracle/product/11.2.0.4/db_1/dbs/dr2slaveb.dat';
alter system set dg_broker_start=true scope=both;
5.主库上操作添加新从库
[oracle@dbmaster ~]$ dgmgrl
DGMGRL> connect sys/oracle
Connected.
DGMGRL> add database 'slaveb' as connect identifier is 'tnsslaveb';
DGMGRL> enable database 'slaveb';
6.新从库添加静态监听
vi /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = slaveb)
(ORACLE_HOME =/u01/app/oracle/product/11.2.0.4/db_1)
(SID_NAME =slaveb)
)
(SID_DESC =
(GLOBAL_DBNAME = slaveb_DGMGRL)
(ORACLE_HOME =/u01/app/oracle/product/11.2.0.4/db_1)
(SID_NAME =slaveb)
)
)
然后重启监听
[oracle@dbslave02 admin]$ lsnrctl stop
[oracle@dbslave02 admin]$ lsnrctl start
7.主库上查看配置
DGMGRL> show configuration;
Configuration - slnngktest
Protection Mode: MaxPerformance
Databases:
slnngk - Primary database
slavea - Physical standby database
slaveb - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
8.主库上查看新添加的备库信息
DGMGRL> show database verbose slaveb;
Database - slaveb
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 1 second ago)
Apply Rate: 0 Byte/s
Real Time Query: OFF
Instance(s):
slaveb
Properties:
DGConnectIdentifier = 'tnsslaveb'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '4'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'slnngk, slaveb'
LogFileNameConvert = 'slnngk, slaveb'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
ApplyLagThreshold = '0'
TransportLagThreshold = '0'
TransportDisconnectedThreshold = '30'
SidName = 'slaveb'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbslave02)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slaveb_DGMGRL)(INSTANCE_NAME=slaveb)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/u01/app/oracle/archive_log/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
9.修改host为ip地址
DGMGRL> edit database slaveb set property StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.182)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slaveb_DGMGRL)(INSTANCE_NAME=slaveb)(SERVER=DEDICATED)))';
Property "staticconnectidentifier" updated
10.新备库打开数据库
SQL> alter database open;
Database altered.
11.切换测试
主库切换为slavea
DGMGRL> switchover to slavea
Performing switchover NOW, please wait...
Operation requires a connection to instance "slavea" on database "slavea"
Connecting to instance "slavea"...
Connected.
New primary database "slavea" is opening...
Operation requires startup of instance "slnngk" on database "slnngk"
Starting instance "slnngk"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "slavea"
DGMGRL> show configuration;
Configuration - slnngktest
Protection Mode: MaxPerformance
Databases:
slavea - Primary database
slnngk - Physical standby database
slaveb - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
主库切换为slaveb
DGMGRL> switchover to slaveb
Performing switchover NOW, please wait...
Operation requires a connection to instance "slaveb" on database "slaveb"
Connecting to instance "slaveb"...
Connected.
New primary database "slaveb" is opening...
Operation requires startup of instance "slavea" on database "slavea"
Starting instance "slavea"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "slaveb"
DGMGRL> show configuration;
Configuration - slnngktest
Protection Mode: MaxPerformance
Databases:
slaveb - Primary database
slnngk - Physical standby database
slavea - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
主库切换为slnngk
DGMGRL> swtichover to slnngk
Unrecognized command "swtichover", try "help"
DGMGRL> switchover to slnngk
Performing switchover NOW, please wait...
Operation requires a connection to instance "slnngk" on database "slnngk"
Connecting to instance "slnngk"...
Connected.
New primary database "slnngk" is opening...
Operation requires startup of instance "slaveb" on database "slaveb"
Starting instance "slaveb"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "slnngk"
DGMGRL> show configuration;
Configuration - slnngktest
Protection Mode: MaxPerformance
Databases:
slnngk - Primary database
slavea - Physical standby database
slaveb - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
发现主备之间切换,数据库会自动的修改standby归档的路径和fal相关参数,切换后原来的2个备份都会自动指向新的主库.
log_archive_dest_2
log_archive_dest_3
fal_server
fal_client
log_archive_config
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?