-- Check mongoDB version
> db.version();
3.0.1
--default conf file location
/etc/mongod.conf
--default utility loc
ls -l /usr/bin/mongo*
> db.version();
3.0.1
--default conf file location
/etc/mongod.conf
--default utility loc
ls -l /usr/bin/mongo*
-- Run JSON file from Shell prompt
# mongo --port <port#> <filename>
-- Run commands from shell
mongo --port 27107 --eval "\
rs.initiate(); sleep(3000);\
rs.add ('<HOSTNAME>:27108');\
rs.addArb('<HOSTNAME>:27109')"
(or)
echo 'sh.addShard( "shard0/localhost:27107" ); \
sh.addShard("shard1/localhost:27117" ); \
sh.addShard( "shard2/localhost:27127" ); sh.status()' | mongo
(or)
echo 'for (i=0; i<10000; i++) { docArr = []; for (j=0; j<1000; j++) { \
docArr.push( { a : i, b : j, c : "Filler String 000000000000000000000 \
000000000000000000000000000000000000000000000000000000000000000000 \
000000000000000" } ) }; db.testcol.insert(docArr) }' | mongo
# mongo --port 27004 repl.status.js
MongoDB shell version: 3.0.1
connecting to: 127.0.0.1:27004/test
optime diff: 0
optimeDate diff: 0
-- Run JSON file from mongo prompt
> load("repl.status.js")
optime diff: 0
optimeDate diff: 0
true
-- Run commands from shell
mongo --port 27107 --eval "\
rs.initiate(); sleep(3000);\
rs.add ('<HOSTNAME>:27108');\
rs.addArb('<HOSTNAME>:27109')"
(or)
echo 'sh.addShard( "shard0/localhost:27107" ); \
sh.addShard("shard1/localhost:27117" ); \
sh.addShard( "shard2/localhost:27127" ); sh.status()' | mongo
(or)
echo 'for (i=0; i<10000; i++) { docArr = []; for (j=0; j<1000; j++) { \
docArr.push( { a : i, b : j, c : "Filler String 000000000000000000000 \
000000000000000000000000000000000000000000000000000000000000000000 \
000000000000000" } ) }; db.testcol.insert(docArr) }' | mongo
--hidden:true ["priority must be 0 when hidden=true"]
I have 4 hosts in replicat set as shown in "rs.conf"
rs0:PRIMARY> rs.conf().members.length
4
Where as "db.isMaster" showing only 3 hosts.
rs0:PRIMARY> db.isMaster().hosts
[
"hostd001:27001",
"hostd001:27002",
"hostd001:27003"
]
I have 4 hosts in replicat set as shown in "rs.conf"
rs0:PRIMARY> rs.conf().members.length
4
Where as "db.isMaster" showing only 3 hosts.
rs0:PRIMARY> db.isMaster().hosts
[
"hostd001:27001",
"hostd001:27002",
"hostd001:27003"
]
Further digging in conf shows that node4 is defined as "hidden".
"host" : "sl73vcasvdbd001:27004", "hidden" : true
Hence "db.isMaster" is not showing it.
--Collections in 'local' database are not replicated.
Hence "db.isMaster" is not showing it.
--Collections in 'local' database are not replicated.
No comments:
Post a Comment