not talking to master and retries used up
在Replica sets 中的secondary节点默认是不可读的。
使用Replica Sets实现读写分离。通过在连接时指定或者在主库指定slaveOk,由Secondary来分担读的压力,Primary只承担写操作。
在secondary上,访问mongo,进行查询。会出现如下错误:
rs:SECONDARY> db.sponsor.find();
Error: error: { "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435 }
一、使用shell有两种方法实现secondary的查询:
1、
> db.getMongo().setSlaveOk();
2、
echo "rs.slaveOk();" > ~/.mongorc.js
这样连接后,可以直接查询。
二、通过Java访问secondary
异常:
com.mongodb.MongoException: not talking to master and retries used up
1、
dbFactory.getDb().slaveOk();
2、
dbFactory.getDb().setReadPreference(ReadPreference.secondaryPreferred());
//在复制集中优先读secondary,如果secondary访问不了的时候就从master中读
或
dbFactory.getDb().setReadPreference(ReadPreference.secondary());
//只从secondary中读,如果secondary访问不了的时候就不能进行查询
3、
在配置mongo的时候增加slave-ok="true",支持直接从secondary中读。
<mongo:options slave-ok="true"/>
分享到:
相关推荐
- Changes to trace logging to reduce activity when trace logging is not turned on. - Note: We have seen a report of the Video Playback failing (crash) due to a faulty video codec, ffdshow.ax. If ...
Previous revisions did not range-check the palette index number, and hard crashes could be produced if out-of-range values were supplied to this routine. Previous release 1.33b Release date: ...
Kafka Retries项目的源代码存放在名为"kafka-retries-master"的压缩包中。这个master分支代表了项目的主开发线,包含了所有最新的特性和改进。用户可以克隆或下载这个分支,根据自己的需求进行定制和集成。 总的来...
springboot+dubbo timeout retries 验证 原文地址 https://blog.csdn.net/u013151053/article/details/116949588
Maximum amount of retries reached爬虫fake_useragent获取ua代理报错教程及资源大全
applied to the anonymous profile can be retained and used in future anonymous profiles. The implication is that the user can now make modifications to a profile, and retain those profile ...
If a collision occurs, the node waits and retries after a random backoff period. The statement "In CSMA/CD, one node" is incomplete, but it highlights the mechanism of carrier sensing and collision ...
AM3359开发板,IAR,JLINK 调试步骤清晰,速度很好很快。
Developers can customize the serialization process used by the client to encode and decode data sent between the client and Elasticsearch. This is useful for handling non-standard data formats or ...
retries : 重试的次数。 在 vanilla 节点中的用法: var retry = require ( 'promise-retries' ) ; retry ( options , function ( retryInterval ) { return new Promise ( function ( ) { // } ) ; } ) . ...
- `--retries <retries>`:每个连接的最大重试次数,默认为5次。 - `--timeout <sec>`:设置socket超时时间,默认15秒。 - `--exists-action <action>`:处理已存在文件或目录的默认动作。 使用pip时,还可以通过...
title: Kafka6# Producer重试参数retries设置取舍retries参数说明参数的设置通常是一种取舍,看下retries参数在版本0.11
更新08/25/20: 从赛普拉斯插件重试迁移到赛普拉斯5.0.0: 从devDependencies和支持/插件文件中的相关代码中删除...要全局启用重试,请在cypress.json设置retries ,而不要使用Cypress.env('RETRIES')例如: { "re
Fix Rate - Show graph data only up to "Max Rate" and don't allow automatic scaling. Log File: Write Data - enables/disables logging. To Log File - specifies file for logging. Rotate N Log ...
Sidekiq ::重试 这将对股票Sidekiq重试中间件进行子分类,以便您可以 重试已禁用重试的作业(重试:0或重试:... # retry this job when it otherwise would not raise Sidekiq::Retries::Retry.new(RuntimeError
fix duplicate retry, change DEFAULT_MAX_RETRIES to 0 merge pr, fix NegativeArraySizeException merge upstream, Use a BufferedOutputStream to read and write cache 1.0.15 2015.03.18 add two missing...
Modbus RTU是一种广泛应用于工业自动化领域的通信协议,它允许设备...根据实际网络条件和设备性能,合理设置`RESP_TO`、`RETRIES`和`Blocked_Proc_Timeout`,可以提高通信效率,减少因从站故障或延迟引起的通信问题。
- Analyze the number of fail bits and read retries required per page to determine the reliability of the memory device. ### Conclusion The Samsung test procedures outlined above are critical for ...
一、报错error connecting to master ‘x@x.x.x.x:x’ – retry-time: 60 retries: 86400 今天搭建mysql主从复制,一直报这个错。我是在一台虚拟机上使用多实例创建的2个不同端口的数据库,查了很久,才解决。 1....