MongoDB性能分析工具mongostat

一 简介

利用mongostat可以查看MongoDB的实时性能,qps,连接数等信息

二 用法帮助

查看帮助

      --help              查看用法帮助                     
      --version   版本

连接选项  

-h, --host=<hostname>     主机IP                   
      --port=<port>   端口

认证选项
  -u, --username=<username>                      用户名
  -p, --password=<password>                       密码
      --authenticationDatabase=<database-name>    用户认证的数据库,MongoDB的用户都是和数据库绑定的
      --authenticationMechanism=<mechanism>       authentication mechanism to use

ssl 参数:
      --ssl                                       connect to a mongod or mongos that has ssl enabled
      --sslCAFile=<filename>                      the .pem file containing the root certificate chain from the certificate authority
      --sslPEMKeyFile=<filename>                  the .pem file containing the certificate and key
      --sslPEMKeyPassword=<password>              the password to decrypt the sslPEMKeyFile, if necessary
      --sslCRLFile=<filename>                     the .pem file containing the certificate revocation list
      --sslAllowInvalidCertificates               bypass the validation for server certificates
      --sslAllowInvalidHostnames                  bypass the validation for server name
      --sslFIPSMode                               use FIPS mode of the installed openssl library

stat options:
  -o=<field>[,<field>]*                           fields to show. For custom fields, use dot-syntax to index into serverStatus output, and optional methods .diff() and .rate() e.g. metrics.record.moves.diff()
  -O=<field>[,<field>]*                           like -o, but preloaded with default fields. Specified fields inserted after default output
      --humanReadable=                            print sizes and time in human readable format (e.g. 1K 234M 2G). To use the more precise machine readable format, use --humanReadable=false (default: true)
      --noheaders                                 don't output column names
  -n, --rowcount=<count>                          number of stats lines to print (0 for indefinite)
      --discover                                  discover nodes and display stats for all
      --http                                      use HTTP instead of raw db connection
      --all                                       all optional fields
      --json                                      output as JSON rather than a formatted table
      --useDeprecatedJsonKeys                     use old key names; only valid with the json output option.
  -i, --interactive                               display stats in a non-scrolling interface
[root@mongoh01 bin]# ./mongostat --version

三 输出详解

mongostat --host=127.0.0.1  --port=9000 --username=root --password=passwd --authenticationDatabase=admin

它的输出有以下几列:

  • inserts/s 每秒插入次数
  • query/s 每秒查询次数
  • update/s 每秒更新次数
  • delete/s 每秒删除次数
  • getmore/s 每秒执行getmore次数
  • command/s 每秒的命令数,比以上插入、查找、更新、删除的综合还多,还统计了别的命令
  • flushs/s 每秒执行fsync将数据写入硬盘的次数。
  • mapped/s 所有的被mmap的数据量,单位是MB,
  • vsize 虚拟内存使用量,单位MB
  • res 物理内存使用量,单位MB
  • faults/s 每秒访问失败数(只有Linux有),数据被交换出物理内存,放到swap。不要超过100,否则就是机器内存太小,造成频繁swap写入。此时要升级内存或者扩展
  • locked % 被锁的时间百分比,尽量控制在50%以下吧
  • idx miss % 索引不命中所占百分比。如果太高的话就要考虑索引是不是少了
  • q t|r|w 当Mongodb接收到太多的命令而数据库被锁住无法执行完成,它会将命令加入队列。这一栏显示了总共、读、写3个队列的长度,都为0的话表示mongo毫无压力。高并发时,一般队列值会升高。
  • conn 当前连接数
  • time 时间戳
原文地址:https://www.cnblogs.com/DBABlog/p/12926897.html