Next let’s create the folders where is going to hold the data, keyfile and configurations inside the mongo_storage volume: $ docker exec mongoNode1 bash -c 'mkdir /data/keyfile /data/admin' $ openssl rand -base64 741 > mongo-keyfile $ chmod 600 mongo-keyfile The content of the keyfile must be the same for all members of the replica set. The contents of the keyfile serves as the shared password for the members of the replica set. $ docker run -name mongoNode1 \ -v mongo_storage:/data \ -d mongo \ -smallfiles Now let’s attached our volume created to start our first mongo container and set the configurations. $ docker volume create -name mongo_storage Now that we have our three machines lets position it in our first machine to start the mongodb configuration, let’s run the next command: $ eval `docker-machine env manager1`īefore creating our mongoDB containers, there is a very important topic that has been long discussed around database persistence in docker containers, and to achieve this challenge what we are going to do is to create a docker volume. To verify if our machines are created, let’s run the following command: $ docker-machine ls // the result will be NAME ACTIVE DRIVER STATE URL manager1 - virtualbox Running tcp://192.168.99.100:2376 worker1 - virtualbox Running tcp://192.168.99.101:2376 worker2 - virtualbox Running tcp://192.168.99.102:2376 # Step 2 - Configuration of master node of MongoDB Now let’s create the two lefting docker-machine $ docker-machine create -d virtualbox worker1 $ docker-machine create -d virtualbox worker2 This command will create a machine called manager1 using virtualbox as our virtualization provider. ![]() To create a docker machine we need to issue the next command in a terminal: $ docker-machine create -d virtualbox manager1 I will use VirtualBox on MacOS Sierra to run our mongoDB instances. ![]() If you are on Mac or Windows, consider using a Virtual Machine. In the image above we are seeing what is going to be the result of our replication set with docker.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |