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/

转载于:https://www.cnblogs.com/wadeyu/p/7941809.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值