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?
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.
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.
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.
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.
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"
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With