MongoDB mongodb 连接中断如何自动重连?

suupic · November 28, 2011 · Last by aNdReW_Qx replied at February 04, 2012 · 6081 hits

如题 因为今天盛大云的主机抽风,有大约 1 分钟时间断网,然后发现 mongo 连接不上 重启 unicorn 后才恢复 太不自动化了 有好的解决方法吗

你是用 mongoid 么? mongoid.yml 中设置 max_retries_on_connection_failure = X (X>0) 即可 设定重连次数,默认是半秒重连一次 具体看文档 http://mongoid.org/docs/installation/configuration.html

You need to Sign in before reply, if you don't have an account, please Sign up first.