监控方式

命令行工具

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/

mongodb之监控的更多相关文章

  1. mongodb的监控与性能优化

    一.mongodb的监控 mongodb可以通过profile来监控数据,进行优化. 查看当前是否开启profile功能用命令 db.getProfilingLevel()  返回level等级,值为 ...

  2. 分布式监控系统Zabbix3.4-针对MongoDB性能监控操作笔记

    公司在IDC机房的一台服务器上部署了MongoDB,由于所存储的业务数据比较重要,所以对MongoDB的监控显得尤为重要!Zabbix监控MongoDB性能的原理:通过echo "db.se ...

  3. Open-Falcon 监控系统监控 MySQL/Redis/MongoDB 状态监控

    背景: Open-Falcon 是小米运维部开源的一款互联网企业级监控系统解决方案,具体的安装和使用说明请见官网:http://open-falcon.org/,是一款比较全的监控.而且提供各种API ...

  4. 011.MongoDB性能监控

    一 MongoDB 监控 1.1 监控概述 MongoDB自带了mongostat 和 mongotop 这两个命令来监控MongoDB的运行情况.这两个命令用于处理MongoDB数据库变慢等等问题非 ...

  5. MongoDB性能监控

    1.mongostat 查看运行中的mongodb实例的统计信息 重要指标说明: getmore: 通常发生在结果集比较大的查询时,第一个query返回了部分结果,后续的结果是通过getmore来获取 ...

  6. springboot项目屏蔽mq或者mongodb的监控日志输出

    最近写项目,用的是springboot,其中用到了rabbitmq和mongodb,配置完成 项目启动后,会输出如下日志: mongodb和mq的检测,会一直打印日志,这样会影响开发人员的测试. 如何 ...

  7. mongodb简单监控

    一.mongodb提供了自己的监控工具 mongostat mongostat是mongodb自带的状态检测工具,在命令行下使用.它会间隔固定时间获取mongodb的当前运行状态,并输出.如果你发现数 ...

  8. mongoDB 学习笔记纯干货(mongoose、增删改查、聚合、索引、连接、备份与恢复、监控等等)

    最后更新时间:2017-07-13 11:10:49 原始文章链接:http://www.lovebxm.com/2017/07/13/mongodb_primer/ MongoDB - 简介 官网: ...

  9. MongoDB 运行状态、性能监控,分析

    这篇文章的目的是让你知道怎么了解你正在运行的Mongdb是否健康.转载自http://tech.lezi.com/archives/290 mongostat详解 启动mongodb监控,通过下面命令 ...

随机推荐

  1. cmd执行Java程序

    先创建一个文本,里面内容为 public class hello{ public static void main(String[] arg) { System.out.println("H ...

  2. 关于 android屏幕适配

    一.关于布局适配 1.不要使用绝对布局 2.尽量使用match_parent 而不是fill_parent . 3.能够使用权重的地方尽量使用权重(android:layout_weight) 4.如 ...

  3. [转]linux之at指令详解

    转自:http://www.2cto.com/os/201409/336183.html 指令:at定时任务,指定一个时间执行一个任务,只能执行一次. 语法:# at [参数] [时间]at> ...

  4. 一个.py引用另一个.py中的方法

    处理函数 X_Add_Y_Func.py #__author__ = 'Administrator' def add_func(x, y): return x+y 调用函数 X_Add_Y_Func_ ...

  5. Linux内存压力测试-memtester工具

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  6. (转)分布式文件存储FastDFS(三)FastDFS配置

    http://blog.csdn.net/xingjiarong/article/details/50559768 在上一节中我们一起搭建了一个单节点的FastDFS系统,但是仅仅将系统搭建起来是远远 ...

  7. C# 字符串到字节数组,字节数组转整型

    ; , ); byte[] bytes = BitConverter.GetBytes(num);//将int32转换为字节数组 num = BitConverter.ToInt32(bytes, ) ...

  8. DECLARE_DYNAMIC

    DECLARE_DYNAMIC(class_name) DECLARE_DYNCREATE 包含了DECLARE_DYNAMIC的功能,并且可以在运行过程中动态创建对象.如果需要动态创建类对象,需要使 ...

  9. CAD绘制一个半径标注(com接口VB语言)

    主要用到函数说明: _DMxDrawX::DrawDimRadial 绘制一个半径标注.详细说明如下: 参数 说明 DOUBLE dCenterX 被标注的曲线的中点X值 DOUBLE dCenter ...

  10. 学习csv

    1.csv文件读取,csv文件是常用的数据存储格式之一,我们使用Python模块来处理csv文件,这是一个天气信息表 import csv from matplotlib import pyplot ...