How to Run MongoDB on Google Cloud Platform?
Last Updated :
23 Sep, 2022
MongoDB, the most popular NoSQL database in the technical world, is not based on a table-like relational database structure but provides different mechanisms for storing and retrieving data. This storage format is called BSON (similar to JSON). The term "NoSQL" means "non-relational". A relational database management system (RDBMS) is not the right choice when it comes to controlling big data by design because it is not horizontally expandable. If the database is running on a single server, it will reach a scaling limit. NoSQL databases are more expandable or adaptable. MongoDB is such a NoSQL database that scales by adding more and more servers and increases productivity with a flexible document model.
Using MongoDB on Google Cloud Platform
Here are the Reasons:
- GCP has the most Dominant network of any cloud provider. Running MongoDB on Google's cloud platform means you'll benefit from the low-latency infrastructure Google provides.
- GCP supports live migration – which means you can migrate your existing VMs from one host to another without downtime.
- Google has its security built into its culture. You'll benefit from all the security practices Google has learned and implemented over the years.
Choosing Right Instance Type
Firstly, you need a compute instance to run MongoDB on, and you should examine how much data you have, what questions you have, and what service level agreements you have with your customers. Ideally, you have to make sure that your chosen instance has enough RAM to support your workload and it has fast enough persistent storage. In general, databases do well with fast persistent storage. Let's Create New Instance.
Creating the Instance in GCP
Step 1: Go to Compute Engine in GCP and click Create Instance.
Step 2: Fill in your instance type details and click Create. This may take a few seconds - if so, don't worry.
Step 3: MongoDB listens on port 27017. You have to make sure that this port is allowed in your firewall rules for the specific IP addresses you want to grant access to. Be careful, don't open this port to the world. One way to restrict access is to create a new firewall rule in your VPC like this: Source IP address ranges are allowed server IP addresses that allow access, protocols, and ports. At this point, you have set up your instance. The next step is the installation of MongoDB on the google cloud Platform.
Installation of MongoDB in GCP
Step 1: Firstly, you need SSH in the Ubuntu instance you have created. You can do this in many ways. One way is to use SSH from the browser option that GCP provides. From the command line, run the command below to import the GPG MongoDB public key:
wget -qO – https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add –
Step 2: Create a file using this command:
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" |
sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
Finally, the installation of MongoDB begins using this command:
sudo apt-get update
Step 3: Installation of MongoDB:
sudo apt-get install -y mongodb-org
And then, you should have MongoDB installed. At this point, if MongoDB is installed but not running. Start MongoDB with this command:
sudo systemctl start mongod
Now you'll want to take a moment to verify that MongoDB has been installed properly. To do this, You have to run this command:
sudo systemctl status mongod
If everything is well, you will have a screen like this:
Similar Reads
How To View Request Logs On Google Cloud Platform ?
Google Cloud Platform Logs Explorer is a tool that enables users to retrieve view and analyze log data helping them troubleshoot problems and monitor their resources effectively. Logs are records of event ed through Google Cloud Console and log entries can be read through the Logging API or Google C
4 min read
Working of Google Cloud Platform
Pre-requisite: Google Cloud Platform Google Cloud Platform is a collection of cloud computing services offered by Google, including Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS) products. These services are designed to provide businesses with the
8 min read
Why Google Cloud Platform?
Pre-requisite: GCP Google Cloud Platform(GCP) is a collection of calculating services that run on the same structure that Google uses internally for its end-stoner products, similar to Google Search and YouTube. GCP offers a wide range of services, including storehouse, networking, big data, machine
4 min read
Features of Google Cloud Platform
Pre-requisite: GCP GCP or Google Cloud Platform is a Public Cloud Provider that enables us to have a list of computing services to perform various computational tasks and services. Here are some of the Features provided by Google Cloud: Cloud Storage: Cloud Storage stores data on Google's servers in
4 min read
How to Create a MySQL Database with Cloud SQL on Google Cloud Platform?
The collection of all the data used for the proper functioning of our product is called a need database (DB) and the system that manages the DB is called a need Database Management System(DBMS).Why Data Management Is Essential?We know that in any startup or business or product based companies like F
8 min read
How to Run MongoDB as a Docker Container?
MongoDB is an open-source document-oriented database designed to store a large scale of data and allows you to work with that data very efficiently. It is categorized under the NoSQL (Not only SQL) database because the storage and retrieval of data in MongoDB are not in the form of tables. In this
4 min read
How to Properly Reuse Connection to MongoDB Across NodeJs
Efficiently managing database connections is important for Node.js applications using MongoDB. MongoDB connection reuse in Node.js is a practice that optimizes resource utilization and enhances application performance. By reusing connections, developers can reduce the overhead associated with establ
6 min read
Google Cloud Platform Project Limit | Complete Tutorial
If we are talking about cloud technologies or cloud providers, then there is a common name, which is Google Cloud Platform. Google Cloud Platform, or GCP, provides various cloud services and computing resources to its users to host applications on the cloud or use databases, and storage on the cloud
6 min read
How to Integrate Google Calendar in Node.js ?
Integrating Google Calendar into a Node.js application allows you to create, modify, and manage calendar events programmatically. This can be useful for various applications, such as scheduling software, personal organizers, or any app that needs to manage events. In this article, we will walk throu
14 min read
How to Install MongoDB on GoormIDE?
GoormIDE is a simple web-based cloud programming tool and MongoDB is a document-oriented NoSQL database, they are used to make efficient software anytime and anywhere. as here during the development of any website or software one required a need of database i.e. MongoDB. so below we discussed two me
3 min read