Mongodb 增加了 db.currentOp() 问题

发布于 2025-01-06 10:26:04 字数 1856 浏览 3 评论 0原文

我的网站使用 mongodb 作为聊天应用程序。 Mongodb 查询超时,所以我检查了 db.currentOp()。下面是 currentOp() 和 Mongodb 详细信息,

637 个活动操作 750 个非活动操作

有关 mongodb 的其他详细信息:

  1. Mongo db 正在使用分片运行
  2. 我有两个数据库

  3. a)第一个数据库只有两个表 b) 第二个数据库有 5 个表

我的问题是,为什么 current.Op() 计数突然增加,以及如果 currentOp() 计数增加,我们必须注意的原因是什么。请帮助我解决这个问题,并对我糟糕的英语表示歉意。

以下是我的 currentOp() 的示例输出

MongoDB shell version: 1.8.2
    > db.currentOp()
    {
        "inprog" : [
        {
            "opid" : "msdata1:234234234",
            "active" : true,
            "lockType" : "read",
            "waitingForLock" : false,
            "secs_running" : 43534,
            "op" : "getmore",
            "ns" : "local.oplog.rs",
            "query" : {

            },
            "client_s" : "70.52.078.123:12345",
            "desc" : "conn"
        },
        {
            "opid" : "msdata1:2342323423",
            "active" : true,
            "lockType" : "read",
            "waitingForLock" : false,
            "secs_running" : 231231,
            "op" : "query",
            "ns" : "ichat.chatmemberlist",
            "query" : {
                "count" : "chatmemberlist",
                "query" : {
                    "Mid" : "23423",
                    "bmid" : "23423"
                }
            },
            "client_s" : "70.52.078.123:12345",
            "desc" : "conn"
        },
        {
            "opid" : "msdata1:2342323423",
            "active" : false,
            "lockType" : "write",
            "waitingForLock" : true,
            "op" : "update",
            "ns" : "?ichat.useravail",
            "query" : {
                "Mid" : "23423"
            },
            "client_s" : "70.512.078234.423:12345",
            "desc" : "conn"
        },

        ...
        ...
        ...

My site using mongodb for the chat application. Mongodb queries are getting timed out so i checked the db.currentOp(). Below is the currentOp() and Mongodb details,

637 active operations
750 inactive operations

Other details about mongodb:

  1. Mongo db is running with sharding
  2. I have two databases

  3. a)First database having, two table only
    b)Second database having , 5 tables

My questions are, why the current.Op() count got increased suddenly and what are the causes we have to taken care if currentOp() count is increased. Please help me on this and apologies for my bad English.

Below are the sample output of my currentOp()

MongoDB shell version: 1.8.2
    > db.currentOp()
    {
        "inprog" : [
        {
            "opid" : "msdata1:234234234",
            "active" : true,
            "lockType" : "read",
            "waitingForLock" : false,
            "secs_running" : 43534,
            "op" : "getmore",
            "ns" : "local.oplog.rs",
            "query" : {

            },
            "client_s" : "70.52.078.123:12345",
            "desc" : "conn"
        },
        {
            "opid" : "msdata1:2342323423",
            "active" : true,
            "lockType" : "read",
            "waitingForLock" : false,
            "secs_running" : 231231,
            "op" : "query",
            "ns" : "ichat.chatmemberlist",
            "query" : {
                "count" : "chatmemberlist",
                "query" : {
                    "Mid" : "23423",
                    "bmid" : "23423"
                }
            },
            "client_s" : "70.52.078.123:12345",
            "desc" : "conn"
        },
        {
            "opid" : "msdata1:2342323423",
            "active" : false,
            "lockType" : "write",
            "waitingForLock" : true,
            "op" : "update",
            "ns" : "?ichat.useravail",
            "query" : {
                "Mid" : "23423"
            },
            "client_s" : "70.512.078234.423:12345",
            "desc" : "conn"
        },

        ...
        ...
        ...

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

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

发布评论

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

评论(1

小嗷兮 2025-01-13 10:26:04

从有限的信息中,我可以看到您的查询运行了很长时间:“secs_running”:231231,表示231秒。您可能没有足够的资源可用于您正在运行的查询类型。这可能是因为您没有足够的内存,或者获取锁的查询过多。如果您还没有使用 MongoDB 2.0.x,那么您可能也想升级到该版本,因为它极大地改进了锁定:http://blog.pythonisito.com/2011/12/mongodbs-write-lock.html

我建议检查 mongodb.log文件来查看哪些查询速度很慢,然后使用解释来确定您是否在列上建立了索引,然后添加索引,或者看看如何重新设计您的架构(如果这看起来像是更好的解决方案)。

From the limited amount of info, I can see that your queries are just running a really long time: "secs_running" : 231231, means 231 seconds. It's likely that you don't have enough resources available for the type of queries that you are running. That could be that you don't have enough memory, or perhaps too much queries that are acquiring a lock. If you're not on MongoDB 2.0.x yet, then you might want to upgrade to that too as it has vastly improved locking: http://blog.pythonisito.com/2011/12/mongodbs-write-lock.html

I would advice to check the mongodb.log file to see which queries are being slow, then use explain to figure out whether you've indexes on the columns and then either add indexes, or see how you can re-design your schema if that might look like a better solution.

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