boq*_*apt 6 sockets mongodb database-replication replicaset
当Mongo数据库(版本3.0.5)从主数据库服务器复制到从服务器时,我得到套接字错误110(连接超时),更准确地说,在提交该数据库的复制时(从服务器的日志在下面).我想可能原因就是数据库很大并且发送操作提交需要花费太多时间.
如何为mongo服务器指定不同的套接字超时?如果不可能,有没有其他方法来修复复制?
我发现这样的选项只适用于mongo客户端(连接字符串选项socketTimeoutMS),但它对Mongo服务器没有帮助.
2016-04-26T13:36:34.693+0100 I INDEX [rsSync] done building bottom layer, going to commit
2016-04-26T13:36:34.693+0100 I INDEX [rsSync] build index done. scanned 30980334 total records. 4072 secs
2016-04-26T13:36:34.772+0100 I REPL [rsSync] initial sync cloning db: {skipped db name}
2016-04-26T13:36:34.823+0100 I NETWORK [rsSync] Socket say send() errno:110 Connection timed out {skipped ip}:27017
2016-04-26T13:36:34.828+0100 E REPL [rsSync] 9001 socket exception [SEND_ERROR] server [{skipped ip}:27017]
2016-04-26T13:36:34.828+0100 E REPL [rsSync] initial sync attempt failed, 9 attempts remaining
Run Code Online (Sandbox Code Playgroud)
更新.我在评论中被要求输出rs.status():
{ "set" : "<skippedsetname>",
"date" : ISODate("2016-05-04T15:35:06.717Z"),
"myState" : 5,
"syncingTo" : "<skipped domain name of other server>:27017",
"members" : [
{
"_id" : 0,
"name" : "<skipped domain name of this server>:27017",
"health" : 1,
"state" : 5,
"stateStr" : "STARTUP2",
"uptime" : 29,
"optime" : Timestamp(0, 0),
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"syncingTo" : "<skipped domain name of other server>:27017",
"configVersion" : 9,
"self" : true
},
{
"_id" : 2,
"name" : "10.0.1.7:27017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 26,
"lastHeartbeat" : ISODate("2016-05-04T15:35:05.859Z"),
"lastHeartbeatRecv" : ISODate("2016-05-04T15:35:06.347Z"),
"pingMs" : 3,
"configVersion" : 9
},
{
"_id" : 3,
"name" : "<skipped domain name of other server>:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 26,
"optime" : Timestamp(1462376105, 196),
"optimeDate" : ISODate("2016-05-04T15:35:05Z"),
"lastHeartbeat" : ISODate("2016-05-04T15:35:05.859Z"),
"lastHeartbeatRecv" : ISODate("2016-05-04T15:35:06.086Z"),
"pingMs" : 4,
"electionTime" : Timestamp(1461688501, 1),
"electionDate" : ISODate("2016-04-26T16:35:01Z"),
"configVersion" : 9
}
],
"ok" : 1 }
Run Code Online (Sandbox Code Playgroud)
更新.我应该但没有提到使用的主机是Azure.通过查询"azure mongodb connection timeout"完全用Google搜索答案和解释.我的错.
您对错误原因的假设是错误的。
Connection timed out:在尝试建立 TCP 连接期间,在给定的时间内没有收到对方的响应。换句话说,这是套接字建立的问题,而不是数据库复制需要多长时间的问题。
调整 TCP 超时是一项系统设置,而不是您为每个应用程序执行的操作。在 Linux 上,这些设置位于系统范围的 /etc/sysctl.conf 中,您可以使用 --但是您几乎从不更改建立套接字的超时(对于任何程序,包括 mongo),并且少数情况我多次更改它是为了缩短它以更快地获得错误,而不是增加它 - 增加它不太可能是任何地球应用程序中的正确解决方案。net.ipv4.tcp_syn_retries
问题要么是配置问题,例如您的设置中有一些错误的 IP 地址,要么是网络问题,例如错误的防火墙、路由表或网络交换机,有时一次无法工作 60-120 秒。
| 归档时间: |
|
| 查看次数: |
1908 次 |
| 最近记录: |