Skip to content

Instantly share code, notes, and snippets.

@sarjarapu
Created June 15, 2018 05:53
Show Gist options
  • Save sarjarapu/8163ca45993b2ada286b8f20888ac2b0 to your computer and use it in GitHub Desktop.
Save sarjarapu/8163ca45993b2ada286b8f20888ac2b0 to your computer and use it in GitHub Desktop.
A bash script with download MongoDB v3.6.5 and start mongod on port 27000
# Run these commands on all the 3 servers of yours.
# download v3.6
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.5.tgz
BIN_NAME="mongodb-linux-x86_64-rhel70-3.6.5"
BIN_VERSION="v3.6.5"
# create data directory and untar the binaries
tar -xvzf "$BIN_NAME.tgz"
rm "$BIN_NAME.tgz"
mv $BIN_NAME $BIN_VERSION
rm -rf data
mkdir data
# start the mongod on port 27000 with bind_ip_all
$BIN_VERSION/bin/mongod --dbpath data --logpath data/mongod.log --fork --replSet rs0 --port 27000 --bind_ip_all
# about to fork child process, waiting until server is ready for connections.
# forked process: 13442
# child process started successfully, parent exiting
# edit /etc/hosts to have the mon0X entries, ofcourse with your own IPs
tail -3 /etc/hosts
# 35.167.113.204 mon01
# 35.167.113.203 mon02
# 35.167.113.206 mon03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment