Created
June 15, 2018 05:56
-
-
Save sarjarapu/10690ca684cfd3258d11602d16f4c2ae to your computer and use it in GitHub Desktop.
A bash script to initiate a replica set with 3 hosts we created earlier
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_VERSION/bin/mongo --port 27000 <<EOF | |
rs.initiate({ | |
_id: 'rs0', | |
members: [ | |
{ _id: 0, host : 'mon01:27000' }, | |
{ _id: 1, host : 'mon02:27000' }, | |
{ _id: 2, host : 'mon03:27000' } | |
] }) | |
EOF | |
# MongoDB shell version v3.6.5 | |
# connecting to: mongodb://127.0.0.1:27000/ | |
# MongoDB server version: 3.6.5 | |
# { | |
# "ok" : 1, | |
# "operationTime" : Timestamp(1529022819, 1), | |
# "$clusterTime" : { | |
# "clusterTime" : Timestamp(1529022819, 1), | |
# "signature" : { | |
# "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), | |
# "keyId" : NumberLong(0) | |
# } | |
# } | |
# } | |
# bye | |
$BIN_VERSION/bin/mongo --port 27000 | |
# rs0:PRIMARY> | |
rs.isMaster().me | |
# mon01:27000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment