-
-
Save qknow-w/9f9fac92ce71e15080f6a2c4c3e5fe1f to your computer and use it in GitHub Desktop.
MongoDB Replica Set with Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
mongo1: | |
container_name: mongo1 | |
image: daocloud.io/mongo | |
ports: | |
- 27017:27017 | |
expose: | |
- 27017 | |
networks: | |
- mongo | |
command: mongod --replSet rs0 --smallfiles --oplogSize 128 | |
mongo2: | |
container_name: mongo2 | |
image: daocloud.io/mongo | |
expose: | |
- 27017 | |
networks: | |
- mongo | |
command: mongod --replSet rs0 --smallfiles --oplogSize 128 | |
mongo3: | |
container_name: mongo3 | |
image: daocloud.io/mongo | |
expose: | |
- 27017 | |
networks: | |
- mongo | |
command: mongod --replSet rs0 --smallfiles --oplogSize 128 | |
networks: | |
mongo: | |
driver: bridge |
master
db.createUser(
{
user: "xxx",
pwd: "xxx",
roles: [ "root" ]
})
docker exec -it mongo1 mongo
connecting to: test
> rs.initiate()
> rs.add("mongo2:27017")
> rs.add("mongo3:27017")
> rs.status();
secondary
rs.slaveOk();
http://www.jianshu.com/p/4d86e9c33e0d
http://shellfu.com/setting-up-a-mongodb-replica-set-on-docker/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
init