running multiple instance of mongod as service

China☆狼群 提交于 2019-12-11 11:24:23

问题


i try to start multiple Instance of MongoDB as a Service. Under the commandline i can start more than one Mongo Instances, for the first instance i append "--install" to the Command and now it run as service. But now i try to append "--install" to the second Instance and get a Error:

first command runs well:

c:\data\bin\mongod --nohttpinterface --port 27201 --dbpath c:\data\cluster\db1 --master --logpath c:\var\log\mongodb_db1.log --serviceName MongoDB_1 --install

but the second one gives a error:

c:\data\bin\mongod --nohttpinterface --port 28000 --dbpath c:\data\cluster\db2 --master --logpath c:\var\log\mongodb_db2.log --serviceName MongoDB_2 --install

error:

Creating service MongoDB_2. Error creating service. Der Name wird bereits als Dienstname oder als Dienstinstanzname verwendet. (1078)

I think that MongoDB use an internal Servicename that is always the same and differ to the shown servicename. But i don't know how to fix it?

Any suggestions?

Regards Rene


回答1:


I ran into this same issue. My workaround is kind of hacky, but it seems to work:

  1. Create the first mongod service using monogd --install
  2. Open regedit and navigate to HKLM\SYSTEM\CurrentControlSet\services\NameOfMongoService
  3. Export this key
  4. Edit exported reg file in text editor, updating service name and mongod params.
  5. Import into reg (and possibly reboot).

To get mongos running as a service I took a different approach and used instsrv and srvany from the Windows NT Resource Kit:

http://support.microsoft.com/kb/137890

This kb doesn't mention that after intstalling srvany using instsrv you have to add a Parameters sub-key under the newly created service in the registry. This key should contain a REG_SZ named "Application" with the path to the app to start as a service.




回答2:


You can do a polite installation of a 2nd instance using the proper command line switches. Just read my answer here https://stackoverflow.com/a/9273816/249992



来源:https://stackoverflow.com/questions/4163428/running-multiple-instance-of-mongod-as-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!