[Original] Deploy a MongoDB shard copy cluster on Docker.

Source: Internet
Author: User
Tags install mongodb docker run

First, install Docker.

Please refer to: http://www.cnblogs.com/hehexiaoxia/p/6150584.html

Second, the preparation of dockerfile.

#在根目录下创建dockerfile.

$ VI Dockerfile

#Version 1.0 fromUbuntu#MaintainerMaintainer HDX#InstallRun apt-Get Cleanrun apt-Get Updaterun apt-get Install-y vimrun Apt-get install-y openssh-Serverrun mkdir-p/var/run/sshd#Open Port 20001Expose 22Expose20001#cmd ["/usr/sbin/sshd", "-D"]Run apt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv Ea312927run Echo"Deb Http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 main">/etc/apt/sources.list.d/mongodb-org.list#Install MongoDBRun apt-Get Updaterun apt-get install-y mongodb-org#Create the MongoDB data directoryRun Mkdir-p/data/Dbentrypoint ["Usr/bin/mongod"]

Third, generate an image image by Dockerfile.

$ sudo docker build-t ubuntu/mongo:latest-</dockerfile

View the creation of the image.

$ sudo docker images

1 REPOSITORY      TAG       IMAGE ID        CREATED     VIRTUAL SIZE2 ubuntu/mongo  latest   522eeeae18e5    54 Minutes ago      

It is found that the image has been generated and can be created by using image.

Four, build MONGO cluster through image image.

1, create 2 shardsvr, each shardsvr contains 3 copies, 1 primary nodes, 1 slave nodes, 1 quorum nodes.

-D indicates background run

-P binds the host host to the Docker port, the first 20001 represents the host port, and the second represents the corresponding Docker port, which can be accessed by calling host host Ip:port to access Docker MongoDB.

$ sudo docker run-d-P 20001:20001--name rs1_container1 ubuntu/mongo:lastest--shardsvr--port 20001--replSet rs1

$ sudo docker run-d-P 20002:20001--name rs1_container2 ubuntu/mongo:lastest--shardsvr--port 20001--replSet rs1
$ sudo docker run-d-P 20003:20001--name rs1_container3 ubuntu/mongo:lastest--shardsvr--port 20001--replSet rs1

$ sudo docker run-d-P 20011:20001--name rs2_container1 ubuntu/mongo:lastest--shardsvr--port 20001--replSet rs2
$ sudo docker run-d-P 20012:20001--name rs2_container2 ubuntu/mongo:lastest--shardsvr--port 20001--replSet rs2
$ sudo docker run-d-P 20013:20001--name rs2_container3 ubuntu/mongo:lastest--shardsvr--port 20001--replSet rs2

2. Creation of 2 configsvr.
$ sudo docker run-d-P 21001:20001--name config_container1 ubuntu/mongo:lastest--configsvr--port 20001
$ sudo docker run-d-P 21002:20001--name config_container2 ubuntu/mongo:lastest--configsvr--port 20001

3, start 2 mongos services.

Not to be continued.

[Original] Deploy a MongoDB shard copy cluster on Docker.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.