对MongoDB的Gridfs.Chunks分片:
> use admin
> db.runCommand({addshard:"localhost:27020",allowLocal:true})
> db.runCommand({addshard:"localhost:27021",allowLocal:true})
> db.runCommand({shardcollection:"mydb.fs.chunks",key:{ files_id:1}})
UploadFileTest : Failed
Test method MongoTests.TestDataTest.UploadFileTest threw exception:
MongoDB.Driver.MongoQueryException: QueryFailure flag was unrecognized command: $readPreference (response was { "$err" : "unrecognized command: $readPreference", "code" : 13390 }).
at
MongoDB.Driver.Internal.MongoReplyMessage`1.
ReadFrom(
BsonBuffer buffer,
IBsonSerializationOptions serializationOptions) in
C:\work\rstam\mongo-csharp-driver\Driver\Internal\MongoReplyMessage.cs: line 99 at
MongoDB.Driver.Internal.MongoConnection.
ReceiveMessage(
BsonBinaryReaderSettings readerSettings,
IBsonSerializationOptions serializationOptions) in
C:\work\rstam\mongo-csharp-driver\Driver\Internal\MongoConnection.cs: line 475 at
MongoDB.Driver.MongoCursorEnumerator`1.
GetReply(
MongoConnection connection,
MongoRequestMessage message) in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs: line 296 at
MongoDB.Driver.MongoCursorEnumerator`1.
GetFirst() in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs: line 251 at
MongoDB.Driver.MongoCursorEnumerator`1.
MoveNext() in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs: line 141 at
System.Linq.Enumerable.
FirstOrDefault(
IEnumerable`1 source)
at
MongoDB.Driver.MongoCollection.
FindOneAs(
IMongoQuery query) in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCollection.cs: line 557at
MongoDB.Driver.MongoCollection`1.
FindOne(
IMongoQuery query) in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCollection.cs: line 1734at
MongoDB.Driver.MongoDatabase.
RunCommandAs(
Type commandResultType,
IMongoCommand command) in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoDatabase.cs: line 973 at
MongoDB.Driver.MongoDatabase.
RunCommandAs(
IMongoCommand command) in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoDatabase.cs: line 950 at
MongoDB.Driver.MongoDatabase.
RunCommand(
IMongoCommand command) in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoDatabase.cs: line 928 at
MongoDB.Driver.MongoCollection.
Count(
IMongoQuery query) in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCollection.cs: line 158at
MongoDB.Driver.MongoCollection.
Count() in
C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCollection.cs: line 143 at
MongoDB.Driver.GridFS.MongoGridFS.
EnsureIndexes(
Int32 maxFiles) in
C:\work\rstam\mongo-csharp-driver\Driver\GridFS\MongoGridFS.cs: line 437at
MongoDB.Driver.GridFS.MongoGridFS.
Upload(
Stream stream,
String remoteFileName,
MongoGridFSCreateOptions createOptions) in
C:\work\rstam\mongo-csharp-driver\Driver\GridFS\MongoGridFS.cs: line 761 at
MongoDB.Driver.GridFS.MongoGridFS.
Upload(
Stream stream,
String remoteFileName) in
C:\work\rstam\mongo-csharp-driver\Driver\GridFS\MongoGridFS.cs: line 744 at
MongoDB.Driver.GridFS.MongoGridFS.
Upload(
String localFileName,
String remoteFileName) in
C:\work\rstam\mongo-csharp-driver\Driver\GridFS\MongoGridFS.cs: line 880 at
MongoTests.TestDataTest.
UploadFileTest() in
TestDataTest.cs: line 171