zoukankan      html  css  js  c++  java
  • mongodb的慢查询

    一、获取慢查询配置:

    db.getProfilingStatus()
    
    db.setProfilingLevel(1,500)

    具体例子如下:

    glc-test:PRIMARY> db.getProfilingStatus()
    {
            "was" : 0,
            "slowms" : 500,
            "ratelimit" : 1,
            "sampleRate" : 1,
            "operationTime" : Timestamp(1606295083, 1),
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1606295083, 1),
                    "signature" : {
                            "hash" : BinData(0,"21NKX80GE0q/yEV5AJII6XAwctQ="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    }
    glc-test:PRIMARY> db.getProfilingLevel()
    0
    glc-test:PRIMARY> db.setProfilingLevel(1,500)
    {
            "was" : 0,
            "slowms" : 500,
            "ratelimit" : 1,
            "sampleRate" : 1,
            "ok" : 1,
            "operationTime" : Timestamp(1606295103, 1),
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1606295103, 1),
                    "signature" : {
                            "hash" : BinData(0,"9m9XwRHgd18Ik2AouRUIvh2DFLg="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    }
    glc-test:PRIMARY> 

    二、删除慢查询集合:

    db.setProfilingLevel(0)
    
    db.system.profile.drop()

    具体例子如下:

    glc-test:PRIMARY> db.getProfilingStatus()
    {
            "was" : 1,
            "slowms" : 500,
            "ratelimit" : 1,
            "sampleRate" : 1,
            "operationTime" : Timestamp(1606294533, 1),
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1606294533, 1),
                    "signature" : {
                            "hash" : BinData(0,"UDIIGdRByffSd7zBXbKOocNHVf4="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    }
    glc-test:PRIMARY> db.system.profile.drop()
    2020-11-25T16:55:53.233+0800 E QUERY    [js] Error: drop failed: {
            "operationTime" : Timestamp(1606294543, 1),
            "ok" : 0,
            "errmsg" : "turn off profiling before dropping system.profile collection",
            "code" : 20,
            "codeName" : "IllegalOperation",
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1606294543, 1),
                    "signature" : {
                            "hash" : BinData(0,"IS5isA2D6B9TAnEsaW/SFsfwe+0="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    } :
    _getErrorWithCode@src/mongo/shell/utils.js:25:13
    DBCollection.prototype.drop@src/mongo/shell/collection.js:707:1
    @(shell):1:1
    glc-test:PRIMARY> db.setProfilingLevel(0)
    {
            "was" : 1,
            "slowms" : 500,
            "ratelimit" : 1,
            "sampleRate" : 1,
            "ok" : 1,
            "operationTime" : Timestamp(1606294563, 1),
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1606294563, 1),
                    "signature" : {
                            "hash" : BinData(0,"NT7TdpDLfjzC37lDMtINsmJvVQ0="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    }
    glc-test:PRIMARY> db.system.profile.drop()
    true
    glc-test:PRIMARY> 

     三、创建慢查询集合:

    db.createCollection("system.profile", {size: 40000000, capped: true})

    具体例子如下:

    glc-test:PRIMARY> show tables;
    ai_caps_skill_info
    cas_users
    glc
    home
    inventory
    iphone
    iphonr
    my2
    my3
    user
    glc-test:PRIMARY> db.createCollection("system.profile", {size: 40000000, capped: true})
    {
            "ok" : 1,
            "operationTime" : Timestamp(1606294983, 1),
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1606294983, 1),
                    "signature" : {
                            "hash" : BinData(0,"vXiMidZUy7pXCg2t8Zvj4zgsO4E="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    }
    glc-test:PRIMARY> show tables;
    ai_caps_skill_info
    cas_users
    glc
    home
    inventory
    iphone
    iphonr
    my2
    my3
    system.profile
    user
    glc-test:PRIMARY> 

    #################################################

  • 相关阅读:
    自动登录跳板机->开发机
    关于写代码的一下规范
    vscode 配置 GOPATH
    thinkphp6.0 nginx 配置
    vue-cli 3.x 构建项目,webpack没有了?
    Laravel6.0 使用 Jwt-auth 实现多用户接口认证
    怎么在 localhost 下访问多个 Laravel 项目,通过一个IP访问多个项目(不仅仅是改变端口哦)
    laravel 5.8 实现消息推送
    vs code 设置 保存自动格式化vue代码
    项目开发规范(编码规范、命名规范、安全规范、前端优化、源码提交规范、代码维护规范、产品发布规范)
  • 原文地址:https://www.cnblogs.com/igoodful/p/13955370.html
Copyright © 2011-2022 走看看