J'essaie d'expérimenter avec sharding et de faire une configuration d'échantillon: le plus simple pour deux fragments. Voici le code à partir des fichiers de chauve-souris:Sharding dans MongoDB en utilisant le pilote C#
cd c:\mongodb-win32-x86_64-1.8.3-rc1\bin
call mongod --shardsvr --dbpath /data/db/Shard--port 10000
cd c:\mongodb-win32-x86_64-1.8.3-rc1\bin
call mongod --shardsvr --dbpath /data/db/Shard2 --port 10001
cd c:\mongodb-win32-x86_64-1.8.3-rc1\bin
mongod --configsvr --dbpath /data/db/config --port 20000
cd c:\mongodb-win32-x86_64-1.8.3-rc1\bin
mongos --configdb 192.168.0.23:20000
cd c:\mongodb-win32-x86_64-1.8.3-rc1\bin
mongo
use admin
db.runCommand({ addshard : "192.168.0.23:10000" })
db.runCommand({ addshard : "192.168.0.23:10001" })
db.runCommand({ enablesharding : "Shard" })
db.runCommand({ shardcollection : "Shard.Customers", key :
{LocalIdentifier : 1} })
Lorsque je tente d'exécuter un simple code d'insertion à ce DB, il exécute mais les deux tessons sont vides. Voici le code d'insertion:
public void SaveBatch(IEnumerable<object> entities)
{
MongoCollection.InsertBatch(typeof(object), entities, SafeMode.True);
}
Aussi c'est le code d'exécuter la connexion:
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
mongoServer = mongoServer.Create(connectionString);
mongoDatabase = mongoServer.GetDatabase("Shard");
mongoCollection = mongoDatabase.GetCollection<Customer>("Customers");
mongoCollection.EnsureIndex(
IndexKeys.Ascending(new[] {"CampaignId", "LocalIdentifier", "ProjectIdentifier", "FirstName", "LastName"}));
Je n'a pas réussi à faire les tessons de travail. Pouvez-vous me dire ce que je suis mal à: configuration, connexion ou insertion? Et quelle est la bonne façon de le faire?
L'affaire est close, il y avait une erreur dans le code appelant –