1. Create replica set of 3 servers.
2. Add data to it.
3. Create 3 config servers for sharding.
4. Create one router (mongos)
5. Add replica set as solo shard
6. enable sharding on the db and collection that you already added data to
7. Repeatedly insert a record into sharded collection and check insert has gone to 2 replicas (getLastError(2))
There is a jstest for this test case at: jstests/grid/shard_insert_getlasterror_w2.
Problem: About every 170th insert fails (getLastError times out) on my Macbook
result of timed-out getLastErrorObj(2,30000) looks like:
{
"shards" : [
"127.0.0.1:31003,127.0.0.1:31004,127.0.0.1:31005",
"repset1/127.0.0.1:31000,127.0.0.1:31001,127.0.0.1:31002"
],
"n" : 0,
"err" : "",
"errs" : [
""
],
"errObjects" : [
],
"ok" : 1
}
Result of a successful getLastErrorObj(2,30000) looks like:
{
"theshard" : "repset1/127.0.0.1:31000,127.0.0.1:31001,127.0.0.1:31002",
"err" : null,
"n" : 0,
"lastOp" : NumberLong("5516791406158413840"),
"wtime" : 2,
"ok" : 1,
"singleShard" : "repset1/127.0.0.1:31000,127.0.0.1:31001,127.0.0.1:31002"
}