|
2 | 2 |
|
3 | 3 | if [ "$#" -ne 1 ]; then
|
4 | 4 | echo "usage: cluster_setup <server|replica_set|sharded_cluster>"
|
| 5 | + echo "override <DATA_DIR | SINGLE_DIR | REPLICASET_DIR | SHARDED_DIR> env variables to change dbPath" |
5 | 6 | exit
|
6 | 7 | fi
|
7 | 8 |
|
| 9 | +DATA_DIR=${DATA_DIR:-data} |
| 10 | +SINGLE_DIR=${SINGLE_DIR:-$DATA_DIR/server} |
| 11 | +REPLICASET_DIR=${REPLICASET_DIR:-$DATA_DIR/replica_set} |
| 12 | +SHARDED_DIR=${SHARDED_DIR:-$DATA_DIR/sharded_cluster} |
| 13 | + |
8 | 14 | if [[ $1 == "replica_set" ]]; then
|
9 |
| - mlaunch init --replicaset --nodes 3 --arbiter --name rs --port 31000 --enableMajorityReadConcern --setParameter enableTestCommands=1 |
10 |
| - echo "mongodb://localhost:31000/?replicaSet=rs" |
| 15 | + mkdir -p $REPLICASET_DIR |
| 16 | + mlaunch init --dir $REPLICASET_DIR --replicaset --nodes 3 --arbiter --name rs --port 31000 --enableMajorityReadConcern --setParameter enableTestCommands=1 |
| 17 | + echo "mongodb://localhost:31000,localhost:31001,localhost:31002/?replicaSet=rs" |
11 | 18 | elif [[ $1 == "sharded_cluster" ]]; then
|
12 |
| - mlaunch init --replicaset --nodes 3 --arbiter --name rs --port 51000 --enableMajorityReadConcern --setParameter enableTestCommands=1 --sharded 1 --mongos 2 |
13 |
| - echo "mongodb://localhost:51000,localhost:51001/" |
| 19 | + mkdir -p $SHARDED_DIR |
| 20 | + mlaunch init --dir $SHARDED_DIR --replicaset --nodes 3 --arbiter --name rs --port 51000 --enableMajorityReadConcern --setParameter enableTestCommands=1 --sharded 1 --mongos 2 |
| 21 | + echo "mongodb://localhost:51000,localhost:51001" |
14 | 22 | elif [[ $1 == "server" ]]; then
|
15 |
| - mlaunch init --single --setParameter enableTestCommands=1 |
| 23 | + mkdir -p $SINGLE_DIR |
| 24 | + mlaunch init --dir $SINGLE_DIR --single --setParameter enableTestCommands=1 |
16 | 25 | echo "mongodb://localhost:27017"
|
17 | 26 | else
|
18 | 27 | echo "unsupported topology: $1"
|
|
0 commit comments