Skip to content

PacktPublishing/Learn-MongoDB-4.x

Repository files navigation

Learn MongoDB 4.x

Learn MongoDB 4.x

This is the code repository for Learn MongoDB 4.x, published by Packt.

A guide to understanding MongoDB development and administration for NoSQL developers

What is this book about?

When it comes to managing a high volume of unstructured and non-relational datasets, MongoDB is the defacto database management system (DBMS) for DBAs and data architects. This updated book includes the latest release and covers every feature in MongoDB 4.x, while helping you get hands-on with building a MongoDB database app.

This book covers the following exciting features:

  • Understand how to configure and install MongoDB 4.x
  • Build a database-driven website using MongoDB as the backend
  • Perform basic database operations and handle complex MongoDB queries
  • Develop a successful MongoDB database design for large corporate customers with complex requirements
  • Secure MongoDB database systems by establishing role-based access control with X.509 transport-level security

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

if (test expression)
{
  Statement upon condition is true
}

Here are the instructions for the test environment that serves for chapters 3 to 12. There are separate instructions, in the book, for testing MongoDB installation (chapter 2). Also, see chapter 13 for instructions on setting up a test environment to model a replica set. See chapter 14 for instructions on setting up a test environment to model a sharded cluster.

Set up your host computer

  • Install git
  • Clone the repository for the book
    • Open a terminal window (command prompt)
    • If you are running Windows, be sure to use the Git BASH shell to follow these commands
    • Change to a directory under which you wish to install the files for the book
    • Clone the repository for the book using git (substitute the target directory on your computer in place of /path/to/repo):
git clone https://github.com/packtpub/learn-mongodb-4_0 /path/to/repo
  • Install docker
  • Pull the Docker base image for the book
docker pull unlikelysource/mongodb_python:latest

How To Setup Test Environment

Using Docker Compose

  • Install docker-compose
  • Open a terminal window (or Windows GIT bash prompt)
  • Change to /path/to/repo
  • Bring the test environment online:
cd /path/to/repo
docker-compose up -d --build

Using Docker

  • Install docker
  • Create a volume learn-mongodb
docker volume create db_data_server_1
  • Identify the location
docker volume ls
docker volume inspect db_data_server_1
  • Run PHP for Linux image and mount the volume (replace $PWD with /path/to/repo):
docker run -d -it --name learn-mongo-server-1 -v db_data_server_1:/data/db -v $PWD:/repo -v $PWD/docker/hosts:/etc/hosts -v $PWD/docker/mongod.conf:/etc/mongod.conf unlikelysource/mongodb_python:latest

Restore the Sample Data

  • Open a terminal window (or Windows GIT bash prompt)
  • Change to /path/to/repo
  • Get container ID
docker container ls -a
  • Open a shell to the container
docker exec -it <container_ID> /bin/bash
// or
docker exec -it learn-mongo-server-1 /bin/bash
  • Restore sample data
/repo/restore_data_inside.sh
  • Stop / start the web server
/repo/restart_apache_inside.sh

Access the Test Server from Outside Docker

  • From inside the docker container, run this command to determine the IP address:
ifconfig
  • Add an entry at the end of the /etc/hosts file of your own computer as follows:
    • Substitute the IP address you discovered above if it's different from 172.16.0.11
172.16.0.11    learning.mongodb.local
  • Also, append the entries from /path/to/repo/docker/hosts file onto the end of your own /etc/hosts file
  • For readers using a Windows computer, the /etc/hosts file is located here:
C:\Windows\System32\drivers\etc\hosts

Following is what you need for this book: This book is a MongoDB tutorial for DevOps engineers, database developers, database administrators, system administrators and those who are just getting started with NoSQL and looking to build document-oriented databases and gain real-world experience in managing databases using MongoDB. Basic knowledge of databases and Python is required to get started with this DBMS book.

With the following software and hardware list you can run all code files present in the book (Chapter 1-16).

Software and Hardware List

Chapter Software required OS required
1-16 Docker, Docker Compose, Git (optional) with 2 GB free disk space, 4 GB of RAM and 500 Kbps or faster internet connection Linux or macOS
1-16 Docker for Windows and Git for Windows with 2 GB free disk space, 4 GB of RAM and 500 Kbps or faster internet connection Windows

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know the Author

Doug Bierer has been writing code since the early 1970s. His first project was a terrain simulator that ran on a Digital Equipment Corporation PDP-8 with 4 K of RAM. Since then, he's written applications for a variety of customers worldwide, in various programming languages, including BASIC, Assembler, PL/I, C, C++, FORTH, Prolog, Pascal, Java, PERL, PHP, and Python. His work with database technology spans a similar range in terms of years and includes Ingres, d:Base, Clipper, FoxBase, r:Base, ObjectVision, Btrieve, Oracle, MySQL, and, of course, MongoDB. Doug runs his own company, unlikelysource, and is also CTO at Foreach Code Factory, being involved in both training (php-cl) and a new cloud services platform (Linux for PHP Cloud Services).

Suggestions and Feedback

Click here if you have any feedback or suggestions.

About

Learn MongoDB 4.0, published by Packt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages