Re: Inserting in "mongos"

40 views
Skip to first unread message

Andre de Frere

unread,
Oct 14, 2012, 11:23:48 PM10/14/12
to mongod...@googlegroups.com
Hi Daniel,

You've commented in another post that your sharding status looks similar to the following:

mongos> db.printShardingStatus()
--- Sharding Status --- 
  sharding version: { "_id" : 1, "version" : 3 }
  shards:
        {  "_id" : "shard0000",  "host" : "127.0.0.1:27018" }
        {  "_id" : "shard0001",  "host" : "127.0.0.1:27019" }
        {  "_id" : "shard0002",  "host" : "127.0.0.1:27020" }
  databases:
        {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
        {  "_id" : "test",  "partitioned" : false,  "primary" : "shard0000" }
        {  "_id" : "mydb",  "partitioned" : true,  "primary" : "shard0000" }
                mydb.products chunks:
                                shard0000       1
                        { "nr" : { $minKey : 1 } } -->> { "nr" : { $maxKey : 1 } } on : shard0000 { "t" : 1000, "i" : 0 }

Is this correct?  If so, what you appear to be doing is trying to create 3 shards, each shard containing a config server.  Your shards should not have a config server in them.  

The config server is a special implementation of "mongod" that does not store any actual data, rather it stores only metadata.  These servers use a two phase commit to keep in sync between each other, and because of this you can have either 1 or 3 of them (we recommend 3 in production).  In addition to these config servers you will also need a number of "mongod" processes that actually store the data which are distinct processes to the config server processes and are not started with "--configsvr".

The quick summary of a running instance will be:

1 - 3 "--configsvr" processes
1 or more "mongod" without --configsvr (I think you are missing these)
1 or more "mongos"

Each of the "mongos" will point to the list of 1 or 3 "mongod --configsvr" proceses.  You will need to "sh.addShard()" for the "mongod without --configsvr" processes.  If you have a replica set, you will need to include the whole replica set configuration string when you issue "sh.addShard()".

Hope this helps,
André

Daniel Mantovani

unread,
Oct 15, 2012, 5:21:51 AM10/15/12
to mongod...@googlegroups.com
Hi,

Thank you very much!

[]'s!

--
"A Jedi uses the Force for knowledge and defense, never for attack." - Yoda

Software Engineer
Just Another Perl Hacker
Daniel Mantovani +5511 8538-9897
XOXO
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb

despot

unread,
Jul 28, 2013, 9:03:09 AM7/28/13
to mongod...@googlegroups.com
Daniel Mantovani <daniel.oliveira.mantovani@...> writes:

>
> Hi,
>
> Thank you very much!
>
> []'s!
>


Hi, this "1 or more "mongod" without --configsvr (I think you are missing
these)" wasn't much clear to me. Apparently you need 1 or more mongod
without the --configsvr on different ports and folders(shards) + a mongos
command on all of the --configsvr mongod(s) and sh.addShard on the mongod(s)
without --configsvr.

These are the exact steps to solve it:
already created folders (deleted everything in them):
C:\mongodb\data\configdb\shard1
C:\mongodb\data\configdb\shard2
C:\mongodb\data\configdb\shard3
C:\mongodb\data\configdb\shard4
C:\mongodb\data\configdb\shard5
C:\mongodb\data\configdb\shard6
The following commands are executed from cmd and path is set to (cd
C:\mongodb\bin):
mongod --configsvr --dbpath C:\mongodb\data\configdb\shard1 --port 27019
mongod --configsvr --dbpath C:\mongodb\data\configdb\shard2 --port 27020
mongod --configsvr --dbpath C:\mongodb\data\configdb\shard3 --port 27021
mongod --dbpath C:\mongodb\data\configdb\shard4 --port 27022
mongod --dbpath C:\mongodb\data\configdb\shard5 --port 27023
mongod --dbpath C:\mongodb\data\configdb\shard6 --port 27024
mongos --configdb localhost:27019,localhost:27020,localhost:27021
db mydb
sh.addShard("localhost:27022")
sh.addShard("localhost:27023")
sh.addShard("localhost:27024")

Cheers,
despot

Reply all
Reply to author
Forward
0 new messages