Starting MongoDB Database Software

MongoDB Database Software

In this blog post, we will cover how to start MongoDB database software in the three most used platforms: Windows/Linux/MacOS.

If you have just started with NoSQL databases, you might wonder how to evaluate if MongoDB is a good fit for your application.

Percona provides a signed version of MongoDB called Percona Server for MongoDB with a couple of enterprise-grade features included free of charge that runs on all Linux flavors. We also support MongoDB, please check out our support page. But, what if you’re running a test on your study laptop, PC or not. How do you easily start a mongod process for testing? Below I demonstrate how to start MongoDB database software on the three most popular operating systems.

Microsoft Windows

First of all, be aware of this hotfix: https://support.microsoft.com/en-ca/help/2731284/33-dos-error-code-when-memory-memory-mapped-files-are-cleaned-by-using.

You might need to restart the computer after applying the fix. Then download the .zip file. The website only offers an MSI, but we don’t want to install the binaries, we just want to run it.

Click here to download the 3.4.10 version:
http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.4.10.zip

After the download, use your favorite decompressing tool to extract the MongoDB executables. Then cut the extracted folder to your Documents or C: or even a memory stick (but don’t expect high performance):

 

Inside of the bin folder, create a data folder. We are going to use this folder to save our databases.

 

Now we have everything we need to start the database. Open the CMD, and run the following commands to start the database:

C:\mongodb\bin\mongod --dbpath c:\mongodb\bin\data

You will see an output like:

This means the process is running.

In a different CMD, connect to the database using:

C:mongodbbinmongod --dbpath c:mongodbbindata

I’ve passed the –quiet to omit the warnings:

And here we go, MongoDB is running on a windows machine!

MacOS and Linux configuration:

For macOS, the process is very similar to Windows. The difference is that we can take advantage of the extensive bash commands that the UNIX-like system offers.

Open the terminal. Go to our home/Downloads folder:

cd ~/Downloads

Download MongoDB for MacOS or Linux:

wget https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz
Download mongodb for Linux:
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz
untar the file:
tar -xvzf mongodb-osx-ssl-x86_64-3.6.3.tgz
Change the folder name to mongodb // just to make it easier
mv mongodb-osx-x86_64-3.6.3/ ~/Downloads/mongodb
Right now all the binaries are on ~/Downloads/mongodb/
Create a folder to save the database is in ~/Downloads/mongodb/bin/
mkdir ~/Downloads/mongodb/bin/data
Start the mongod process
./mongod --dbpath data

The output must be similar to:

On a different tab run:

~/Downloads/mongodb/bin/mongo

At this point, you should be able to use MongoDB with the default options on MacOS or Linux.

Note that we aren’t enabling authentication either configuring a replica set.

If we don’t pass the –quiet parameter we will receive a few warnings like:

2018-03-16T14:26:20.868-0300 I CONTROL  [initandlisten]
I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
I CONTROL  [initandlisten] **  Read and write access to data and configuration is unrestricted.
I CONTROL  [initandlisten]
I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
I CONTROL  [initandlisten] **       Start the server with --bind_ip <address> to specify which IP
I CONTROL  [initandlisten] **  addresses it should serve responses from, or with --bind_ip_all to
I CONTROL  [initandlisten] **   bind to all interfaces. If this behavior is desired, start the
I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
I CONTROL  [initandlisten]

For more information about how to configure those parameters, please refer to the following blog post and or documentation:

https://www.percona.com/blog/2017/12/15/mongodb-3-6-security-improvements/

https://www.percona.com/blog/2017/05/17/mongodb-authentication-and-roles-creating-your-first-personalized-role/

https://www.percona.com/blog/2016/08/12/tuning-linux-for-mongodb/

To stop the mongod process, use ctrl+c (on any operating system) in the server window.

The post Starting MongoDB Database Software appeared first on Percona Database Performance Blog.

关注dbDao.com的新浪微博

扫码加入微信Oracle小密圈,了解Oracle最新技术下载分享资源

TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569