0
現在の設定で2台の設定サーバーと2台のシャードと1台のルータがあります。私はすべてのログから、彼らはすべて接続されていることがわかります。
私は 'testdb'という新しいデータベースを作成しました。私は 'testdb'のシャーディングを有効にし、 'testdb'のコレクションに挿入しようとしました。私はそれを試みると、私はエラーが発生します。別の奇妙なことは、私が 'show dbs'を試してみると、データベース 'testdb'が表示されないということです。以下は、端末のビューです。シャードされたmongodbデータベースに挿入中にエラーが発生しました
mongos> use testdb
switched to db testdb
mongos> sh.enableSharding("testdb")
{ "ok" : 1 }
mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("59d1c43767d73804222be772")
}
shards:
{ "_id" : "ReplicaSet", "host" : "ReplicaSet/192.168.1.3:20011,192.168.1.3:20012", "state" : 1 }
active mongoses:
"3.4.1" : 1
autosplit:
Currently enabled: yes
balancer:
Currently enabled: yes
Currently running: no
Balancer lock taken at Mon Oct 02 2017 10:14:40 GMT+0530 (IST) by ConfigServer:Balancer
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
No recent migrations
databases:
{ "_id" : "testdb", "primary" : "ReplicaSet", "partitioned" : true }
mongos> db.testcoll.insert({_id:1,name:"testvalue"})
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 193,
"errmsg" : "Cannot accept sharding commands if not started with --shardsvr"
}
})
mongos> show dbs
admin 0.000GB
config 0.000GB
mongos> db
testdb
のconfigサーバのステータスは以下のとおりです。破片の
ReplicaSet:PRIMARY> rs.status()
{
"set" : "ReplicaSet",
"date" : ISODate("2017-10-02T05:33:42.973Z"),
"myState" : 1,
"term" : NumberLong(1),
"configsvr" : true,
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1506922413, 1),
"t" : NumberLong(1)
},
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1506922413, 1),
"t" : NumberLong(1)
},
"appliedOpTime" : {
"ts" : Timestamp(1506922413, 1),
"t" : NumberLong(1)
},
"durableOpTime" : {
"ts" : Timestamp(1506922413, 1),
"t" : NumberLong(1)
}
},
"members" : [
{
"_id" : 0,
"name" : "192.168.1.3:20002",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 3048,
"optime" : {
"ts" : Timestamp(1506922413, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2017-10-02T05:33:33Z"),
"electionTime" : Timestamp(1506919478, 1),
"electionDate" : ISODate("2017-10-02T04:44:38Z"),
"configVersion" : 1,
"self" : true
},
{
"_id" : 1,
"name" : "192.168.1.3:20003",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 2954,
"optime" : {
"ts" : Timestamp(1506922413, 1),
"t" : NumberLong(1)
},
"optimeDurable" : {
"ts" : Timestamp(1506922413, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2017-10-02T05:33:33Z"),
"optimeDurableDate" : ISODate("2017-10-02T05:33:33Z"),
"lastHeartbeat" : ISODate("2017-10-02T05:33:42.557Z"),
"lastHeartbeatRecv" : ISODate("2017-10-02T05:33:42.557Z"),
"pingMs" : NumberLong(0),
"syncingTo" : "192.168.1.3:20002",
"configVersion" : 1
}
],
"ok" : 1
}
状況:私は間違っているつもりです
ReplicaSet:PRIMARY> rs.status()
{
"set" : "ReplicaSet",
"date" : ISODate("2017-10-02T05:39:08.968Z"),
"myState" : 1,
"term" : NumberLong(1),
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1506922743, 1),
"t" : NumberLong(1)
},
"appliedOpTime" : {
"ts" : Timestamp(1506922743, 1),
"t" : NumberLong(1)
},
"durableOpTime" : {
"ts" : Timestamp(1506922743, 1),
"t" : NumberLong(1)
}
},
"members" : [
{
"_id" : 0,
"name" : "192.168.1.3:20011",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 3355,
"optime" : {
"ts" : Timestamp(1506922743, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2017-10-02T05:39:03Z"),
"electionTime" : Timestamp(1506919442, 1),
"electionDate" : ISODate("2017-10-02T04:44:02Z"),
"configVersion" : 1,
"self" : true
},
{
"_id" : 1,
"name" : "192.168.1.3:20012",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 3317,
"optime" : {
"ts" : Timestamp(1506922743, 1),
"t" : NumberLong(1)
},
"optimeDurable" : {
"ts" : Timestamp(1506922743, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2017-10-02T05:39:03Z"),
"optimeDurableDate" : ISODate("2017-10-02T05:39:03Z"),
"lastHeartbeat" : ISODate("2017-10-02T05:39:08.532Z"),
"lastHeartbeatRecv" : ISODate("2017-10-02T05:39:07.254Z"),
"pingMs" : NumberLong(0),
"syncingTo" : "192.168.1.3:20011",
"configVersion" : 1
}
],
"ok" : 1
}
?