MongoDB 不会在副本集中分配读取

发布于 2024-11-05 06:08:20 字数 703 浏览 0 评论 0原文

我们的副本集中有三台服务器。举例来说,ServerA 是主服务器,而 ServerB 和 ServerC 是辅助服务器。在对环境进行压力测试时,ServerA 上的服务器负载已飙升至 4.00 左右,而辅助服务器仍保持在 0.00。压力测试的 URL 目标不会对 mongo 进行任何写入,但读取似乎不会分发到辅助节点。

我们使用官方 C# 驱动程序。

ServerA 日志显示许多正在打开的连接、lsn 设置条目和一堆“killcursors”命令——它显然正在努力提供页面。然而,ServerB 和 ServerC 仅显示来自 Web 服务器(其中四个)的初始连接,之后日志中仅显示“lsn set”条目。几分钟后,最初的四个连接超时并关闭。

副本集处于完整工作状态。我可以在主要节点上停止 mongo,并且辅助节点将正确选择一个新的主要节点。

来自 Web.config 的连接字符串:

<connectionStrings>
    <add name="wellness.mongodb" connectionString="mongodb://serverA:27017,serverB:27017,serverC:27017/mydatabase?safe=true;replicaset=myreplicaset;slaveok=true" />
</connectionStrings>

我们做错了什么?

We have three servers in a replica set. For the sake of example, ServerA is primary, while ServerB and ServerC are secondaries. While stress testing the environment, the server load on ServerA has spiked to around 4.00, while the secondaries remain at 0.00. The URL targets of the stress testing do not do any writes to mongo, but it appears that reads are not being distributed to the secondaries.

We are using the official C# driver.

ServerA log shows many connections being opened, lsn set entries, and a bunch of "killcursors" commands -- it is obviously working to serve up pages. ServerB and ServerC, however, only show the initial connections from the web servers (four of them), and after that only "lsn set" entries appear in the logs. After a few minutes, the initial four connections timeout and close.

The replica set is in full working order. I can stop mongo on the primary, and the secondaries will correctly elect a new primary.

Our connection string from Web.config:

<connectionStrings>
    <add name="wellness.mongodb" connectionString="mongodb://serverA:27017,serverB:27017,serverC:27017/mydatabase?safe=true;replicaset=myreplicaset;slaveok=true" />
</connectionStrings>

What are we doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安人多梦 2024-11-12 06:08:20

连接字符串看起来没问题。我会尝试重现并报告。

The connection string looks OK. I'll try and reproduce and report back.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文