0

我的mongo-java-driver是3.12.10,

mongdodb版本是6.0.4,配置的分片集群 ,
mongodb-driver-sync版本是4.6.1
在设置分片键的时候出现以下报错:
com.mongodb.MongoCommandException: Command failed with error 59 (CommandNotFound): 'no such command: 'shardCollection'' on server xxx:27018. The full response is {"ok": 0.0, "errmsg": "no such command: 'shardCollection'", "code": 59, "codeName": "CommandNotFound", "lastCommittedOpTime": {"$timestamp": {"t": 1688634311, "i": 1}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1688634317, "i": 3}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "operationTime": {"$timestamp": {"t": 1688634311, "i": 1}}}

以下是我的命令:

Document append = new Document("shardCollection", new BsonString(dataBase + "." + collect)).append("key", new Document("_id", "hashed"));

admin.runCommand(append);

有人可以帮忙答疑吗?非常感谢

更改状态以发布