在使用Datagurd broker进行Datagurd主备切换时报ORA-12514监听异常, 详细信息如下:
DGMGRL> switchover to xiaohe;
Performing switchover NOW, please wait...
New primary database "xiaohe" is opening...
Operation requires shutdown of instance "xiaohedg" on database "xiaohedg"
Shutting down instance "xiaohedg"...
ORACLE instance shut down.
Operation requires startup of instance "xiaohedg" on database "xiaohedg"
Starting instance "xiaohedg"...
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Failed.
Warning: You are no longer connected to ORACLE.
Please complete the following steps to finish switchover:
start up instance "xiaohedg" of database "xiaohedg"
DGMGRL>
查看主备库的listener.ora配置信息:
$ cat listener.ora
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=xiaohe_dg1)(PORT=1521))))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=xiaohe_DGMGRL_xiaohe.com)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0)
(SID_NAME=xiaohe))
)
根据官方文档, 但使用DG Broker管理DG时, 需要在监听器配置GLOBAL_DBNAME:
GLOBAL_DBNAME =db_unique_name_DGMGRL.db_domain
我当前数据库的db_unique_name为xiaohe, db_domain为xiaohe.com, 因此根据官方文档要求, GLOBAL_DBNAME应该配置为:xiaohe_DGMGRL.xiaohe.com 。 但是上面的listener.ora不小心配置成了xiaohe_DGMGRL_xiaohe.com。
修改listener.ora配置并重启监听后, 使用broker进行DG主备切换正常。
SQL> show parameter db_unique_name; NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string xiaohe
SQL> show parameter db_domain;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_domain string xiaohe.com
修改监听配置后, Datagurd主备正常切换的日志如下:
DGMGRL> switchover to xiaohe;
Performing switchover NOW, please wait...
New primary database "xiaohe" is opening...
Operation requires shutdown of instance "xiaohedg" on database "xiaohedg"
Shutting down instance "xiaohedg"...
ORACLE instance shut down.
Operation requires startup of instance "xiaohedg" on database "xiaohedg"
Starting instance "xiaohedg"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "xiaohe"