`
男人50
  • 浏览: 237299 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

not talking to master and retries used up

 
阅读更多
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"/>
1
0
分享到:
评论

相关推荐

    BURNINTEST--硬件检测工具

    - 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 ...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    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重试逻辑添加到您的项目中

    Kafka Retries项目的源代码存放在名为"kafka-retries-master"的压缩包中。这个master分支代表了项目的主开发线,包含了所有最新的特性和改进。用户可以克隆或下载这个分支,根据自己的需求进行定制和集成。 总的来...

    springboot+dubbo timeout retries 验证

    springboot+dubbo timeout retries 验证 原文地址 https://blog.csdn.net/u013151053/article/details/116949588

    fake_useragent获取ua代理报错Maximum amount of retries reached.html

    Maximum amount of retries reached爬虫fake_useragent获取ua代理报错教程及资源大全

    selenium-dotnet-2.45.0.zip

    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 ...

    计算机网络英文题库(附答案)chapter5.pdf

    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 ...

    IAR使用JLINK仿真器调试TI CORTEX-A8开发板

    AM3359开发板,IAR,JLINK 调试步骤清晰,速度很好很快。

    elasticsearch-py-readthedocs-io-en-7.7.1.pdf

    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 ...

    promise-retries:重试返回承诺的函数

    retries : 重试的次数。 在 vanilla 节点中的用法: var retry = require ( 'promise-retries' ) ; retry ( options , function ( retryInterval ) { return new Promise ( function ( ) { // } ) ; } ) . ...

    Python开发之pip安装及使用方法详解

    - `--retries &lt;retries&gt;`:每个连接的最大重试次数,默认为5次。 - `--timeout &lt;sec&gt;`:设置socket超时时间,默认15秒。 - `--exists-action &lt;action&gt;`:处理已存在文件或目录的默认动作。 使用pip时,还可以通过...

    yongliangcode#myArticle#Kafka6# Producer重试参数retries设置取舍1

    title: Kafka6# Producer重试参数retries设置取舍retries参数说明参数的设置通常是一种取舍,看下retries参数在版本0.11

    cypress-plugin-retries:一个赛普拉斯插件,可重试失败的测试

    更新08/25/20: 从赛普拉斯插件重试迁移到赛普拉斯5.0.0: 从devDependencies和支持/插件文件中的相关代码中删除...要全局启用重试,请在cypress.json设置retries ,而不要使用Cypress.env('RETRIES')例如: { "re

    STG (SNMP Traffic Grapher)

    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-retries:适用于Sidekiq的增强的重试中间件

    Sidekiq ::重试 这将对股票Sidekiq重试中间件进行子分类,以便您可以 重试已禁用重试的作业(重试:0或重试:... # retry this job when it otherwise would not raise Sidekiq::Retries::Retry.new(RuntimeError

    Github-volley 最新jar包和源代码 2015.07.28

    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 通信连接超时参数.docx

    Modbus RTU是一种广泛应用于工业自动化领域的通信协议,它允许设备...根据实际网络条件和设备性能,合理设置`RESP_TO`、`RETRIES`和`Blocked_Proc_Timeout`,可以提高通信效率,减少因从站故障或延迟引起的通信问题。

    Samsung Test Procedure

    - 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 ...

    Mysql主从复制注意事项的讲解

    一、报错error connecting to master ‘x@x.x.x.x:x’ – retry-time: 60 retries: 86400 今天搭建mysql主从复制,一直报这个错。我是在一台虚拟机上使用多实例创建的2个不同端口的数据库,查了很久,才解决。 1....

Global site tag (gtag.js) - Google Analytics