1.profile
0,關閉profile;1,隻抓取slow查詢;2,抓取所有資料。
可以通過mongo shell啟動,也可以通過驅動中的profile指令啟動,啟動後記錄會被儲存在system.profile collection下,可以使用db.setProfilingLevel來啟動。預設slow為100 毫秒。db.setProfilingLevel可以有2個參數,第一個參數指定Profiling 級别,第二個參 數指定slow閥值。
檢查目前Profiling 級别:可以通過db.getProfilingStatus()擷取目前profiling級别,slowms 标記慢查詢閥值。
關閉Profiling:還是使用db.setProfilingLevel(0)來關閉profiling
整個執行個體開啟Profiling:mongod --prifile=1 --slowms=15
shard的Profiling:對shard的profiling要對每一個執行個體進行profiling
可以直接在system.profile的collection上檢視如:db.systen.profile.find()。或者使用show profile,會顯示最近至少1ms時間運作的前5條記錄。
要修改system.profile collection的大小必須:1.關閉profiling,2.删除system.profile,3.然後重新建立system.profile,4.重新開機profile。
shell如下:db.setProfilingLevel(0)
,db.system.profile.drop()
,db.createCollect("system.profile",{cappedLtrue,size:4000000})
,db.setProfilingLevel(1)
2.Mongostat
<a href="http://docs.mongodb.org/manual/reference/program/mongostat/">http://docs.mongodb.org/manual/reference/program/mongostat/</a>
inserts - # of inserts per second (* means replicated op)
query - # of queries per second
update - # of updates per second
delete - # of deletes per second
getmore - # of get mores (cursor batch) per second
command - # of commands per second, on a slave its local|replicated
flushes - # of fsync flushes per second
mapped - amount of data mmaped (total data size) megabytes
vsize - virtual size of process in megabytes
res - resident size of process in megabytes
faults - # of pages faults per sec
locked - name of and percent time for most locked database
idx miss - percent of btree page misses (sampled)
qr|qw - queue lengths for clients waiting (read|write)
ar|aw - active clients (read|write)
netIn - network traffic in - bits
netOut - network traffic out - bits
conn - number of open connections
set - replica set name
repl - replication type
PRI - primary (master)
SEC - secondary
REC - recovering
UNK - unknown
SLV - slave
RTR - mongos process ("router")
3.Mongoop
collection級别反應,讀寫的時間
http://docs.mongodb.org/manual/reference/program/mongotop/
mongotop -h 192.168.10.69 2,每間隔2秒傳回一次結果
ns total read write 2014-05-09T14:00:55
ub1405.system.users 0ms 0ms 0ms
ub1405.system.profile 0ms 0ms 0ms
b1405.system.namespaces 0ms 0ms 0ms
ub1405.system.indexes 0ms 0ms 0ms
ub1405.WapRecommend 0ms 0ms 0ms
ub1405.VisitPageInfo 0ms 0ms 0ms
ub1405.UsageInfo 0ms 0ms 0ms
ub1405.UpgradeInfo 0ms 0ms 0ms
ub1405.Switch 0ms 0ms 0ms
用來測試io性能,可以用來做mongo的io壓力測試,和sql server的SQLIOSim
http://docs.mongodb.org/manual/reference/program/mongoperf/
5. ServerStatus db.serverStatus()
包含了很多資訊
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525193">1.執行個體資訊</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525194">2.鎖</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525195">3.全局鎖</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525196">4.記憶體使用</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525197">5.連接配接</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525198">6.額外資訊</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525199">7.索引計數器</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525200">8.cursors</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525201">9.網絡</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525202">10.複制集</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525203">11.複制集操作集數</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525204">12.操作計數器</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525205">13.斷言</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525206">14.writeBackQueued</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525207">15.Journal(dur)持久性</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525208">16.recordStats</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525209">17.工作集(workingSet)</a>
<a href="http://www.cnblogs.com/Amaranthus/p/3721155.html#_Toc387525210">18.名額(metrics)</a>
6.db.stats()
反應資料庫所占用的存儲
{
"db" : "ub1405",
"collections" : 17,
"objects" : 9939344,
"avgObjSize" : 336.2453477815035,
"dataSize" : 3342058180,
"storageSize" : 4501643264,
"numExtents" : 111,
"indexes" : 15,
"indexSize" : 322633136,
"fileSize" : 8519680000,
"nsSizeMB" : 16,
"dataFileVersion" : {
"major" : 4,
"minor" : 5
},
"ok" : 1
}
7.db.collection.stats()
傳回collection的一些資訊:
"ns" : "ub1405.WapRecommend",
"count" : 514,
"size" : 174416,
"avgObjSize" : 339.3307392996109,
"storageSize" : 430080,
"numExtents" : 3,
"nindexes" : 1,
"lastExtentSize" : 327680,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 24528,
"indexSizes" : {
"_id_" : 24528