0

this is Log txt

error:[_47Baby.DBModule.Fun1.FunDB2.InserPlayer]Safemode detected an error 'not master'. (Response was { "err" : "not master", "code" : 10054, "n" : 0, "connectionId" : 7, "ok" : 1.0 }).

The setup is 1 master, and 2 slaves.

One of the slave read is success,but another slave is error, the message is Safemode detected an error 'not master'.

I have already setting the server string "mongodb://**/databasename?safe=true;slaveok=true"

4

2 回答 2

1

当您遇到此异常时,您调用了什么驱动程序方法?并非所有操作都能够发送到从站。

您是否在连接字符串(“**”部分)上放置了一个主机名?或者您是否放置了一个包含多个副本集成员的种子列表?

如果您可以提供一个堆栈跟踪,这也会有所帮助。

于 2012-05-02T15:07:39.120 回答
0

从 MongoDB v2.2 开始,它现在允许使用另一种方法来允许从 slave/secondary 读取,这使您可以更好地控制发生的事情。请参阅阅读首选项

因此,这可能会引起您的兴趣,并且可能比使用服务器字符串参数效果更好。

(以下是 Java 驱动程序的示例,但对于 C# 应该足够接近)

这种新方法的基础是将一个类型传递给ReadPreference您用来查询数据库的 DBCursor。

ReadPreference preference = ReadPreference.secondaryPreferred();
DBCursor cursor = new DBCursor(collection, query, null, preference);

来源:阅读偏好模式¶

于 2013-12-08T02:46:25.973 回答