Replica Shard Cluster

30 views
Skip to first unread message

Thiago Hernandes

unread,
Feb 26, 2015, 3:12:27 PM2/26/15
to mongod...@googlegroups.com
I have the code:

-- REPLICA SHARD 1
mongod --replSet rs1 --logpath C:\mongodb\case4\log\log0.txt --dbpath c:\mongodb\case4\shard0\rs0 --port 37017 --shardsvr  --smallfiles
mongod --replSet rs1 --logpath C:\mongodb\case4\log\log1.txt --dbpath c:\mongodb\case4\shard0\rs1 --port 37018 --shardsvr  --smallfiles
mongod --replSet rs1 --logpath C:\mongodb\case4\log\log2.txt --dbpath c:\mongodb\case4\shard0\rs2 --port 37019 --shardsvr  --smallfiles
mongo --port 37017
config = { _id: "rs1", members:[{ _id : 0, host : "localhost:37017" },{ _id : 1, host : "localhost:37018" },{ _id : 2, host : "localhost:37019" }]};

rs.initiate(config)

-- REPLICA SHARD 2
mongod --replSet rs2 --logpath C:\mongodb\case4\log\log3.txt --dbpath c:\mongodb\case4\shard1\rs0 --port 40017 --shardsvr  --smallfiles
mongod --replSet rs2 --logpath C:\mongodb\case4\log\log4.txt --dbpath c:\mongodb\case4\shard1\rs1 --port 40018 --shardsvr  --smallfiles
mongod --replSet rs2 --logpath C:\mongodb\case4\log\log5.txt --dbpath c:\mongodb\case4\shard1\rs2 --port 40019 --shardsvr  --smallfiles
mongo --port 40017
config = { _id: "rs2", members:[{ _id : 0, host : "localhost:40017" },{ _id : 1, host : "localhost:40018" },{ _id : 2, host : "localhost:40019" }]};

rs.initiate(config)

-- REPLICA SHARD 3
mongod --replSet rs3 --logpath C:\mongodb\case4\log\log6.txt --dbpath c:\mongodb\case4\shard2\rs0 --port 50017 --shardsvr  --smallfiles
mongod --replSet rs3 --logpath C:\mongodb\case4\log\log7.txt --dbpath c:\mongodb\case4\shard2\rs1 --port 50018 --shardsvr  --smallfiles
mongod --replSet rs3 --logpath C:\mongodb\case4\log\log8.txt --dbpath c:\mongodb\case4\shard2\rs2 --port 50019 --shardsvr  --smallfiles
mongo --port 50017
config = { _id: "rs3", members:[{ _id : 0, host : "localhost:50017" },{ _id : 1, host : "localhost:50018" },{ _id : 2, host : "localhost:50019" }]};

rs.initiate(config)


-- ADD CONFIGS
mongod --logpath c:\mongodb\case4\config\1\logconfig-a.txt --dbpath c:\mongodb\case4\config\1 --port 57040 --configsvr --smallfiles
mongod --logpath c:\mongodb\case4\config\2\logconfig-b.txt --dbpath c:\mongodb\case4\config\2 --port 57041 --configsvr --smallfiles
mongod --logpath c:\mongodb\case4\config\3\logconfig-c.txt --dbpath c:\mongodb\case4\config\3 --port 57042 --configsvr --smallfiles

mongos --logpath c:\mongodb\case4\start\mongos.log --configdb localhost:57040

-- ADD SHARDS
mongo 
db.adminCommand({addShard : "rs1/"+"localhost:37017"})
db.adminCommand({addShard : "rs2/"+"localhost:40017"})
db.adminCommand({addShard : "rs3/"+"localhost:50017"})

db.adminCommand({enableSharding: "dbcarros"})
db.adminCommand({shardCollection: "dbcarros.fabricantes", key: {_id:1}});
db.adminCommand({shardCollection: "dbcarros.carros", key: {_id:1}});

For ports: 40017 and 50017 works correctly replication / shard. Only for port 30017 and its shards does not recognize the database and collection.
Any tips?

Alberto Frosi

unread,
Feb 27, 2015, 4:01:48 AM2/27/15
to mongod...@googlegroups.com
Hi Thiago,
do you have problem to add shard for port 37017 ? not for 30017 I think...
Do you have take a look in log file ?
Alberto
Reply all
Reply to author
Forward
0 new messages