使用自动故障转移时的 PHP MongoDB 错误 [英] PHP MongoDB errors when using automatic failover

查看:38
本文介绍了使用自动故障转移时的 PHP MongoDB 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最难解决这个问题.我有一个 2 个服务器副本集,其中一个仲裁器与当前主服务器一起运行.

I'm having the hardest time trying to figure this one out. I have a 2 server replica set with one arbiter running alongside the current primary.

当我连接或发出查询时,我会收到间歇性错误,其中包括以下任何一种:

When I connect or issue queries, I get intermittent errors which range from any one of the following:

  • 无法确定主人.
  • 无法连接到 [将主机放在这里].
  • 断管异常.
  • MongoCursorExceptions.

似乎服务器启动的时间越长,它们发生的频率就越高.一段时间后,无法建立连接,当我尝试登录 mongo shell 时出现以下错误:

It seems like they happen more often the longer the servers are up. After awhile, no connections can be made and I get the following error when I try and login to the mongo shell:

MongoDB shell version: 1.8.1
connecting to: test
Wed May 11 16:36:50 MessagingPort recv() errno:104 Connection reset by peer 127.0.0.1:27017
Wed May 11 16:36:50 SocketException: remote:  error: 9001 socket exception [1] 
Wed May 11 16:36:50 DBClientCursor::init call() failed
exception: DBClientBase::findOne: transport error: 127.0.0.1 query: { whatsmyuri: 1 }

(顺便说一句,使用详细(-vvvv)日志记录,9001 套接字异常似乎出现在每个运行的查询中.)

(BTW, with verbose (-vvvv) logging, the 9001 socket exception seems to come up with every query that is run.)

当我重新启动 mongo 服务器时,事情会恢复并开始工作,但不会持续很长时间.

When I restart the mongo servers, things come back up and start working, but not for long.

无论我使用何种连接选项组合,都没有任何效果.当我更改两个网络服务器以连接到主副本时,一切都开始工作了.没有错误.没有自动故障转移:(.奇怪的是,replicaSet 选项仍然被设置,这意味着 PHP 驱动程序仍然需要确定它连接的那个是否是一个主节点,如果没有连接到它,如果是这样,什么都不做.

No matter what combination of connection options I used, nothing worked. When I changed both webservers to connect to the primary replica everything started working. No errors. No automatic failover :(. Weird thing was, that the replicaSet option was still set which means the PHP driver still needs to determine whether or not the one it connected to was a master and if not connect to it, if so, do nothing.

这告诉我问题出在 PHP 驱动程序中,它在尝试确定是否连接到主服务器后尝试连接到主服务器.只是为了尝试支持我的理论,我告诉其中一台服务器连接到辅助服务器.立即,我开始从该服务器收到错误消息.不是仍然连接到主服务器的其他服务器.切换回来,没有错误.

This tells me that the issue resides in the PHP driver where it tries to connect to the master after attempting to determine if it is connected to the master or not. Just to try and back up my theory, I told one of the servers to connect to the secondary server. Immediately, I started getting errors from that server. Not the other server which was still connected to the primary. Switch back, no errors.

任何人都可以对此有所了解吗?

Can anyone shed any light on this?

我的设置:- 2 个网络服务器- Apache/PHP 都支持- MongoDB 副本集跨越两者- 次要一对一- 初级和仲裁者- MongoDB 1.8.1- PHP 驱动程序 1.1.4- PHP 5.3.3- 阿帕奇 2.2.17- RedHat 5.5 (Tikanga)

My setup: - 2 webservers - Apache/PHP on both - MongoDB Replica-Set span across both - Secondary on one - Primary and Arbiter on the other - MongoDB 1.8.1 - PHP Driver 1.1.4 - PHP 5.3.3 - Apache 2.2.17 - RedHat 5.5 (Tikanga)

推荐答案

这是 活动线程.

最好关闭它并让讨论在那里结束.

May be best to close it and let discussion finish out there.

这篇关于使用自动故障转移时的 PHP MongoDB 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆