hands-on lab

Install MongoDB with Persistent Volumes

Up to 1h 30m
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.


Lab Overview

MongoDB is an extremely popular cross-platform document-oriented database.

This Lab is designed to show you how to install MongoDB with persistent data volumes on a Linux based EC2 instance within AWS.

Lab Objectives

Upon completion of this Lab, you will be able to:

  • Install and configure MongoDB on Amazon 2 Linux with persistent EBS based volumes
  • Use the mongo client command to connect to the MongoDB service and create and query data
  • Prepare and format an XFS based filesystem using the mkfs.xfs command
  • Mount filesystems

You should:

  • Be comfortable with using an SSH based terminal session

Lab Environment

This Lab will start with the following AWS resources provisioned automatically for you:

  • A single EC2 instance, named mongodb.server.instance, which will have a public IP address attached. This will be the instance that you will connect to using SSH, to setup and install MongoDB.

To achieve the Lab end state, you will be walked through the process of:

  • Using your local terminal or SSH client to remotely connect to mongodb.server.instance
  • Format and prepare persistent disk volumes for the /data, /log, and /journal directories used by MongoDB
  • Install and configure the MongoDB service
  • Use the mongo client command to connect to the MongoDB service and create and query data


December 29th, 2022 - Updated lab to use EC2 Instance Connect

Environment before

Environment after

About the author

Jeremy Cook, opens in a new tab
Content Lead Architect
Learning paths

Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, Azure, GCP), Security, Kubernetes, and Machine Learning.

Jeremy holds professional certifications for AWS, Azure, GCP, Terraform, Kubernetes (CKA, CKAD, CKS).

Lab steps

Logging In to the Amazon Web Services Console
Connecting to an EC2 Instance Using Amazon EC2 Instance Connect
Format and Mount Persistent Data Volumes
Install MongoDB
Connect to MongoDB Service