MongoDB 3.4 Sharded Cluster

367 views
Skip to first unread message

Alan

unread,
Aug 9, 2017, 6:19:45 PM8/9/17
to mongodb-user
Can someone show me simple step by step instructions of how to setup a MongoDB sharded cluster in Mongo 3.4.  From what I understand, Mongo 3.4 has a different way of setting it up compared to previous versions.  So far I tried the following but it doesn't seem to work.


mongod --configsvr --dbpath cfg0 --port 26050 --fork --logpath log.cfg0 --logappend
mongod --configsvr --dbpath cfg1 --port 26051 --fork --logpath log.cfg1 --logappend

mongod --shardsvr --replSet a --dbpath a0 --logpath log.a0 --port 27000 --fork --logappend --smallfiles --oplogSize 50
mongod --shardsvr --replSet a --dbpath a1 --logpath log.a1 --port 27001 --fork --logappend --smallfiles --oplogSize 50

mongos --configdb m034:26050,m034:26051,m034:26052 --fork --logapend --logpath log.mongos0

FailedToParse: mirrored config server connections are not supported; for config server replica sets be sure to use the replica set connection string
try 'mongos --help' for more information

Jacek Radzikowski

unread,
Aug 9, 2017, 6:39:58 PM8/9/17
to mongodb-user

You have to set up config server as a replica set:
mongod --configsvr --dbpath cfg0 --port 26050 --fork --logpath log.cfg0 --logappend --replSet "rs0"
Other nodes in the config server RS also need to be called with replSet parameter.

invocation of mongo will look like this:
mongos --configdb rs-/m034:26050,m034:26051,m034:26052 --fork --logapend --logpath log.mongos0

Jacek.

 

Alan

unread,
Aug 9, 2017, 11:48:10 PM8/9/17
to mongodb-user
Hi Jacek or anyone who also may help,

The Mongo 3.4 Shard setup is different compared to previous versions from what I understand.  Here are the instructions that I am supposed to perform: 

Stop the mongod process. Now, restart the mongod process adding the option --shardsvr. If you started mongod with a --dbpath option, specify that as well.

mongod --shardsvr ...

Note that with --shardsvr specified the default port for mongod becomes 27018.


Start a mongo config server:

mongod --configsvr ...


Note: configuration server setup has changed. If you are using MongoDB 3.4 you must set up your configuration servers with CSRS. An example setup is as follows:


mongod --configsvr --replSet csReplSet ...
mongod --configsvr --replSet csReplSet ...
mongod --configsvr --replSet csReplSet ...

mongo --port 27019

config = { _id: "csReplSet", members:[
         { _id : 0, host : "localhost:27019" },
         { _id : 1, host : "localhost:27020" },
         { _id : 2, host : "localhost:27021" }]};
rs.initiate(config)


(Note with --configsvr specified the default port for listening becomes 27019 and the default data directory /data/configdb. Wherever your data directory is, it is suggested that you verify that the directory is empty before you begin.)


Start a mongos:

mongos --configdb your_host_name:27019


These are the steps I tried from what I have gathered so far: 

mongod --shardsvr --replSet a --dbpath a0 --logpath log.a0 --port 27000 --fork --logappend --smallfiles --oplogSize 50
mongod --shardsvr --replSet a --dbpath a1 --logpath log.a1 --port 27001 --fork --logappend --smallfiles --oplogSize 50
mongod --shardsvr --replSet a --dbpath a2 --logpath log.a2 --port 27002 --fork --logappend --smallfiles --oplogSize 50

mongod --configsvr --replSet a --dbpath cfg0 --port 26050 --fork --logpath log.cfg0 --logappend
mongod --configsvr --replSet a --dbpath cfg1 --port 26051 --fork --logpath log.cfg1 --logappend
mongod --configsvr --replSet a --dbpath cfg2 --port 26052 --fork --logpath log.cfg2 --logappend

mongos --configdb m034:26050,m034:26051,m034:26052 --fork --logappend --logpath log.mongos0


It looks like I'm missing the step where it says if you're using Mongo 3.4, you must set up you configuration servers with CSRS.  What steps am I missing in order to get it to work?  Please help me fill in the missing steps.  Thanks.

Asya Kamsky

unread,
Aug 10, 2017, 10:02:39 AM8/10/17
to mongodb-user
Why not follow the docs instructions?  See here:


Looks like you are missing the part where you connect to config servers and configure the replica set (the rs.initiate() section you quoted but didn’t mention running).

Asya


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/5dff7862-c497-4450-b6d4-0dc4a0908987%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Asya Kamsky
Lead Product Manager
MongoDB
Download MongoDB - mongodb.org/downloads
We're Hiring! - https://www.mongodb.com/careers

Alan

unread,
Aug 10, 2017, 10:19:09 PM8/10/17
to mongodb-user
Thanks Asya.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.

To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.

Alan

unread,
Aug 10, 2017, 10:20:11 PM8/10/17
to mongodb-user
Thanks Jacek.
Reply all
Reply to author
Forward
0 new messages