我正在使用Mongo java异步驱动程序v3.2使用以下测试。我可以看到调用了回调(在Mongo集合上使用insertOne调用注册的回调)。我可以看到测试客户端能够连接到mongos进程(最后附加的日志)。我在Mongo看不到任何文件。我启用了数据库集合以进行分片,我也可以从mongos进程运行shard status命令。关于我在设置中可能配置错误的想法?
CountDownLatch latch = new CountDownLatch(1);
SingleResultCallback<Void> callbackWhenFinished = new SingleResultCallback<Void>() {
@Override
public void onResult(final Void result, final Throwable t) {
System.out.println("Operation Finished!");
latch.countDown();
}
};
final Document doc = new Document("name", "MongoDB")
.append("type", "database")
.append("count", 1)
.append("info", new Document("x", 203).append("y", 102));
collection.insertOne(doc, callbackWhenFinished);
latch.await();
Mongo日志:
this host as shard shard0002, but shard name was previously initialized as shard0001" } }
2016-07-20T12:02:52.682-0400 I NETWORK [mongosMain] connection accepted from 127.0.0.1:44633 #42 (1 connection now open)
2016-07-20T12:02:52.715-0400 I NETWORK [mongosMain] connection accepted from 127.0.0.1:44635 #43 (2 connections now open)
2016-07-20T12:02:52.750-0400 I NETWORK [conn42] end connection 127.0.0.1:44633 (1 connection now open)
2016-07-20T12:02:52.750-0400 I NETWORK [conn43] end connection 127.0.0.1:44635 (0 connections now open)
2016-07-20T12:02:57.279-0400 I SHARDING [Balancer] caught exception while doing balance: remote client 127.0.0.1:40696 tried to initialize this host as shard shard0002, but shard name was previously initialized as shard0001
2016-07-20T12:02:57.279-0400 I SHARDING [Balancer] about to log metadata event into actionlog: { _id: "ali-HP-ENVY-m7-Notebook-2016-07-20T12:02:57.279-0400-578fa0b154165752fe990d83", server: "ali-HP-ENVY-m7-Notebook", clientAddr: "", time: new Date(1469030577279), what: "balancer.round", ns: "", details: { executionTimeMillis: 5, errorOccured: true, errmsg: "remote client 127.0.0.1:40696 tried to initialize this host as shard shard0002, but shard name was previously initialized as shard0001" } }
2016-07-20T12:03:07.334-0400 I SHARDING [Balancer] caught exception while doing balance: remote client 127.0.0.1:40704 tried to initialize this host as shard shard0002, but shard name was previously initialized as shard0001
2016-07-20T12:03:07.335-0400 I SHARDING [Balancer] about to log metadata event into actionlog: { _id: "ali-HP-ENVY-m7-Notebook-2016-07-20T12:03:07.335-0400-578fa0bb54165752fe990d84", server: "ali-HP-ENVY-m7-Notebook", clientAddr: "", time: new Date(1469030587335), what: "balancer.round", ns: "", details: { executionTimeMillis: 3, errorOccured: true, errmsg: "remote client 127.0.0.1:40704 tried to initialize this host as shard shard0002, but shard name was previously initialized as shard0001" } }
答案 0 :(得分:0)
通过确保正确配置mongo群集(查询路由器,cofig服务器和具有副本集的mongo分片)解决了该问题。完成此操作后,我可以看到插入被添加到分片(以及达到迁移阈值后的多个分片)。希望它能帮助别人