Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb, sharding and multiple windows services

In order to get sharding to work I need to run two copies of mongod.exe. One as a shard and one as the config server. How can I install both mongod instances as windows services?

like image 614
detroitpro Avatar asked Aug 09 '10 03:08

detroitpro


People also ask

How does MongoDB increase sharding performance?

Sharding with MongoDB allows you to seamlessly scale the database as your applications grow beyond the hardware limits of a single server, and it does so without adding complexity to the application.

Can we do sharding in MongoDB?

MongoDB uses sharding to support deployments with very large data sets and high throughput operations. Database systems with large data sets or high throughput applications can challenge the capacity of a single server.

How many types of sharding exist in MongoDB?

While there are many different sharding methods, we will consider four main kinds: ranged/dynamic sharding, algorithmic/hashed sharding, entity/relationship-based sharding, and geography-based sharding.

How does sharding improve the write capacity of a MongoDB database?

As the size of the data increases, a single machine may not be sufficient to store the data nor provide an acceptable read and write throughput. Sharding solves the problem with horizontal scaling. With sharding, you add more machines to support data growth and the demands of read and write operations.


2 Answers

The following command line will install a 2nd instance of Mongo DB. Note that you have to provide serviceName, serviceDisplayName, port, dbpath and logpath in order to avoid collisions.

mongod --install --serviceName "Mongo DB 2nd instance" --serviceDisplayName "Mongo DB 2nd instance" --port 37017 --dbpath c:\data\db2 --logpath c:\data\logs\mongolog2.txt

Then you just start the service with

net start "Mongo DB 2nd instance"

like image 131
hemme Avatar answered Oct 11 '22 20:10

hemme


Use sc.exe from the Windows Resource Kit ( http://support.microsoft.com/kb/251192 ) which allows you to specify an unique display name for each instance:

sc.exe create "Mongo DB 1" binPath= "c:\mongodb\bin\mongod.exe --service --dbpath=c:\data\db --logpath=c:\data\log.txt"

like image 39
J-B Avatar answered Oct 11 '22 20:10

J-B