Skip to content

Start Stop local MongoDB server with Eclipse

angelozerr edited this page Jul 26, 2012 · 11 revisions

MongoDB IDE gives you the capability to start/stop a local MongoDB server and display server logs in the Eclipse Console :

Start Local Server

On other words, you can define a MongoDB server as Mongo runtime and start it by calling the /bin/mongod.exe (or mongod.sh) process file with an Eclipse Launch (start button generate an Eclipse Launch which do that).

Install MongoDB Server

Install MongoDB Server is very easy. To do that :

  1. Download MongoDB MongoDB Server by choosing the well distribution according your OS.
  2. Unzip the distribution on your hard disk.

Configure Mongo Runtimes

After installing a MongoDB server, you can reference this server in the Mongo Runtimes preferences. To do that, go to the Window/Preferences menu and click on MongoDB IDE/Mongo Runtimes node :

Mongo Runtimes Preferences

Click on Add... button to open the New MongoDB Runtime Environnment dialog:

New MongoDB Runtime Environnment

Click on Browse... button of the dialog to select the well home directory (this home directory must contains a /bin folder which contains mongo.exe (or mongo.sh) and mongod.exe (or mongod.sh) process files.) on your local MongoDB server:

Select MongoDB home directory

After selecting the well home directory, the name field should be fill automaticly with the version of the MongoDB server (the /bin/mongo.exe is called with -version parameter to get the version of the server) :

Well MongoDB home directory

Click on OK button to close the dialog and display in the Mongo Runtimes list the new runtime :

New Runtime in the list

Click on OK button of the Preferences page to save the runtime.

Create Local MongoDB Server

After opening the MongoDB Explorer View

Empty MongoDB Explorer View

you can create the local MongoDB server with the New Server wizard. To open this wizard you can click on right mouse button of the view and select New/New Server menu item :

New Server from View

or by going to the File/New/Other... menu item and select MongoDB IDE/New Server menu item :

New Server from New wizard

the New Server wizard appears :

Empty New Server wizard

To define a Local server, you must :

  1. select localhost for the host.
  2. select a runtime environnment.

Local Server with New Server wizard

Click on OK button to close the wizard and register the new server. The MongoDB View Explorer is refreshed with the new server :

View with New Server

Start Local MongoDB Server

At this step you can start the local server by clicking on start button :

Start the server

This start button :

  1. starts the local server by calling the /bin/mongod.exe (defined by the runtime)
  2. try to connect (with Mongo Java Driver) to this local server.

While this step, server state is starting :

Starting the server

Once the connection can be done, server state is started and databases of this server appears:

Started server

You will notice that Eclispe Console displays logs of the server.