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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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"
回答2:
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"
回答3:
Mongo added a --serviceDisplayName flag in 1.8