-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts/0-init_mongod.sh scripts/1-init_mongocfg.sh scripts/2-add-shard0.sh
- Loading branch information
1 parent
f8eda00
commit 44886f9
Showing
16 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/docker_compose.env | ||
/var/lib/mongo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# mongo-cluster-docker-compose | ||
mongo-clluster-docker-compose | ||
|
||
## Docker-compose | ||
|
||
You can do the following to start with docker-compose: | ||
|
||
* copy `docker_compose.env.template` to `docker_compose.env` and modify the settings. | ||
* `docker-compose --env-file docker_compose.env -f docker-compose.yaml up -d` | ||
* `scripts/0-init_mongod.sh` | ||
* `scripts/1-init_mongocfg.sh` | ||
* `scripts/2-add-shard0.sh` | ||
|
||
您可以使用以下方式來使用 docker-compose: | ||
|
||
* 將 `./docker_compose.env.template` copy 到 `./docker_compose.env` 並且更改相對應的設定. | ||
* `docker-compose --env-file docker_compose.env -f docker-compose.yaml up -d` | ||
* `scripts/0-init_mongod.sh` | ||
* `scripts/1-init_mongocfg.sh` | ||
* `scripts/2-add-shard0.sh` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
version: '2' | ||
services: | ||
mongod0-0: | ||
image: mongo:4.4.2 | ||
command: | ||
- "mongod" | ||
- "-f" | ||
- "/etc/mongod.conf" | ||
expose: | ||
- 27018 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOD_CPU} | ||
memory: ${MONGOD_MEM} | ||
reservations: | ||
cpus: ${MONGOD_CPU} | ||
memory: ${MONGOD_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOD0_0}:/data/db | ||
- ${MONGOD0_CFG}:/etc/mongod.conf | ||
mongod0-1: | ||
image: mongo:4.4.2 | ||
command: | ||
- "mongod" | ||
- "-f" | ||
- "/etc/mongod.conf" | ||
expose: | ||
- 27018 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOD_CPU} | ||
memory: ${MONGOD_MEM} | ||
reservations: | ||
cpus: ${MONGOD_CPU} | ||
memory: ${MONGOD_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOD0_1}:/data/db | ||
- ${MONGOD0_CFG}:/etc/mongod.conf | ||
mongod0-arb: | ||
image: mongo:4.4.2 | ||
command: | ||
- "mongod" | ||
- "-f" | ||
- "/etc/mongod.conf" | ||
expose: | ||
- 27018 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOD_ARB_CPU} | ||
memory: ${MONGOD_ARB_MEM} | ||
reservations: | ||
cpus: ${MONGOD_ARB_CPU} | ||
memory: ${MONGOD_ARB_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOD0_ARB}:/data/db | ||
- ${MONGOD0_CFG}:/etc/mongod.conf | ||
mongocfg-0: | ||
image: mongo:4.4.2 | ||
command: | ||
- "mongod" | ||
- "-f" | ||
- "/etc/mongod.conf" | ||
expose: | ||
- 27019 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOCFG_CPU} | ||
memory: ${MONGOCFG_MEM} | ||
reservations: | ||
cpus: ${MONGOCFG_CPU} | ||
memory: ${MONGOCFG_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOCFG_0}:/data/db | ||
- ${MONGOCFG_CFG}:/etc/mongod.conf | ||
mongocfg-1: | ||
image: mongo:4.4.2 | ||
command: | ||
- "mongod" | ||
- "-f" | ||
- "/etc/mongod.conf" | ||
expose: | ||
- 27019 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOCFG_CPU} | ||
memory: ${MONGOCFG_MEM} | ||
reservations: | ||
cpus: ${MONGOCFG_CPU} | ||
memory: ${MONGOCFG_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOCFG_1}:/data/db | ||
- ${MONGOCFG_CFG}:/etc/mongod.conf | ||
mongocfg-2: | ||
image: mongo:4.4.2 | ||
command: | ||
- "mongod" | ||
- "-f" | ||
- "/etc/mongod.conf" | ||
expose: | ||
- 27019 | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOCFG_CPU} | ||
memory: ${MONGOCFG_MEM} | ||
reservations: | ||
cpus: ${MONGOCFG_CPU} | ||
memory: ${MONGOCFG_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOCFG_2}:/data/db | ||
- ${MONGOCFG_CFG}:/etc/mongod.conf | ||
mongos-0: | ||
image: mongo:4.4.2 | ||
ports: | ||
- "127.0.0.1:27017:27017" | ||
command: | ||
- "mongos" | ||
- "-f" | ||
- "/etc/mongos.conf" | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOS_CPU} | ||
memory: ${MONGOS_MEM} | ||
reservations: | ||
cpus: ${MONGOS_CPU} | ||
memory: ${MONGOS_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOS_CFG}:/etc/mongos.conf | ||
mongos-1: | ||
image: mongo:4.4.2 | ||
ports: | ||
- "127.0.0.1:27027:27017" | ||
command: | ||
- "mongos" | ||
- "-f" | ||
- "/etc/mongos.conf" | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: ${MONGOS_CPU} | ||
memory: ${MONGOS_MEM} | ||
reservations: | ||
cpus: ${MONGOS_CPU} | ||
memory: ${MONGOS_MEM} | ||
restart: always | ||
volumes: | ||
- ${MONGOS_CFG}:/etc/mongos.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
MONGOD0_0=${PWD}/var/lib/mongo/mongod0_0 | ||
MONGOD0_1=${PWD}/var/lib/mongo/mongod0_1 | ||
MONGOD0_ARB=${PWD}/var/lib/mongo/mongod0_arb | ||
MONGOCFG_0=${PWD}/var/lib/mongo/mongocfg_0 | ||
MONGOCFG_1=${PWD}/var/lib/mongo/mongocfg_1 | ||
MONGOCFG_2=${PWD}/var/lib/mongo/mongocfg_2 | ||
|
||
MONGOD0_CFG=${PWD}/etc/mongo/mongod0.conf | ||
MONGOCFG_CFG=${PWD}/etc/mongo/mongocfg.conf | ||
MONGOS_CFG=${PWD}/etc/mongo/mongos.conf | ||
|
||
MONGOD_CPU=2 | ||
MONGOD_MEM=24G | ||
MONGOD_ARB_CPU=2 | ||
MONGOD_ARB_MEM=4G | ||
MONGOCFG_CPU=2 | ||
MONGOCFG_MEM=8G | ||
MONGOS_CPU=2 | ||
MONGOS_MEM=8G |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
storage: | ||
dbPath: /data/db | ||
journal: | ||
enabled: true | ||
wiredTiger: | ||
engineConfig: | ||
cacheSizeGB: 0.3 | ||
net: | ||
bindIpAll: true | ||
tls: | ||
mode: disabled | ||
# PEMKeyFile: /etc/mongo/ssl/mongo-keypem.pem | ||
# CAFile: /etc/mongo/ssl/root-ca.pem | ||
# allowConnectionsWithoutCertificates: true | ||
# allowInvalidCertificates: false | ||
# security: | ||
# clusterAuthMode: x509 | ||
replication: | ||
replSetName: mongo-configsvr | ||
sharding: | ||
clusterRole: configsvr |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
storage: | ||
dbPath: /data/db | ||
journal: | ||
enabled: true | ||
wiredTiger: | ||
engineConfig: | ||
cacheSizeGB: 0.5 | ||
net: | ||
bindIpAll: true | ||
tls: | ||
mode: disabled | ||
# PEMKeyFile: /etc/mongo/ssl/mongo-keypem.pem | ||
# CAFile: /etc/mongo/ssl/root-ca.pem | ||
# allowConnectionsWithoutCertificates: true | ||
# allowInvalidCertificates: false | ||
# security: | ||
# clusterAuthMode: x509 | ||
replication: | ||
replSetName: mongo0 | ||
sharding: | ||
clusterRole: shardsvr |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
net: | ||
bindIpAll: true | ||
tls: | ||
mode: disabled | ||
# PEMKeyFile: /etc/mongo/ssl/mongo-keypem.pem | ||
# CAFile: /etc/mongo/ssl/root-ca.pem | ||
# allowConnectionsWithoutCertificates: true | ||
# allowInvalidCertificates: false | ||
# security: | ||
# clusterAuthMode: x509 | ||
sharding: | ||
configDB: mongo-configsvr/mongocfg-0:27019,mongocfg-1:27019,mongocfg-2:27019 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
docker exec mongo-cluster-docker-compose_mongod0-0_1 mongo localhost:27018 --eval 'rs.initiate({ | ||
_id : "mongo0", | ||
members: [ | ||
{ _id: 0, host: "mongod0-0:27018" }, | ||
{ _id: 1, host: "mongod0-1:27018" }, | ||
{ _id: 2, host: "mongod0-arb:27018", arbiterOnly: true } | ||
] | ||
})' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
docker exec mongo-cluster-docker-compose_mongocfg-0_1 mongo localhost:27019 --eval 'rs.initiate({ | ||
_id : "mongo-configsvr", | ||
members: [ | ||
{ _id: 0, host: "mongocfg-0:27019" }, | ||
{ _id: 1, host: "mongocfg-1:27019" }, | ||
{ _id: 2, host: "mongocfg-2:27019" } | ||
] | ||
})' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker exec mongo-cluster-docker-compose_mongos-0_1 mongo localhost:27017 --eval 'sh.addShard("mongo0/mongod0-0:27018,mongod0-1:27018")' |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.