11.2.0.4的 data guard,配制了broker,从主库切换到备库的时候,正常。再从备库切换到主库的时候。出现问题。
DGMGRL> switchover to testogg;
Performing switchover NOW, please wait...
Operation requires a connection to instance "testogg" on database "testogg"
Connecting to instance "testogg"...
Connected.
New primary database "testogg" is opening...
Operation requires startup of instance "testogg_stdby" on database "testogg_stdby"
Starting instance "testogg_stdby"...
Unable to connect to database
ORA-12545: Connect failed because target host or object does not exist
Failed.
Warning: You are no longer connected to ORACLE.
Please complete the following steps to finish switchover:
start up instance "testogg_stdby" of database "testogg_stdby"
DGMGRL>
查看alert log日志,提示log_archive_dest_2 是invalid的 。并且提示db_unique_name不对。
Switchover: Primary highest seen SCN set to 0x0.0x1a410d
ARCH: Noswitch archival of thread 1, sequence 113
ARCH: End-Of-Redo Branch archival of thread 1 sequence 113
ARCH: LGWR is actively archiving destination LOG_ARCHIVE_DEST_3
ARCH: Standby redo logfile selected for thread 1 sequence 113 for destination LOG_ARCHIVE_DEST_3
Archived Log entry 32 added for thread 1 sequence 113 ID 0xe0779467 dest 1:
ARCH: Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received alls redo
Final check for a synchronized target standby. Check will be made once.
Archive destination LOG_ARCHIVE_DEST_2 invalidated
DB_UNIQUE_NAME tesgogg is not in the Data Guard configuration
LOG_ARCHIVE_DEST_3 is a potential Physical Standby switchover target
Active, synchronized target has been identified
Target has also received all redo
检查log_archive_dest_2的设置,发现db_unique_name的确有问题,更改,提示和log_archive_dest_3因为值相同有冲突。
SYS@testogg_stdby>alter system set log_archive_dest_2= 'SERVICE=tesgogg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testogg';
alter system set log_archive_dest_2= 'SERVICE=tesgogg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testogg'
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-16021: session LOG_ARCHIVE_DEST_3 destination cannot be the same as session
LOG_ARCHIVE_DEST_2 destination
查看log_archive_dest_3,发现的确配置了log_archive_dest_3。但是搭建data guard的时候,并没有设置这个参数。该参数是配置broker后,broker自己生成的。清空后,设置log_archive_dest_2.
SYS@testogg_stdby>show parameter log_archive_dest_3
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_3 string service="testogg", LGWR ASYNC
NOAFFIRM delay=0 optional comp
ression=disable max_failure=0
max_connections=1 reopen=300 d
b_unique_name="testogg" net_ti
meout=30, valid_for=(all_logfi
les,primary_role)
log_archive_dest_30 string
log_archive_dest_31 string
SYS@testogg_stdby>alter system set log_archive_dest_3='';
System altered.
SYS@testogg_stdby>alter system set log_archive_dest_2= 'SERVICE=tesgogg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testogg';
System altered.
设置完毕后,还是存在无法切换data guard的问题。检查broker的配置。发现数据库的配置中,连接的host是hostname,而不是IP地址。
DGMGRL> show database verbose testogg_stdby;
Database - testogg_stdby
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: (unknown)
Apply Lag: (unknown)
Apply Rate: (unknown)
Real Time Query: OFF
Instance(s):
testogg_stdby
Properties:
DGConnectIdentifier = 'testogg_stdby'
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 = '/u01/app/oracle/oradata/testogg/, /u01/app/oracle/oradata/testogg_stdby/'
LogFileNameConvert = '/u01/app/oracle/oradata/testogg/, /u01/app/oracle/oradata/testogg_stdby/'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
ApplyLagThreshold = '0'
TransportLagThreshold = '0'
TransportDisconnectedThreshold = '30'
SidName = 'testogg_stdby'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbtrain)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=testogg_stdby_DGMGRL)(INSTANCE_NAME=testogg_stdby)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/archive_log/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
TopWaitEvents = '(monitor)'
Database Status:
DGM-17016: failed to retrieve status for database "testogg_stdby"
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
ORA-16625: cannot reach database "testogg_stdby"
DGMGRL>
检查主备库的hosts文件,发现里面没有对方的地址。添加。再次在dgmgrl命令行下执行切换。主备切换正常。
DGMGRL> switchover to testogg
Performing switchover NOW, please wait...
Operation requires a connection to instance "testogg" on database "testogg"
Connecting to instance "testogg"...
Connected.
New primary database "testogg" is opening...
Operation requires startup of instance "testogg_stdby" on database "testogg_stdby"
Starting instance "testogg_stdby"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "testogg"
END