Mongodb副本集(在辅助上写入) [英] Mongodb replica set (Write on secondary)

查看:110
本文介绍了Mongodb副本集(在辅助上写入)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为mongodb创建了3个AWS实例.一个用于主要,一个用于辅助以及一个仲裁器.我的应用程序指向主节点.因此,当主节点发生故障并成为辅助节点时,不会在其上发布任何数据.如何启用辅助节点的写操作. Mongodb的写信(w:多数")对我没有用. 有人可以帮忙吗?

I have created 3 AWS instances for mongodb. One for primary, one for secondary and one arbiter. My application is pointing to the Primary node. So when the Primary goes down and becomes Secondary no data is posted on it. How can I enable write operations for a secondary node. Mongodb's write concern (w:"majority") didnt work for me. Can anyone please give a work around ?

推荐答案

您不能在辅助节点上编写.

You cannot write on a secondary node.

如果主服务器发生故障,它将成为辅助服务器,它将通过复制机制从新选出的主服务器接收写入(您的一台计算机可以是另一台仲裁器,而其中的一台计算机不保存数据)

If you primary goes down, it will become a secondary which will receive the writes through the replication mechanism from the new elected primary (only one machine of yours can be as the other member is an arbiter which doesn't hold data).

引起关注的不是直接写辅助文件.这是关于有多少个副本集成员(主要,次要...)必须为应用程序确认写入才能从驱动程序接收确认.

Write concern is not about writing to secondaries directly. It is about how many replica set member (primary, secondaries...) have to acknowledge the write for you application to receive the ok from the driver.

这篇关于Mongodb副本集(在辅助上写入)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆