溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Mongodb數(shù)據(jù)庫中mongostat工具用法

發(fā)布時間:2020-08-10 15:30:24 來源:網(wǎng)絡 閱讀:949 作者:xiaocao13140 欄目:MongoDB數(shù)據(jù)庫

mongostat是mongoDB自帶的工具,用于檢測mongodb的運行狀態(tài)。

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秒數(shù)據(jù),每1秒鐘輸出

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

300秒數(shù)據(jù),每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中所有節(jié)點的60s內(nèi)運行狀態(tài),間隔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

監(jiān)控復制集Primary節(jié)點 80.81.2.4 的狀態(tài)

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操作次數(shù)
query 每秒query操作次數(shù)
update 每秒update操作次數(shù)
delete 每秒delete操作次數(shù)
getmore每秒getmore操作次數(shù)
command每秒command執(zhí)行次數(shù)
flushes每秒執(zhí)行fsync將數(shù)據(jù)寫入硬盤的次數(shù)
vsize 虛擬內(nèi)存使用量,單位是MB
res 物理內(nèi)存使用量,單位MB
qr|qw 隊列中waiting的讀/寫次數(shù)
ar|aw 已激活active的讀/寫次數(shù)
netIn 接收端網(wǎng)絡速率,單位是bytes
netOut發(fā)送端網(wǎng)絡速率,單位是bytes
conn 連接數(shù)(open connections)
set 復制集(replica set)名稱
repl 成員在復制集中的狀態(tài)(PRI|SEC|ARB|REC)
向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI