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> 

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

  • 相关阅读:
    Flask Mysql数据库连接
    Flask form前后端交互消息闪现
    Flask block继承和include包含
    Flask filter过滤器
    常规http状态码
    linux搭建hadoop环境
    inline-block布局代码
    JDBC4.0自动加载驱动器类
    用反射模拟Hibernate保存JavaBean
    深入ThreadLocal的内部机制
  • 原文地址:https://www.cnblogs.com/igoodful/p/13955370.html
Copyright © 2011-2022 走看看