MongoDB Server Instance As Service
From my last blog as i discussed about how can we run an Instance using cmd. As you might have noticed the instance have started but a command prompt get engaged with this and a
window remains open always which looks little odd. It’s not good practice to
run your server like this because any one can close server may be by mistake and restarting will have to go through all pain using cmd.
So we
can run the instance as windows service, which become easy to manage. You can start,
stop and restart easily. Otherwise you have to follow steps and type all info
again if you are restarting. Here is the screenshot of service I have created.
Now
unlike any other service you can start, stop or restart.
In
order to do so, we have to open command prompt again and change the directory
to bin folder follow step 2 as mentioned in my previous blog. Now type command mentioned below.
Make
sure you have created a directory and log file: C:\data\log\MongoDB.log. You
can create according to your choice, I have chosen C:\data\log\MongoDB.log.
{mongod
--auth --bind_ip localhost
--logpath
"C:\data\log\MongoDB.log"
--logappend --dbpath "C:\data\db" --port 27017 --serviceName
"MongoDB3.0" --serviceDisplayName "MongoDB3.0" --install}
--auth
:if you want to run your server in authentication mode, which at this point not
required rest is self-explanatory. So without authentication the command would
be
{mongod --bind_ip
localhost --logpath
"C:\data\log\MongoDB.log"
--logappend --dbpath "C:\data\db" --port 27017 --serviceName
"MongoDB3.0" --serviceDisplayName "MongoDB3.0" --install}
References:
No comments:
Post a Comment