ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

c#-主要故障,现在是辅助故障主要-如何写入新的主要故障?

2019-11-27 19:56:24  阅读:220  来源: 互联网

标签:mongodb pymongo python c


如果我在一个MongoDB副本集上设置了3个节点(Primary,Secondary,Arbiter),Primary节点出现故障,现在Secondary假设是Primary,那么如何动态处理客户端中的更改,以便它们现在可以写入Primary?

我在开发环境中经历了这一点,并开始思考处理此问题的最佳方法.这不是分片群集,只是一个独立的副本集.

您是否在连接中检查了诸如“ IsPrimary”之类的内容,以便您不更改书写位置?

任何建议,将不胜感激.

谢谢,

小号

解决方法:

设置连接后,驱动程序应足够聪明,以理清应将数据发送到哪个节点.

For the C# driver

To connect to a replica set specify the seed list by providing
multiple hostnames (and port numbers if required) separated by commas.
For example:

mongodb://server1,server2:27017,server2:27018

For the Python driver

A connection to a replica set can be made using the normal
Connection() constructor, specifying one or more members of the set.
For example, any of the following will create a connection to the set
we just created:

Connection("morton.local", replicaset='foo')
Connection([u'morton.local:27019', 'morton.local:27017', u'morton.local:27018'])
Connection("morton.local:27018", replicaset='foo')
Connection([u'morton.local:27019', u'morton.local:27017', 'morton.local:27018'])
Connection("morton.local", 27019, replicaset='foo')
Connection(['morton.local:27019', u'morton.local:27017', u'morton.local:27018'])
Connection(["morton.local:27018", "morton.local:27019"])
Connection(['morton.local:27019', u'morton.local:27017', 'morton.local:27018'])
Connection("mongodb://morton.local:27017,morton.local:27018,morton.local:27019")
Connection(['morton.local:27019', 'morton.local:27017', 'morton.local:27018'])

The nodes passed to Connection() are called the seeds. If only one
host is specified the replicaset parameter must be used to indicate
this isn’t a connection to a single node. As long as at least one of
the seeds is online, the driver will be able to “discover” all of the
nodes in the set and make a connection to the current primary.

标签:mongodb,pymongo,python,c
来源: https://codeday.me/bug/20191127/2076821.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有