zoukankan      html  css  js  c++  java
  • mongodb通过profile来监控数据

    mongodb可以通过profile来监控数据,进行优化。
    查看当前是否开启profile功能
    用命令db.getProfilingLevel() 返回level等级,值为0|1|2,分别代表意思:0代表关闭,1代表记录慢命令,2代表全部
    开启profile功能命令为

    db.setProfilingLevel(level); #level等级,值同上

    level为1的时候,慢命令默认值为100ms,

    更改为db.setProfilingLevel(level,slowms)如db.setProfilingLevel(1,50)这样就更改为50毫秒

    通过db.system.profile.find() 查看当前的监控日志.

    /* 1 */
    {
        "op" : "query",
        "ns" : "config.system.profile",
        "command" : {
            "find" : "system.profile",
            "filter" : {},
            "$readPreference" : {
                "mode" : "secondaryPreferred"
            },
            "$db" : "config"
        },
        "keysExamined" : 0,
        "docsExamined" : 0,
        "cursorExhausted" : true,
        "numYield" : 0,
        "locks" : {
            "Global" : {
                "acquireCount" : {
                    "r" : NumberLong(2)
                }
            },
            "Database" : {
                "acquireCount" : {
                    "r" : NumberLong(1)
                }
            },
            "Collection" : {
                "acquireCount" : {
                    "r" : NumberLong(1)
                }
            }
        },
        "nreturned" : 0,
        "responseLength" : 94,
        "protocol" : "op_command",
        "millis" : 32,
        "planSummary" : "COLLSCAN",
        "execStats" : {
            "stage" : "COLLSCAN",
            "nReturned" : 0,
            "executionTimeMillisEstimate" : 0,
            "works" : 2,
            "advanced" : 0,
            "needTime" : 1,
            "needYield" : 0,
            "saveState" : 0,
            "restoreState" : 0,
            "isEOF" : 1,
            "invalidates" : 0,
            "direction" : "forward",
            "docsExamined" : 0
        },
        "ts" : ISODate("2019-01-18T03:10:06.731Z"),
        "client" : "192.168.0.72",
        "appName" : "MongoDB Shell",
        "allUsers" : [ 
            {
                "user" : "root",
                "db" : "admin"
            }
        ],
        "user" : "root@admin"
    }
  • 相关阅读:
    linux commands ---2 ,学习vim编辑器如何使用的方法。
    $stateParams 详解
    ipa 打包遇到的坑
    原生和jQuery的ajax用法
    ios 的 desciption
    ios上线流程
    android 上线流程
    cordova 常用插件
    iframe
    cordova 强制竖屏
  • 原文地址:https://www.cnblogs.com/visionsl/p/10286655.html
Copyright © 2011-2022 走看看