Working with MongoDB

1 hour
  • 3 Learning Objectives

About this Hands-on Lab

There are often times that you will be called upon in your journey to assist in the testing of a new technology. In this hands-on lab, you will be installing MongoDB. Once it has been installed, you will be bulk inserting data to be used by your Dev team for testing.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install MongoDB version 4.0
  1. Add the YUM repository for the repo as sudo:

    sudo su
    cat << EOF > /etc/yum.repos.d/mongodb-org-4.0.repo
    name=MongoDB Repository 
  2. Install and start MongoDB:

    yum install -y mongodb-org
    service mongod start
Insert the test data located in /home/cloud_user/data/cities.csv
  1. As the regular user, run the mongoimport command:

    mongoimport -d cities -c cityinfo --type CSV --file '/home/cloud_user/data/cities.csv' --headerline
Validate that the data has the required entries
  1. This is done from the mongo shell:

    use cities

    This should return four records.

  2. Exit the mongo shell.

  3. Exit the server.

Additional Resources

In this hands-on lab, you will be required to install and prep a MongoDB instance. This involves installing MongoDB version 4.0 and importing the test data file cities.csv that is located in the cloud_user's home directory in the data folder. The database needs to be named "cities" and the collection will be "cityinfo".

Once this is complete, you will need to ensure that the data was imported correctly and that there are four entries for the state of Georgia (GA) in the imported data.

When you are done, exit out of the server and leave it in its current state.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?