Last active
July 26, 2019 01:06
-
-
Save focusj/1d75713c884dd52c151395051f2dccf1 to your computer and use it in GitHub Desktop.
docker启动mongodb replicaset
This file contains hidden or 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
| docker network create mongo | |
| docker run -d \ | |
| -p 0.0.0.0:27017:27017 \ | |
| --name mongo-rs1 \ | |
| --net mongo \ | |
| mongo:3.4.20-xenial mongod --replSet mongo-rs1 | |
| docker run -d \ | |
| -p 0.0.0.0:27027:27017 \ | |
| --name mongo-rs-n1 \ | |
| --net mongo \ | |
| mongo:3.4.20-xenial mongod --replSet mongo-rs1 | |
| docker run -d \ | |
| -p 0.0.0.0:27037:27017 \ | |
| --name mongo-rs-n2 \ | |
| --net mongo \ | |
| mongo:3.4.20-xenial mongod --replSet mongo-rs1 | |
| docker exec -it mongo-rs1 mongo | |
| > rs.initiate | |
| > rs.add("mongo-rs-n1:27017") | |
| > rs.add("mongo-rs-n2:27017") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment