I had a mongodb instance which was up as a replicaset and was a single node in the replicaset. Now I have added to other replicasets each with one node and connected them to clutser through mongos using addShard
command, enabled sharding on a db using enableSharding
command and sharded a collection using shardCollection
. However when I run sh.status the
output says that I have no chunk and also my data did not get balanced. Is there anything wrong?
mongodb version: 6.0.2
mongodb sh.status() results:
[direct: mongos]> sh.status()
shardingVersion
{
_id: 1,
minCompatibleVersion: 5,
currentVersion: 6,
clusterId: ObjectId("64d62ba7e9d199311e7be6b5")
}
---
shards
[
{
_id: 'myshard1',
host: 'myshard1/node3:27018',
state: 1,
topologyTime: Timestamp(6, 1691758010)
},
{
_id: 'myshard2',
host: 'myshard2/node2:27018',
state: 1,
topologyTime: Timestamp(206, 1691773056)
},
{
_id: 'myshard3',
host: 'myshard3/node1:27018',
state: 1,
topologyTime: Timestamp(51, 1691773082)
}
]
---
active mongoses
[ { '6.0.4': 1 } ]
---
autosplit
{ 'Currently enabled': 'yes' }
---
balancer
{
'Currently enabled': 'yes',
'Currently running': 'no',
'Failed balancer rounds in last 5 attempts': 0,
'Migration Results for the last 24 hours': {
'3': "Failed with error 'aborted', from myshard3 to myshard1",
'30': "Failed with error 'aborted', from myshard1 to myshard2",
'157': "Failed with error 'aborted', from myshard1 to myshard3",
'2669': 'Success'
}
}
---
databases
[
{
database: {
_id: 'mydb',
primary: 'myshard1',
partitioned: false,
version: {
uuid: UUID("2dcac9aa-595c-4515-8033-27298507f20c"),
timestamp: Timestamp(1, 1691758436),
lastMod: 1
}
},
collections: {
'mydb.user': {
shardKey: { _id: 1 },
unique: false,
balancing: true,
chunks: [],
tags: []
}
}
},
{
database: { _id: 'config', primary: 'config', partitioned: true },
collections: {
'config.system.sessions': {
shardKey: { _id: 1 },
unique: false,
balancing: true,
chunks: [],
tags: []
}
}
}
]
getShardDistribution on sharded collection:
[direct: mongos]> db.user.getShardDistribution()
Shard myshard1 at myshard1/node3:27018
{
data: '248.01GiB',
docs: 210646,
chunks: 0,
'estimated data per chunk': '0B',
'estimated docs per chunk': 0
}
---
Shard myshard3 at myshard3/node1:27018
{
data: '249.23GiB',
docs: 44758,
chunks: 0,
'estimated data per chunk': '0B',
'estimated docs per chunk': 0
}
---
Shard myshard2 at myshard2/node2:27018
{
data: '248.63GiB',
docs: 65768,
chunks: 0,
'estimated data per chunk': '0B',
'estimated docs per chunk': 0
}
---
Totals
{
data: '745.88GiB',
docs: 321172,
chunks: 0,
'Shard myshard1': [
'33.25 % data',
'65.58 % docs in cluster',
'1.2MiB avg obj size on shard'
],
'Shard myshard3': [
'33.41 % data',
'13.93 % docs in cluster',
'5.7MiB avg obj size on shard'
],
'Shard myshard2': [
'33.33 % data',
'20.47 % docs in cluster',
'3.87MiB avg obj size on shard'
]
}
also my data size is the following which is not balanced:
14G node1
15G node2
33G node3
Can anyone please help me with this?