Mongodb in Linux Server

MongoDB migration from local host to a Linux server

First, you should capture the database file:
Find this directory on windows cmd:
C:\Program Files\MongoDB\Tools\100\bin
write the following in the cmd:
“mongoexport --db --collection --out
output.json”
find the database JSON file in that directory

Now you should export you database to the server directory:
scp -r /mnt/d/database.json
@:/home/...

Now you should import the mongodb database:
mongoimport --db --collection --file

Specifying storage for mongoDB server in fresh install on Azure

The reason why you see pricing is because it's neither added by Canonical nor MongoDB publishers. The golden image you shared is being offered by Cloud Infrastructure Services. They not only offer MongoDB CE images but also packer, docker compose etc., built on top of Opensource OS.

As you say both OS & Data disks will be provisioned using Premium SSDs. I wouldn't worry much about performance.

To cut down costs, I would propose below things.

  1. Create MongoDB image yourself by picking free version of Ubuntu/Centos or whatever. You can use packer or Azure Image Builder. I would setup automation to periodically build images with different versions of Mongo & Linux flavor & version them
  2. Provision VM, install MongoDB app on top of the VM & regularly patch, upgrade both linux & application packages
  3. If you have MongoDB server on-prem, you could create a snapshot of OS with MongoDB application packaged in it, convert it into vhd file & export the image onto Azure. You can follow documentation here
  4. If MongoDB offers golden images as private offers & you have existing license contract with them. Check out with MongoDB, register your subscription & you may be eligible to access their golden images on Azure appearing as "Private Offers". RedHat offers it's images to customers this way.

The image being offered on Azure doesn't make much financial sense. Let's assume you have 3 node cluster.

Pricing for using image is :: 0.025 euros per hour

per day it would be :: 24*0.025 = 0.6 euros

yearly cost could be :: 365*0.6 = 219 euros

combined cost for 3 nodes :: 219*3 = 657 euros

If you have multiple environments, multiple databases in different regions, cost just gets multiplied on & on.

Now, the choice is yours!

Install multiple versions of MongoDB on linux

To do that, you must have both versions of MongoDB available on your system.

For instance, let's say you have downloaded the 2.6 version binaries to /opt/mongo/26/ and the other version's at /opt/mongo/34/, you could run both versions of the database daemon on different ports:

/opt/mongo/26/mongod --dbpath /data/26/ --port 27017
/opt/mongo/34/mongod --dbpath /data/34/ --port 28018

Accessing MongoDB from Windows & Mac Client Machines

I found the answer. @ShahNewasKhan is brilliant. See How to connect Robomongo to MongoDB

All you need to do is SSH to server and edit mongod.conf file:

  1. uncomment #port=27017 to port=27017
  2. comment bind_ip=127.0.0.1 to #bind_ip=127.0.0.1
  3. restart mongodb via service mongod restart

Then create a mongo connection via your server ip in the address field and 27017 in the port field

Hope this helps mongo newbies and start-ups like me :) Good luck.

Now I just need to figure out how to make this secure. My concern is that anyone who knows my server ip can hack into my MongoDB



Related Topics



Leave a reply



Submit