During an initial sharding of collection the error shown below can occur. During the insert of the initial chunk documents to config.chunks the asynchronously-running data consistency checking thread can observe an inconsistent view of the config db, and throws the "Data inconsistency detected amongst config servers" error up.
mongos> sh.shardCollection("test.foo", key: { "x": 1 }) { "ok" : 0, "errmsg" : "Creating first chunks failed: Data inconsistency detected amongst config servers", "code" : 132 }
This stops the shardCollection command at the point of having inserted some fraction of chunk documents into config.chunks, but no document into config.collections. So if the same command is attempted again then the following error appears:
{ "ok" : 0, "errmsg" : "collection test.foo already sharded with 834 chunks.", "code" : 23 }
The likelihood of having this timing collision with the consistency checking action seems to be very low if you only have a few chunks to insert. I could only reproduce when I had > 1,000 chunks, which in the environment I was using caused the shardCollection command to run for > 30 secs.
Changing the config servers to a replica set (per these instructions) was the only way I could consistently avoid this error while sharding the large collections in my test.