Giter Site home page Giter Site logo

hansuxdev / learn-mongodb-4.x Goto Github PK

View Code? Open in Web Editor NEW

This project forked from packtpublishing/learn-mongodb-4.x

0.0 1.0 0.0 9.77 MB

Learn MongoDB 4.0, published by Packt

License: MIT License

JavaScript 99.38% Python 0.33% HTML 0.12% CSS 0.15% Dockerfile 0.01% Shell 0.01%

learn-mongodb-4.x's Introduction

Test Environment for Learn MongoDB 4.x

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

learn-mongodb-4.x's People

Contributors

pratikandrade avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.