MongoDB效能分析工具mongostat使用方法

來源:互聯網
上載者:User

MongoDB效能分析工具mongostat使用方法

mongostat是MongoDB內建的效能分析工具,用於檢測mongodb的運行狀態。

Test:Test/node-131 / # mongostat --help
Usage:
mongostat <options> <polling interval in seconds>

Monitor basic MongoDB server statistics.

See http://docs.mongodb.org/manual/reference/program/mongostat/ for more information.

general options:
--help print usage
--version print the tool version and exit

verbosity options:
-v, --verbose=<level> more detailed log output (include multiple times for more verbosity, e.g. -vvvvv, or specify a numeric value, e.g. --verbose=N)
--quiet hide all log output

connection options:
-h, --host=<hostname> mongodb host to connect to (setname/host1,host2 for replica sets)
--port=<port> server port (can also use --host hostname:port)

ssl options:
--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

authentication options:
-u, --username=<username> username for authentication
-p, --password=<password> password for authentication
--authenticationDatabase=<database-name> database that holds the users credentials
--authenticationMechanism=<mechanism> authentication mechanism to use

stat options:
--noheaders dont 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

舉例:

20秒資料,每1秒鐘輸出

mongostat -h 80.81.2.3 -p 27017 --rowcount 20 1

300秒資料,每5秒輸出

mongostat -h 80.81.2.3 -p 27017 -n 300 5

以json格式輸出

mongostat -h 80.81.2.4 -p 27017 -n 60 1 --json

搜集複製集aCloud中所有節點的60s內運行狀態,間隔1s重新整理,儲存到檔案mongostat_aCloud.log中。

mongostat -h aCloud/80.81.2.4,80.81.2.5,80.81.2.6 -p 27017 -n 60 1 >> mongostat_aCloud.log

監控複製集Primary節點 80.81.2.4 的狀態

Sangfor:aCloud/node-131 /var/lib/mongodb # mongostat -h 80.81.2.4 -p 27017 -n 60 1
insert query update delete getmore command % dirty % used flushes vsize res qr|qw ar|aw netIn netOut conn set repl time
4327 0 0 0 445 748|0 0.5 4.1 0 1.1G 437.0M 0|0 0|0 834k 1m 7 aCloud PRI 2016-07-21T20:56:48+08:00
3857
0 0 0 442 752|0 0.5 4.1 0 1.1G 438.0M 0|0 0|0 771k 1m 7 aCloud PRI 2016-07-21T20:56:49+08:00

結果解析:

insert 每秒instert操作次數query 每秒query操作次數update 每秒update操作次數delete 每秒delete操作次數getmore每秒getmore操作次數command每秒command執行次數flushes每秒執行fsync將資料寫入硬碟的次數vsize 虛擬記憶體使用量,單位是MBres 實體記憶體使用量,單位MBqr|qw 隊列中waiting的讀/寫次數ar|aw 已啟用active的讀/寫次數netIn 接收端網路速率,單位是bytesnetOut發送端網路速率,單位是bytesconn 串連數(open connections)set 複製集(replica set)名稱repl 成員在複製集中的狀態(PRI|SEC|ARB|REC)

更多MongoDB相關教程見以下內容:

MongoDB文檔、集合、資料庫簡介 

MongoDB 3分區部署及故障類比驗證 

Linux CentOS 6.5 yum安裝MongoDB 

CentOS 7 yum方式快速安裝MongoDB 

MongoDB的查詢操作 

在 Azure 虛擬機器上快速搭建 MongoDB 叢集 

MongoDB複製集原理 

MongoDB 3.4 遠端連線認證失敗 

Ubuntu 16.04中安裝MongoDB3.4資料庫系統 

MongoDB權威指南第2版PDF完整帶書籤目錄 下載見

MongoDB 的詳細介紹:請點這裡
MongoDB 的:請點這裡

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.