Review
In the previous section, we have laid down the functional specs of the application. In this section, we will learn how to setup a MongoDB server both in Windows and Ubuntu.Table of Contents
Part 1: Introduction and Functional SpecsPart 2: MongoDB setup
Part 3: Java classes
Part 4: XML configuration
Part 5: HTML Files (with AJAX)
Part 6: Running the Application
MongoDB Setup
We will first tackle how to setup MongoDB in Windows, in particular Windows 7; then we will focus on Ubuntu, in particular Ubuntu 10.04.Windows 7
To setup a MongoDB server in Windows, follow these steps:1. Open a browser and visit the MongoDB download section at http://www.mongodb.org/downloads
2. Under the Production Release, choose the file that matches your operating system. In our case, it's Windows 32-bit.
3. Once downloaded, extract the contents of the zip file
4. Open the extracted folder and browse under the bin directory. You should see the following executables
5. Select and run mongod.exe application.
6. You should see a command prompt with a similar output:
Do not close the command prompt. Your MongoDB server is now running.
Note: If the command prompt abruptly appears and then disappears, it's possible that the data/db path is missing in your file system.
To verify this,
- Open a new command prompt
- Run mongod.exe (either by dragging the executable or typing manually the full path)
- Read the error and check if it's similar with the following:
[initandlisten] exception in initAndListen: 10296 dbpath (/d ata/db) does not exist, terminating dbexit: [initandlisten] shutdown: going to close listening sockets... [initandlisten] shutdown: going to flush diaglog... [initandlisten] shutdown: going to close sockets... [initandlisten] shutdown: waiting for fs preallocator... [initandlisten] shutdown: closing all files... [initandlisten] closeAllFiles() finished dbexit: really exiting now
- If it's the same message, please proceed below to resolve the issue.
To resolve this issue, follow these steps:
- Go to C:\ drive
- Create a new folder data
- Open data
- Create a new folder db
- Then run mongod.exe again. You should see MongoDB running now.
Ubuntu 10.04
To setup a MongoDB server in Ubuntu, follow these steps:1. Open a browser and visit the MongoDB download section at http://www.mongodb.org/downloads
2. Under the Production Release, choose the file that matches your operating system. In our case, it's Linux 32-bit.
3. Once downloaded, extract the contents of the compressed file
4. Open the extracted folder and browse under the bin directory. You should see the following executables. Pay attention to mongod.
5. Let's make mongod executable. There are two ways: GUI and terminal-based
GUI-based:
- Right-click on the mongod application
- Open the "Permissions" tab.
- Ensure that "Allow executing file as program" is checked
Terminal-based:
- Open a terminal
- Run the following command:
sudo chmod +x PATH/TO/YOUR/MONGO/bin/mongod
Make sure to change the path to your Mongo directory.
6. Open a terminal and run the following command:
PATH/TO/YOUR/MONGO/bin/mongod
7. You should see a similar output indicating that your MongoDB server is now running:
Note: If in case there's an error, make sure that /data/db directory exists in the file system. This is similar with the Windows error above.
Next
In the next section, we will discuss the project's structure and start writing the Java classes. Click here to proceed.
Share the joy:
|
Subscribe by reader Subscribe by email Share
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletecore java training in Electronic City
Hibernate Training in electronic city
spring training in electronic city
java j2ee training in electronic city