1

I've got 3 dedicated non-virtual servers (srv1-3). On one of them (srv1) i've got MongoDB in production, that already have got really big amount of data. At the present time there is no sharding or replica processes, it's just a standalone server.

So, I want this server (srv1) to be as a shrad and config server at the same time. The second server (srv2) is going to be a second shard. And the third one (srv3) is going to be a replica server.

I guess, that I have to run the mongod process on srv1 in two instances: one is the regular in --fork, and the second is --configsrv localhost:27019 (and previously create a separate directory for the config server, like /data/confDB).

After that, I should add sh.addShard("srv1:27017") and sh.addShard("srv2:27017") in mongo console and then just sh.enableSharding(myDBname).

Is that correct? Or it's necessary to create an additional server, that will be the config server?

  • ,What is the MongoDB version(x,y,z)? – Md Haidar Ali Khan Mar 5 at 10:14
  • My MongoDB version is 3.6.3 – Mikhail N. Mar 5 at 11:19
  • How big is the data, and why are you looking into doing sharding? Note that sharding is a relatively complex process that needs advanced planning, so unless you're hitting some hardware bottleneck, I would start by having a replica set first. On another note, I would not recommend you to have the config server and the shard server sharing a machine. This will lead to difficulties in backup & deployment in the future. – kevinadi Mar 6 at 4:39
0

So, I want this server (srv1) to be as a shrad and config server at the same time. The second server (srv2) is going to be a second shard. And the third one (srv3) is going to be a replica server.

Is that correct? Or it's necessary to create an additional server, that will be the config server?

Yes, you can, As per MongoDB documentation here Changed in version 3.4. Replica Set Config Servers.

Starting in MongoDB 3.2, config servers for sharded clusters can be deployed as a replica set (CSRS) instead of three mirrored config servers (SCCC). Using a replica set for the config servers improves consistency across the config servers, since MongoDB can take advantage of the standard replica set read and write protocols for the config data. In addition, using a replica set for config servers allows a sharded cluster to have more than 3 config servers since a replica set can have up to 50 members. To deploy config servers as a replica set, the config servers must run the WiredTiger storage engine.

In version 3.4, MongoDB removes support for SCCC config servers.

The following restrictions apply to a replica set configuration when used for config servers:

  • Must have zero arbiters.
  • Must have no delayed members.
  • Must build indexes (i.e. no member should have buildIndexes setting set to false).

Examples

The following command adds a replica set as a shard:

use admin
db.runCommand( { addShard: "repl0/mongodb3.example.net:27327"} )

WARNING Do not use localhost for the hostname unless your config server is also running on localhost.

  • Thank You! So, I've got one more question - what about the mongos process? How should I start it? I didn't get the right sequence of commands. What is the first step? Shall I start the "mongos --configdb" process first on the existing server? – Mikhail N. Mar 5 at 12:12
  • FIrst, start all your config servers. Then mongos or shard is fine. – Mani Mar 6 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.