时间:2021-07-01 10:21:17 帮助过:35人阅读
执行完sql的switchover后,Broker报如下错误。
DGMGRL> show configuration; Configuration - dr1 Protection Mode: MaxAvailability Databases: 11gdg2 - Primary database Error: ORA-16816: incorrect database role 11gdg1 - Physical standby database Error: ORA-16810: multiple errors or warnings detected for the database Fast-Start Failover: DISABLED Configuration Status: ERROR DGMGRL> show database verbose 11gdg2; Database - 11gdg2 Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): dgtst Database Error(s): ORA-16816: incorrect database role Properties: DGConnectIdentifier = ‘11gdg2‘ ObserverConnectIdentifier = ‘‘ LogXptMode = ‘SYNC‘ 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 = ‘‘ LogFileNameConvert = ‘‘ FastStartFailoverTarget = ‘‘ InconsistentProperties = ‘(monitor)‘ InconsistentLogXptProps = ‘(monitor)‘ SendQEntries = ‘(monitor)‘ LogXptStatus = ‘(monitor)‘ RecvQEntries = ‘(monitor)‘ SidName = ‘dgtst‘ StaticConnectIdentifier = ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=11gdg2.localdomain.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=11gdg2_DGMGRL)(INSTANCE_NAME=dgtst)(SERVER=DEDICATED)))‘ StandbyArchiveLocation = ‘USE_DB_RECOVERY_FILE_DEST‘ AlternateLocation = ‘‘ LogArchiveTrace = ‘0‘ LogArchiveFormat = ‘%t_%s_%r.dbf‘ TopWaitEvents = ‘(monitor)‘ Database Status: ERROR
Broker中Primary还是11gdg2呢~ 信息不一致啦。只能重新配置Broker啦。
DGMGRL> REMOVE CONFIGURATION PRESERVE DESTINATIONS; Removed configuration
...重新配置完毕,执行如下语句进行switchover。
DGMGRL> DGMGRL> 11gdg1-> dgmgrl DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production Copyright (c) 2000, 2009, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. DGMGRL> CONNECT sys/oracle@11gdg1 Password: Connected. DGMGRL> SWITCHOVER TO 11gdg2;
三、模拟故障,实现failover 。
注意几点:
failover 之后,原primary 数据库默认不再是data guard 配置的一部分。
多数情况下,其它逻辑/物理standby 数据库不直接参与failover 的过程,因此这些数据库不需要做任何操作。
某些情况下,新的primary 数据库配置之后,需要重新创建其它所有的standby 数据库。另外,如果待转换角色的standby 处于maximum protection 或maximum availability 模式的话,归档日志应该是连续存在的
3.1 将主库关闭,假设主库崩溃啦。
SQL> conn / as sysdba Connected. SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down.
3.2 检查从库是否存在日志gap
查询待转换standby 数据库的V$ARCHIVE_GAP 视图,确认归档文件是否连接:
SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
如果返回的有记录,按照列出的记录号复制对应的归档文件到待转换的standby 服务器。这一步非常重
要,必须确保所有已生成的归档文件均已存在于standby 服务器,不然可能会数据不一致造成转换时报错。
文件复制之后,通过下列命令将其加入数据字典:
SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE ‘filespec1‘;
3.3 将从库切换成主库
SQL> select switchover_status from v$database; SWITCHOVER_STATUS ------------------------------------------------------------ NOT ALLOWED
switchover是不允许的,我们要怎么办呢?
首先,取消日志应用
SQL> alter database recover managed standby database cancel; Database altered.
再次,发出一个命令,模拟主库已经进行了数据库切换。在日志中打上EOR
SQL> alter database recover managed standby database finish; Database altered.
如果日志有gap,上面的命令将会失败,则需要执行ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
一旦finish操作完成,无论数据库原先的保护模式是什么,全部都会将为最大性能。为了保证新的主库一定能打开。
切换成主库,并打开数据库。
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN; Database altered. SQL> ALTER DATABASE OPEN; Database altered.
3.3 测试插入数据
SQL> conn scott/tiger Connected. SQL> select count(*) from t1; COUNT(*) ---------- 28 SQL> insert into t1 select * from t1; 28 rows created. SQL> commit; Commit complete.
本文出自 “叮咚” 博客,请务必保留此出处http://lqding.blog.51cto.com/9123978/1682064
Oracle学习之DATAGUARD(八) Switchover与failover
标签:switchover failover