有一个库自从上线之后,主库的alertlog中一直有如下报错:
Tue Dec 20 14:42:16 2016 Error 12154 received logging on to the standby PING[ARC2]: Heartbeat failed to connect to standby 'rmydb'. Error is 12154.
1. 检查远端的standby库已经启动,且已经到了mount以上的状态(即在read only的模式下Real Time Apply)。
2. 检查主库到远端的tnsping,正常。
3. 检查主库sqlplus user/pwd@tns 也是正常连接。
4. defer log_archive_dest_state_2后再enable,让archive进程意识到tnsnames.ora的变动。(怕之前修改过,archive进程没有意识到。),还是没用。依旧报错。
5. 再检查了一下,发现TNS_ADMIN的环境变量没有设置。所以用于心跳检测的archive进程,会找不到tns的配置文件。
临时解决办法:
不使用tnsnames.ora的配置文件,直接在log_archive_dest_2中设置: alter system set log_archive_dest_2='SERVICE="(description=(address_list=(address=(protocol=TCP)(host=rhost)(port=1534)))(connect_data=(sid=mydb)))" LGWR ASYNC NOAFFIRM reopen=60 valid_for=(online_logfile,primary_role) db_unique_name=rmydb'; alter system set log_archive_dest_state_2=defer; alter system set log_archive_dest_state_2=enable;
修改环境变量,添加TNS_ADMIN,待下次重启数据库生效。
参考:
Error 12154 received logging on to the standby whenever primary instance startup with srvctl (Doc ID 1943178.1)
RFS Is not coming up on standby Due to ORA-12154 on transport (primary side) (Doc ID 2196182.1)
Troubleshooting – Heartbeat failed to connect to standby (Doc ID 1432367.1)