• 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> 

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

  • 相关阅读:
    ios app 开发中ipa重新签名步骤介绍-备
    推荐IOS开发3个工具:Homebrew、TestFight、Crashlytics-b
    iOS开发工具——统计Crash的工具Crashlytics-备用
    摘要算法
    Xcode中将图片放入Images.xcassets和直接拖入的区别
    PHP面向对象的基本写法(区别于java)
    PHP 解决时差8小时的问题
    Java-Hirbernate小结大纲
    PHP替换数据库的换行符
    Java-strurs总结
  • 原文地址:https://www.cnblogs.com/igoodful/p/13955370.html
Copyright © 2020-2023  润新知