I am new to MongoDB and NodeJS. I am running an ec2 instance on AWS and I want to sync the data of AWS to local systems and local to AWS. I don't have any idea about how to do it. I have tried some configuration in database files but I am not able to connect my local system with remote server.
I found this repository on git hub https://github.com/sheharyarn/mongo-sync but I don't know how to use that repository in my code.
Kindly help me.
Thank you
Mongodb atlas provides free 512MB of space. You can create cluster in mongoldb atlas and use online database from anywhere. it will work on your local machine and also on aws server.
Just open mongoldb website you can find mongoldb atlas easily. after sign up.
Related
My apologies if this is a noob question but, is it possible to configure a docker-compose file to get an already-existing Mongo Atlas database working as part of a docker network?
I have searched in internet but everyone is using new local mongodb connections or new mongodb Atlas ones.
(I have an express node forum running and its hosted on Atlas cloud db)
First of all you need to understand that MongoDB Atlas is a Cloud platform for MongoDB, so the database lives somewhere in the cloud, e.g. AWS.
While Docker network is a local network that Docker creates for you to encapsulate different containers into one net, thus making it possible to communicate between each other, and by the same token be isolated from world.
The answer is that you cannot make MongoDB Atlas part of your Docker network, because Atlas is not a Container that you could embed into your network. But the good news that you don't need to, because you can connect to the Atlas instance anyways from any computer, in condition that configuration of your Atlas allows to establish connections.
As admin part I want to use ForestAdmin.
Also I am gonna use already existing database (Mattermost`s actually).
Everything was deployed to AWS (ForestAdmin and Mattermost).
Due to tutorial I can install ForestAdmin via Lumber and connect it to existing db. Actually I have done this, do some playing with code to expand some functionalities.
The main question is: when I install ForestAdmin locally via Lumber - I point to my local instance of database and lumber generates code (models and CRUD). So also I can install ForestAdmin locally and point to Mattermost`s database on AWS. BUT can I somehow change which database I want to use - local or that one on AWS?
Maybe I explain this problem bad - so also I will try to rephrase with example of desired flow:
Mattermost with database already installed on AWS
ForestAdmin also installed via Lumber and connected to Mattermost`s db
I got local instance of Forestadmin and Mattermost, write some code, test it in local environment.
Push to repo, connect via ssh to AWS and pull changes which was made.
AWS instances works as local but with separate instances of db.
Or maybe there is some better way to push changes from local Forestadmin and pull it to AWS instance of Forestadmin?
Thanks for any help in advance!
Yes you definitely can, you can use Forest environment for that :
https://docs.forestadmin.com/documentation/reference-guide/how-it-works/environments
Can I use my aws EC2 instance to run both node server and mongo server by installing mongo driver into my EC2 instance ?
Its gotta be just like how we do it in our localhost, right?
I'd rather advise you to separate concerns and have dedicated instances for nodejs and for mongodb. It's not only good practice to separate app and db but also you'll able to scale much easier, and you'll scale exactly what you need.
I have created an application using MEAN, After that, I have created the ec2 Linux instance, where I am running this application.I have installed all the dependencies.
Added port 27017 on security group page.
running the command on the ec2 instance as node server.js
Node: My mongo DB is outside my cloud instance i.e on my laptop.
How can I fix this error?
You need to open your laptop to internet which is almost impossible (and you shouldn't). That means you need a MongoDB server which is accessible by your EC2 Linux instance.
You may use a free mongodb hosting such as mlab
On the other hand you can enable another EC2 instance and setup your own mongodb. Beware that you may need to setup firewall if it's not an internal network.
I have an ElasticBean application running (setup with NodeJS) and I wondered what the best way to integrate MongoDB would be. As of now, all I've done is ssh into my eb instance (with the eb cli) and install mongodb. My main worry comes from the fact that the mongo db exists in my instance. As I understand it, that means that my data will most certainly be lost as soon as I terminate my instance. Is that correct? If so the what is the best way to go about hooking en EB app to a MongoDB? Does AWS support that natively without having to go rent a DB on a dedicated server?
You definitely do NOT want to install MongoDB on an Elastic Beanstalk instance.
You have a few options for running MongoDB on AWS. You can install it yourself on some EC2 servers (NOT Elastic Beanstalk servers) and handle all the management of that yourself. The other option is to use mLab (previously MongoLab) which is a managed MongoDB as a Service provider that works on AWS as well as other cloud services. Using mLab you can easily provision a MongoDB database in the same AWS region as your Elastic Beanstalk servers.
Given the steps involved in setting up a highly-available MongoDB cluster on AWS I generally recommend using mLab instead of trying to handle it yourself. Just know that the free-tier is not very performant and you will want to upgrade to one of the paid plans for your production database.
Been there, done that. As #MarkB suggested it´d be a lot easier to use a SaaS instead.
AWS by itself doesn´t have a native MongoDB support but deppending of your requierements you could find a solution with little or no extra cost (beside EC2 price) on Amazon Marketplace. These images are vendor´s pre-configured production-ready AMIs of popular tools like MongoDB.