广告
返回顶部
首页 > 资讯 > 数据库 >Mongodb监控命令
  • 135
分享到

Mongodb监控命令

2024-04-02 19:04:59 135人浏览 安东尼
摘要

Mongodb监控命令一、监控工具1、monGostat工具默认为显示每秒的统计信息# mongostat -uroot -ppassWord --authentic

Mongodb监控命令


一、监控工具

1、monGostat工具

默认为显示每秒的统计信息

# mongostat -uroot -ppassWord --authenticationDatabase admin -h292.168.x.xx  --rowcount 10 1
connected to: 192.168.x.xx
insert  query update delete getmore command flushes mapped  vsize    res faults  locked db idx miss %     qr|qw   ar|aw  netIn netOut  conn set repl       time 
    *0     *0     *0     *0       0     3|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0   178b     4k     6 rs0  SEC   21:02:36 
    *0     *0     *0     *0       0     3|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0   342b     4k     6 rs0  SEC   21:02:37 
    *0     *0     *0     *0       0     1|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0    62b     3k     6 rs0  SEC   21:02:38 
    *0     *0     *0     *0       0     3|0       1  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0   342b     4k     6 rs0  SEC   21:02:39 
    *0      6     *0     *0       0     1|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0    62b     3k     6 rs0  SEC   21:02:40 
    *0     *0     *0     *0       0     3|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0   342b     4k     6 rs0  SEC   21:02:41 
    *0     *0     *0     *0       0     1|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0    62b     3k     6 rs0  SEC   21:02:42 
    *0     *0     *0     *0       0     3|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0   342b     4k     6 rs0  SEC   21:02:43 
    *0     *0     *0     *0       0     1|0       0  1.19g  3.07g    85m      0  test:0.0%          0       0|0     0|0    62b     3k     6 rs0  SEC   21:02:44 
    *0     *0     *0     *0       0     3|0       0  1.19g  3.07g    85m      0   db4:0.0%          0       0|0     0|0   342b     4k     6 rs0  SEC   21:02:45

可以添加 --discover显示shard集群(连接mongos)和副本集的所有成员的统计信息。


输出含义,参考:Http://docs.mongoDB.org/v2.6/reference/program/mongostat/


2、mongotop工具

显示每个数据库集合的读写时间,或每个数据库的读写时间(--locks),默认为1秒。

# mongotop -uroot -ppassword --authenticationDatabase admin -h292.168.x.xx  5
connected to: 192.168.x.xx

                            ns       total        read       write		2015-06-10T13:23:51
            db4.system.indexes         0ms         0ms         0ms
                      db4.$cmd         0ms         0ms         0ms
         db2.system.namespaces         0ms         0ms         0ms
            db2.system.indexes         0ms         0ms         0ms
                      db2.post         0ms         0ms         0ms
                    db1.userX2         0ms         0ms         0ms
                    db1.userX1         0ms         0ms         0ms

                            ns       total        read       write		2015-06-10T13:23:56
            db4.system.indexes         0ms         0ms         0ms
                      db4.$cmd         0ms         0ms         0ms
         db2.system.namespaces         0ms         0ms         0ms
            db2.system.indexes         0ms         0ms         0ms
                      db2.post         0ms         0ms         0ms
                    db1.userX2         0ms         0ms         0ms
                    db1.userX1         0ms         0ms         0ms

					
# mongotop -uroot -ppassword --authenticationDatabase admin -h292.168.x.xx  5 --locks
connected to: 192.168.x.xx

                            db       total        read       write		2015-06-10T13:24:42
                             .         1ms         1ms         0ms
                          test         0ms         0ms         0ms
                         local         0ms         0ms         0ms
                           db4         0ms         0ms         0ms
                           db2         0ms         0ms         0ms
                           db1         0ms         0ms         0ms
                         admin         0ms         0ms         0ms

                            db       total        read       write		2015-06-10T13:24:47
                          test         0ms         0ms         0ms
                         local         0ms         0ms         0ms
                           db4         0ms         0ms         0ms
                           db2         0ms         0ms         0ms
                           db1         0ms         0ms         0ms
                         admin         0ms         0ms         0ms
                             .         0ms         0ms         0ms	

输出含义,参考:http://docs.mongodb.org/v2.6/reference/program/mongotop/


3、db.serverStatus()

参考:http://docs.mongodb.org/v2.6/reference/command/serverStatus/


4、db.stats() 

> db.stats()
{
	"db" : "db4",
	"collections" : 3,
	"objects" : 13,
	"avgObjsize" : 87.38461538461539,
	"dataSize" : 1136,
	"storageSize" : 24576,
	"numExtents" : 3,
	"indexes" : 3,
	"indexSize" : 24528,
	"fileSize" : 16777216,
	"nsSizeMB" : 16,
	"dataFileVersion" : {
		"major" : 4,
		"minor" : 5
	},
	"extentFreeList" : {
		"num" : 0,
		"totalSize" : 0
	},
	"ok" : 1
}

参考:http://docs.mongodb.org/v2.6/reference/command/dbStats/#dbcmd.dbStats


5、db.collect_name.stats()

{
	"ns" : "db4.userInfo",
	"count" : 5,
	"size" : 560,
	"avgObjSize" : 112,
	"storageSize" : 8192,
	"numExtents" : 1,
	"nindexes" : 3,
	"lastExtentSize" : 8192,
	"paddingFactor" : 1,
	"systemFlags" : 1,
	"userFlags" : 1,
	"totalIndexSize" : 24528,
	"indexSizes" : {
		"_id_" : 8176,
		"name_hashed" : 8176,
		"age_1" : 8176
	},
	"ok" : 1
}

参考:http://docs.mongodb.org/v2.6/reference/command/collStats/#dbcmd.collStats


6、rs.status()

查询副本集信息

> rs.status()
{
	"set" : "rs0",
	"date" : ISODate("2015-06-11T04:02:55Z"),
	"myState" : 2,
	"syncingTo" : "192.168.x.xx:27018",
	"members" : [
		{
			"_id" : 0,
			"name" : "192.168.x.xx:27017",
			"health" : 1,
			"state" : 2,
			"stateStr" : "SECONDARY",
			"uptime" : 84674,
			"optime" : Timestamp(1435989328, 1),
			"optimeDate" : ISODate("2015-07-04T05:55:28Z"),
			"lastHeartbeat" : ISODate("2015-06-11T04:02:54Z"),
			"lastHeartbeatRecv" : ISODate("2015-06-11T04:02:54Z"),
			"pingMs" : 8,
			"syncingTo" : "192.168.x.xx:27018"
		},
		{
			"_id" : 3,
			"name" : "192.168.x.xx:27017",
			"health" : 1,
			"state" : 2,
			"stateStr" : "SECONDARY",
			"uptime" : 84676,
			"optime" : Timestamp(1435989328, 1),
			"optimeDate" : ISODate("2015-07-04T05:55:28Z"),
			"self" : true
		},
		{
			"_id" : 4,
			"name" : "192.168.x.xx:27018",
			"health" : 1,
			"state" : 1,
			"stateStr" : "PRIMARY",
			"uptime" : 84674,
			"optime" : Timestamp(1435989328, 1),
			"optimeDate" : ISODate("2015-07-04T05:55:28Z"),
			"lastHeartbeat" : ISODate("2015-06-11T04:02:54Z"),
			"lastHeartbeatRecv" : ISODate("2015-06-11T04:02:55Z"),
			"pingMs" : 2,
			"electionTime" : Timestamp(1435803779, 1),
			"electionDate" : ISODate("2015-07-02T02:22:59Z")
		}
	],
	"ok" : 1
}

参考:http://docs.mongodb.org/v2.6/reference/command/replSetGetStatus


二、诊断性能问题

1、Locks

分析 db.serverStatus() 输出的 globalLock 部分:

"globalLock" : {
		"totalTime" : NumberLong("240481182000"),
		"lockTime" : NumberLong(11670085),
		"currentQueue" : {
			"total" : 0,
			"readers" : 0,
			"writers" : 0
		},
		"activeClients" : {
			"total" : 0,
			"readers" : 0,
			"writers" : 0
		}
	}

If globalLock.currentQueue.total is consistently high, then there is a chance that a large number of requests are waiting for a lock.

This indicates a possible concurrency issue that may be affecting perfORMance.


globalLock.totalTime : The value of totalTime represents the time, in microseconds, since the database last started and creation of the globalLock. 

   This is roughly equivalent to total server uptime.


lockTime/totalTime很大,表示锁花费的时间长,导致性能下降。


2、内存

分析 db.serverStatus() 输出的 mem 部分:

"mem" : {
		"bits" : 64,
		"resident" : 39,
		"virtual" : 2993,
		"supported" : true,
		"mapped" : 1119,
		"mappedWithJournal" : 2238
	}

单位为M.

resident 表示mongodb进程占用的内存,如果是专用服务器,随着mongodb使用内存的增加,这个参数的值会渐渐接近于系统内存。

如果这个参数的值,超过系统内存并且大量的数据存放在磁盘而不在内存中,我们需要增加硬件能力。


mapped 文件映射的内存量,这个值大致与mongodb数据库的大小相同。

If this value is greater than the amount of system memory, some operations will require disk access page faults to read data from virtual memory and negatively affect performance.


3、Page Faults

分析 db.serverStatus() 输出的 extra_info 部分:

"extra_info" : {
		"note" : "fields vary by platform",
		"heap_usage_bytes" : 62941696,
		"page_faults" : 40
	}

通常对大量数据的读取会产生大量的page faults 会使mongodb 性能下降。解决办法是优化sql或扩充内存。


4、连接数

分析 db.serverStatus() 输出的 connections 部分:

"connections" : {
		"current" : 12,
		"available" : 1626,
		"totalCreated" : NumberLong(8014)
	}
	
"globalLock" : {
		"totalTime" : NumberLong("240481182000"),
		"lockTime" : NumberLong(11670085),
		"currentQueue" : {
			"total" : 0,
			"readers" : 0,
			"writers" : 0
		},
		"activeClients" : {
			"total" : 0,
			"readers" : 0,
			"writers" : 0
		}
	}	

说明 :

globalLock.activeClients contains a counter of the total number of clients with active operations in progress or queued.


connections is a container for the following two fields:

  current the total number of current clients that connect to the database instance.

  available the total number of unused collections available for new clients.



您可能感兴趣的文档:

--结束END--

本文标题: Mongodb监控命令

本文链接: https://www.lsjlt.com/news/41818.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Mongodb监控命令
    Mongodb监控命令一、监控工具1、mongostat工具默认为显示每秒的统计信息# mongostat -uroot -ppassword --authentic...
    99+
    2022-10-18
  • MongoDB监控
    一、          Mongo 相关监控参数设置使用mongo自带的监测工具mongostat ,运维从该工具运行结果中...
    99+
    2022-10-18
  • linux命令中网络命令和监控命令有哪些
    本篇内容主要讲解“linux命令中网络命令和监控命令有哪些”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“linux命令中网络命令和监控命令有哪些”吧!网络和监控命令类似于这些: hostname...
    99+
    2023-06-09
  • Zabbix 监控 MongoDB
    Zabbix 监控 MongoDB 从zabbix共享站点,找到了一个MongoDB的模板:https://share.zabbix.com/databases/mongodb/mongodb-f...
    99+
    2022-10-18
  • Zabbix MongoDB监控
    去年监控mongodb设置的模板,包括mongodb连接数,内存,复制延迟,是否Master的监控,下面是一些监控图形示例我们还有一些触发器,比如mongodb实例是否可用,mongodb副本集的角色是否切...
    99+
    2022-10-18
  • linux命令学习之10个网络命令和监控命令
    网络和监控命令类似于这些: hostname, ping, ifconfig, iwconfig, netstat, nslookup, traceroute, finger, telnet, ethtoo...
    99+
    2022-06-04
    命令 网络 linux
  • netstat命令如何看被监控
    使用netstat命令可以查看网络连接和网络统计信息。要查看是否有被监控,可以使用以下命令:1. 打开命令提示符(Windows)或...
    99+
    2023-09-15
    netstat
  • redis 性能指标监控命令
    redis 性能指标监控命令大家在学习的过程中,一定要学会经常使用help来了解命令的具体用法。1.info  (监控一般使用这个命令读取数据)127.0.0.1:6379> help in...
    99+
    2022-10-18
  • mongodb性能监控
    mongostat: mongostat -u admin --authenticationDatabase admin ...
    99+
    2022-10-18
  • mongodb监控脚本
    脚本涵盖两种监控mongo的方法:使用自带的mongostat工具查看,各个监控项的位置可能要按实际的mongostat输出进行调整;进入admin库,查看具体状态信息,可能需要验证。完整步骤: ...
    99+
    2022-10-18
  • mongodb 性能监控
    使用/var/soft/mongodb2.2/bin/mongostat --port 端口号可以实时监控·inserts/s 每秒插入次数 ·query/s 每秒查询次数 ·update/s 每秒更新次数...
    99+
    2022-10-18
  • mongodb监控指标
    insert 每秒 插入/查询/更新/删除数mongostat --port 21000 --rowcount=1 | grep -v insert | awk '{print $1}'query 每秒 插...
    99+
    2022-10-18
  • 如何监控mongoDB?
    使用mongostat查看公司的数据库状态mongostat --host IPADDRESS:27020 --username root --password PASSWORD --authenticat...
    99+
    2022-10-18
  • MongoDB监控二 mongotop
    mongotop可以查看MongoDB实例花销在读数据或写数据上的时间,它提供集合级别的统计数据,而mongostat是提供数据库级别的统计数据。mongotop默认每秒显示一次数据相关参数选项如下:--h...
    99+
    2022-10-18
  • Zabbix监控mongodb配置
    本文主要介绍zabbix监控mongodb的配置。zabbix监控mongodb需要自定义脚本去监控,脚本可以传入多个参数。原理:通过mongodb客户端连接命令,过滤出db.serverStatus()输...
    99+
    2022-10-18
  • mongodb监控工具mongosniff
    mongodb监控工具mongosniff 介绍 mongosniff提供了对数据库实时活动的低级别操作跟踪和嗅探视图。可以将mongosniff认为是专为MongoDB定制的,类似于t...
    99+
    2022-10-18
  • 使用zabbix监控MongoDB
    现在公司几个游戏项目主要使用MongoDB来存储游戏数据,所以对MongoDB的监控非常重要。关于MongoDB的其他监控方法详见以下几篇文章:MongoDB监控一MongoDB监控二 mongotopMo...
    99+
    2022-10-18
  • 怎么使用pv命令监控Linux命令的执行进度
    小编给大家分享一下怎么使用pv命令监控Linux命令的执行进度,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!PV 命令PV 由Andrew Wood 开发,是 P...
    99+
    2023-06-16
  • 基于JVM性能监控命令介绍
    •jps:JVM Process StatusTool,显示指定系统内所有的HotSpot虚拟机进程•jstat:JVM Statistics Monitoring Tool,用于手机HotSpot虚拟机各方面的运行...
    99+
    2023-05-31
    jvm 性能监控 命令
  • MyCAT的命令行监控工具介绍
    MyCAT命令行监控工具介绍 (1).查看系统运行情况 mysql>show @@server; (2).查看ThreadPool信息 mysql>show @@threadpool; ...
    99+
    2022-10-18
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作