Created
January 16, 2015 01:24
-
-
Save akira-kurogane/fe30701867026ac7d63d to your computer and use it in GitHub Desktop.
Bash script to launch three single mongo shard dbs, three configs, a mongos, and add the shards as initialization.
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
#!/bin/bash | |
set -e | |
set -x | |
hn=$(hostname -s) | |
dbpath=${HOME}/fresh_shard_cluster | |
mkdir ${dbpath} ${dbpath}/shard0{1,2,3} ${dbpath}/shard0{1,2,3}/db ${dbpath}/config{1,2,3} ${dbpath}/config{1,2,3}/db | |
if [ ! -f ${dbpath}/keyfile ]; then | |
openssl rand -base64 741 > ${dbpath}/keyfile | |
chmod 600 ${dbpath}/keyfile | |
fi | |
mongod --dbpath ${dbpath}/shard01/db --logpath ${dbpath}/shard01/mongod.log --port 27018 --fork --keyFile ${dbpath}/keyfile | |
mongod --dbpath ${dbpath}/shard02/db --logpath ${dbpath}/shard02/mongod.log --port 27019 --fork --keyFile ${dbpath}/keyfile | |
mongod --dbpath ${dbpath}/shard03/db --logpath ${dbpath}/shard03/mongod.log --port 27020 --fork --keyFile ${dbpath}/keyfile | |
mongod --dbpath ${dbpath}/config1/db --logpath ${dbpath}/config1/mongod.log --port 27021 --fork --keyFile ${dbpath}/keyfile --configsvr | |
mongod --dbpath ${dbpath}/config2/db --logpath ${dbpath}/config2/mongod.log --port 27022 --fork --keyFile ${dbpath}/keyfile --configsvr | |
mongod --dbpath ${dbpath}/config3/db --logpath ${dbpath}/config3/mongod.log --port 27023 --fork --keyFile ${dbpath}/keyfile --configsvr | |
mongos --logpath ${dbpath}/mongos.log --configdb ${hn}:27021,${hn}:27022,${hn}:27023 --keyFile ${dbpath}/keyfile --fork | |
mongo --eval "sh.addShard('${hn}:27018'); sh.addShard('${hn}:27019'); sh.addShard('${hn}:27020')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, Akira Kurogane, thank you for your time to answer my question in StactOverflow. The log file mongos.log in the mongos's log path, showed the reason for that error.
But I don't know how to going on with this error message to sovle this problem. Can you give me some suggestions according it? very thankful again.