问题
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:
- Create the first mongod service using monogd --install
- Open regedit and navigate to HKLM\SYSTEM\CurrentControlSet\services\NameOfMongoService
- Export this key
- Edit exported reg file in text editor, updating service name and mongod params.
- 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