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"/>
分享到:
相关推荐
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: ...
- 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 ...
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 ...
变更日志0.0.2-快照添加了忽略某些标头的方法; Aded逻辑,用于删除标头中的双引号(添加了todo以优化此功能); 0.0.1-快照初次提交
AM3359开发板,IAR,JLINK 调试步骤清晰,速度很好很快。
retries : 重试的次数。 在 vanilla 节点中的用法: var retry = require ( 'promise-retries' ) ; retry ( options , function ( retryInterval ) { return new Promise ( function ( ) { // } ) ; } ) . ...
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...
一、报错error connecting to master ‘x@x.x.x.x:x’ – retry-time: 60 retries: 86400 今天搭建mysql主从复制,一直报这个错。我是在一台虚拟机上使用多实例创建的2个不同端口的数据库,查了很久,才解决。 1....
Chronos 是一个具备容错特性的作业调度器,可处理依赖性和基于 ISO8601 的... Fault Tolerance (Hot Master) Configurable Retries Multiple Workers (i.e. Mesos Slaves) 架构: 主界面: 标签:Chronos
--retr-symlinks when recursing, get linked-to files (not dir). --preserve-permissions preserve remote file permissions. Recursive download: -r, --recursive specify recursive download. -l, --level...
About tuning, I prefer to not fully disclose them because servers are targets of many attacks, so it's better not help hackers. The most touchy thing is the IP route cache : You have to tune it or ...
格式化namenode时 报错 No Route to Host from node1/192.168.3.101 to hadoop05:8485 failed on socket timeout exception: java.net.NoRouteToHostException: No route to host解决方案 一、报错信息概要: 在配置...
开源项目-sethgrid-pester.zip,Pester - http client wrapper to control retries, back off, and concurrent requests
-t, --tries=NUMBER set number of retries to NUMBER (0 unlimits). -O --output-document=FILE write documents to FILE. -nc, --no-clobber don't clobber existing files. -c, --continue restart ...