MongoDB cloneCollection between CentOS servers times out at 2 hours I'm trying to clone a MongoDB collection from CentOS server A to CentOS server B. Both are running 2.4.6. The copy works great until exaxctly 2 hours, at which point I get a 9001 socket exception: "errno:10054 An existing connection was forcibly closed by the remote host."

I have tried to set the tcp_keepalive_time to 3600, down from 7200 (2 hours) on both servers with the hope that my keep alive probes will tell routers to keep my connection alive after the 1 hour mark.

No dice. Even with a shorter keepalive time (and 70 second interval for keepalive probes), my connection dies at 2 hours.

Does anyone know how to set up my servers and/or my mongodb configuration to allow my tcp connection to be active past 2 hours?

Thanks!
The connection being killed after 2 hours, even when active (keepalive would only come into play for an idle connection, which is why it had not impact on your issue), suggests that this is a firewall or similar in the path between the two servers that is killing the connection.  You either need an exception to that rule from your network admin or you need to figure out a different way to copy the data, preferably one that can resume following an interruption.

The easiest alternative I can think of is to use mongodump to dump out the collection locally on the first MongoDB instance, SCP/FTP the files (with a client that supports resuming transfers) to the second machine, then use mongorestore to load the collection locally into the second MongoDB instance.