Situation
I have 3 nodes on a Replica Set (P+S+S). Mongodb version 2.6.9. I would like to migrate all the nodes to 3.0.4 wiredtiger.
When I need to do that without downtime, I do the following workflow:
- setup a new server with 3.0.4
- add the node to the replica set
- remove one of the old nodes
- go to step 1
Problem is that with my set of data, adding a node with the "rs.addnode" tactic just doesn't work. The process takes forever and starts the initial syncronization again and again. To walkaround this, I normally do a cold backup from one of the old nodes to the new one. That takes the data and the local database, the node joins the replica set without initial syncronization.
Problem is that I cannot do that because the file system is not the same. If I can put one with wiredtiger, I can do the cold backup trick with the other ones.
Attempts I made with no luck:
- reduce size of my database
- reduce the Oplog size
- try with a dump backup / restore
- rs.add
I know there is a way to add a node with a setting --fastsync. But to do that, I need to have a copy from the primary, and the files are not the same. Not sure if that will do the trick with dump backup / restore. I would know if when the node takes the new member as a valid secondary, I can restart the node without the fastsync or I should put that setting forever.
This is my mongod.log when it fails with the initial sync:
I INDEX [rsSync] building index using bulk method
I INDEX [rsSync] build index done. scanned 3 total records. 0 secs
I REPL [rsSync] initial sync cloning db: config
I REPL [rsSync] initial sync data copy, starting syncup
I REPL [rsSync] oplog sync 1 of 3
I NETWORK [rsSync] Socket recv() timeout x.x.x.x:x
I NETWORK [rsSync] SocketException: remote: x.x.x.x:x error: 9001 socket exception [RECV_TIMEOUT] server [x.x.x.x:x]
I NETWORK [rsSync] DBClientCursor::init call() failed
E REPL [rsSync] 10276 DBClientBase::findN: transport error: x:x ns: local.oplog.rs query: { query: {}, orderby: { $natural: -1 } }
E REPL [rsSync] initial sync attempt failed, 9 attempts remaining
SOLUTION (see comments)
configure ulimits:
sudo nano /etc/security/limits.conf
# add at the bottom
mongod soft nproc 64000
mongod hard nproc 64000
mongod soft nofile 64000
mongod hard nofile 64000
mongod soft fsize unlimited
mongod hard fsize unlimited
mongod soft cpu unlimited
mongod hard cpu unlimited
mongod soft as unlimited
mongod hard as unlimited
configure keep alive
sudo nano /etc/sysctl.conf
# add at the bottom
net.ipv4.tcp_keepalive_time = 120
Note: I did that on the new member and on the existing ones
tcp_keep_alive
timing to 120 seconds and increased yourulimits
from the default before doing the initial sync.tcp_keepalive_time
has definitely fixed the problem for other users with the same issue. I don't think you have a choice of not going through the Azure balancer or some other network gear that has the keepalive issue, so it's definitely worth a try. Note: In case you didn't check my profile .. I work for MongoDB ;-).