zoukankan      html  css  js  c++  java
  • mongodb之监控

    监控方式


    命令行工具

    mongostat命令

    用途

    用于mongod或者mongos操作类型统计,网络流量统计,当前并发数等统计

    用法

    mongostat options <sleeptime>

    常用选项

    --host <hostname><:port>, -h <hostname><:port>

    连接主机名

    --port <port>

    连接端口

    --username <username>, -u <username>

    授权用户名

    --password <password>, -p <password>

    授权用户密码

    --authenticationDatabase <dbname>

    授权数据库

    --discover

    发现和统计集群中所有成员

    --all

    显示所有字段

    实践

    mongostat --host 127.0.0.1 --port 27025 -u root -p root --all --authenticationDatabase admin 2

    输出内容

    insert query update delete getmore command flushes mapped vsize  res faults qrw arw net_in net_out conn                time
        *0    *0     *0     *0       0     6|0       0     0B  413M 128M      0 0|0 0|0   878b   16.9k    3 Nov 29 16:51:47.730
        *0    *0     *0     *0       0     2|0       0     0B  413M 128M      0 0|0 0|0   294b   17.4k    3 Nov 29 16:51:48.701
        *0    *0     *0     *0       0     1|0       0     0B  413M 128M      0 0|0 0|0   280b   16.6k    3 Nov 29 16:51:49.719
        *0    *0     *0     *0       0     2|0       0     0B  413M 128M      0 0|0 0|0   291b   17.3k    3 Nov 29 16:51:50.700
        *0    *0     *0     *0       0     1|0       0     0B  413M 128M      0 0|0 0|0   285b   16.9k    3 Nov 29 16:51:51.702
        *0    *0     *0     *0       0     2|0       0     0B  413M 128M      0 0|0 0|0   286b   17.0k    3 Nov 29 16:51:52.700
        *0    *0     *0     *0       0     2|0       0     0B  413M 128M      0 0|0 0|0   286b   16.9k    3 Nov 29 16:51:53.699
        *0    *0     *0     *0       0     2|0       0     0B  413M 128M      0 0|0 0|0   286b   16.9k    3 Nov 29 16:51:54.699
        *0    *0     *0     *0       0     1|0       0     0B  413M 128M      0 0|0 0|0   283b   16.8k    3 Nov 29 16:51:55.706
        *0    *0     *0     *0       0     6|0       0     0B  413M 128M      0 0|0 0|0   890b   17.2k    3 Nov 29 16:51:56.728
    

      

    输出内容字段说明

    insert

    每秒插入文档数量,还有句话不理解,贴下面备注下
    If followed by an asterisk (e.g. *), the datum refers to a replicated operation.

    query

    每秒执行查询次数

    update

    每秒执行更新次数

    delete

    每秒执行删除次数

    getmore

    每秒执行获得更多次数

    command

    每秒执行命令的数量

    flushes

    WiredTiger: refers to the number of WiredTiger checkpoints triggered between each polling interval.
    MMAPV1: 每秒执行fsync操作的次数

    dirty

    Only for WiredTiger Storage Engine. The percentage of the WiredTiger cache with dirty bytes,
    calculated by wiredTiger.cache.tracked dirty bytes in the cache / wiredTiger.cache.maximum bytes configured.

    used

    Only for WiredTiger Storage Engine. The percentage of the WiredTiger cache that is in use,
    calculated by wiredTiger.cache.bytes currently in the cache / wiredTiger.cache.maximum bytes configured.

    mapped

    MMAPv1内存数据映射总数量(M为单位)

    vsize

    使用的虚拟内存数量(M为单位)

    non-mapped

    MMAPv1:使用的虚拟内存数量(不包括映射内存数量)

    res

    使用的物理内存数量(单位M)

    faults

    MMAPv1:每秒出现page faults数量

    lr

    MMAPv1:等待读锁的百分比

    lw

    MMAPv1:等待写锁的百分比

    lrt

    MMAPv1:获得读锁平均等待的时间(单位微秒)

    lwt

    MMAPv1:获得写锁平均等待的时间(单位微秒)

    qr

    等待读数据的客户端队列长度

    qw

    等待写数据的客户端队列长度

    ar

    当前正在读数据的客户端数量

    aw

    当前正在写数据的客户端数量

    netIn

    入网流量(单位字节)

    netOut

    出网流量(单位字节)

    conn

    打开客户端连接数量

    set

    副本集名字

    repl

    节点属性

    Value Replication Type
    M master
    SEC secondary
    REC recovering
    UNK unknown
    SLV slave
    RTR mongos process (“router”)
    ARB arbiter

    mongotop命令

    用途

    按集合分类统计查看当前读写情况

    用法

    mongotop options <sleeptime>

    常用选项

    --host <hostname><:port>, -h <hostname><:port>

    连接主机

    --port <port>

    连接端口

    --username <username>, -u <username>

    授权用户名

    --password <password>, -p <password>

    授权用户密码

    --authenticationDatabase <dbname>

    授权数据库

    实践

    mongotop --host 127.0.0.1 --port 27027 -u root -p root --authenticationDatabase admin 2

    输出内容

                    ns    total    read    write    2017-11-29T18:38:39+08:00
            local.oplog.rs     13ms    13ms      0ms                             
      admin.system.profile      0ms     0ms      0ms                             
        admin.system.roles      0ms     0ms      0ms                             
        admin.system.users      0ms     0ms      0ms                             
      admin.system.version      0ms     0ms      0ms                             
                  local.me      0ms     0ms      0ms                             
    local.replset.election      0ms     0ms      0ms                             
    local.replset.minvalid      0ms     0ms      0ms                             
         local.startup_log      0ms     0ms      0ms                             
      local.system.replset      0ms     0ms      0ms
    

      


    数据库命令

    查看服务器状态
    db.serverStatus()

    查看数据库统计
    db.stats()

    查看集合统计
    db.xxCollection.stats()

    查看副本集集群状态
    rs.status()

    查看分片集群状态
    sh.status()

    查看分片集群锁情况
    use config
    db.locks.find({})


    第三方统计项目插件

    比如Nagios的插件Nagios-plugin-mongodb
    比如SPM Performance Monitoring的插件MongoDB Docker Agent


    官方的运维管理工具(Ops Manger)

    除了监控还有备份的功能,这套系统需要单独部署


    备注

    1. 执行命名的用户需要有serverStatus查看的权限
    2. replication集群需要关注同步延迟情况,延迟大会对应用功能造成不好的后果


    参考文档

    【1】mongodb监控
    https://docs.mongodb.com/manual/administration/monitoring/

    【2】mongostat命令
    https://docs.mongodb.com/manual/reference/program/mongostat/

    【3】mongotop命令
    https://docs.mongodb.com/manual/reference/program/mongotop/

    作者:WadeYu
    出处:http://www.cnblogs.com/wadeyu/
    本文版权归本人和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    C#手写日志(txt格式)
    dedecms:解析Robots.txt 协议标准
    dedecms列表页有图调用缩略图无图留空的方法
    简单的随机数实现
    单页面定时跳转的办法小结
    css3通过scale()实现放大功能、通过rotate()实现旋转功能
    rem自适应布局小结001
    Java的BIO、NIO、AIO
    Java实现静态代理、动态代理
    博弈论基础
  • 原文地址:https://www.cnblogs.com/wadeyu/p/7941809.html
Copyright © 2011-2022 走看看