mloginfo文檔翻譯

mloginfo

mloginfo獲取一個日誌文件並報告有關該日誌文件的Default Information。 The script also has some options for additional Sections.

Usage

mloginfo [-h] logfile
         [--clients]
         [--connections]
         [--cursors]
         [--distinct]
         [--queries]
            [--rounding {0,1,2,3,4}]
            [--sort {namespace,pattern,count,min,max,mean,95%,sum}]
         [--restarts]
         [--rsstate]
         [--storagestats]
         [--transactions]
            [--tsort {duration}]
         [--verbose]
         [--version]

General Parameters

Help

  • -h, --help

    顯示幫助文本並退出.

Version

  • --version

    顯示版本號並退出.

Verbosity

  • --verbose

    這將打印其他信息,具體取決於每個sections.

Default Information

默認情況下,mloginfo將輸出關於日誌文件的一般信息,包括文件的開始和結束以及行數。如果在文件中發現重啓,它還將輸出二進制文件(mongodmongos)和版本歷史。

Example:

     source: mongod.log
       host: enter.local:27019
      start: 2017 Dec 14 05:56:48.578
        end: 2017 Dec 14 05:57:55.965
date format: iso8601-local
     length: 190
     binary: mongod
    version: 3.4.9
    storage: wiredTiger

Sections

除了一般信息之外,mloginfo還支持不同的信息sections,可以使用附加參數調用這些信息sections。根據不同的sections,收集信息可能需要一些時間。下文將對各sections進行描述。

Queries (--queries)

查詢section將遍歷日誌文件並找到所有查詢(包括來自更新的查詢),併爲每個查詢模式收集一些統計信息。 查詢模式是查詢的形狀或簽名(類似於索引定義),而沒有每個字段的實際查詢值。

本節顯示一個帶有名稱空間的表(使用通常的database.collection語法),查詢模式和各種統計信息,例如查詢該查詢模式的頻率(計數),最小和最大執行時間,均值和總和。 它還會告知執行的操作類型。 該列表按總和排序,這反映了數據庫對於每個查詢模式必須執行的總體工作。 allowDiskUsage(最後一列)參數提供有關名稱空間的磁盤使用情況的信息。 如果使用了磁盤,則慢速查詢日誌條目將顯示值“ True”或“ False”,如果日誌中沒有此信息,則顯示“ None”。

該概述對於瞭解要創建哪些索引以使MongoDB環境獲得最佳性能非常有用。 優化工作應該從列表的頂部開始,然後向下進行,以在不創建索引的情況下獲得最高的總體改進。

例如:

mloginfo mongod.log --queries

除默認信息外,該命令還將輸出QUERIES section:

QUERIES

namespace                  operations    pattern                                        count    min (ms)    max (ms)    mean (ms)       95%-ile (ms)    sum (ms)        allowDiskUse

serverside.scrum_master    update        {"datetime_used": {"$ne": 1}}                     20       15753       17083        16434          1.8          328692          True
serverside.django_session  find          {"_id": 1}                                       562         101        1512          317          2.0          178168          False
serverside.user            find          {"_types": 1, "emails.email": 1}                 804         101        1262          201          1.0          162311          False
local.slaves               find          {"_id": 1, "host": 1, "ns": 1}                   131         101        1048          310          0.0          40738           True
serverside.email_alerts    update        {"_types": 1, "email": 1, "pp_user_id": 1}        13         153       11639         2465          0.0          32053           None
serverside.sign_up         update        {"_id": 1}                                        77         103         843          269          1.8          20761           None
serverside.user_credits    remove        {"_id": 1}                                         6         204         900          369          1.3          2218            None
serverside.counters        remove        {"_id": 1, "_types": 1}                            8         121         500          263          2.1          2111            True
serverside.auth_sessions   update        {"session_key": 1}                                 7         111         684          277          1.0          1940            True
serverside.credit_card     update        {"_id": 1}                                         5         145         764          368          0.0          1840            True
serverside.email_alerts    remove        {"_types": 1, "request_code": 1}                   6         143         459          277          1.3          1663            False
serverside.user            find          {"_id": 1, "_types": 1}                            5         153         427          320          1.9          1601            False
serverside.user            update        {"emails.email": 1}                                2         218         422          320          0.7          640             True
serverside.user            update        {"_id": 1}                                         2         139         278          208          0.4          417             True
serverside.auth_sessions   update        {"session_endtime": 1, "session_userid": 1}        1         244         244          244          0.2          244             False
serverside.game_level      find          {"_id": 1}                                         1         104         104          104          0.1          104             None

--rounding

此選項調整計算統計數據(如平均值和95%-ile)的舍入。

例如:

mloginfo mongod.log --queries --rounding 2

除非還指定了--queries,否則此選項無效。

有效的舍入值是從0到4位小數。默認值是1。

--sort

mloginfo mongod.log --queries --sort count
mloginfo mongod.log --queries --sort sum

除非還指定了--queries,否則此選項無效。

有效排序參數值是namespace, pattern, count, min, max, mean, 95%,和 sum.

默認按sum排序

Restarts (--restarts)

重新啓動部分將遍歷日誌文件並查找所有服務器重新啓動。它將爲每個找到的重新啓動輸出一行,包括日期、時間和版本。

例如:

mloginfo mongod.log --restarts

除了默認信息外,該命令還將輸出RESTART部分:

RESTARTS

Jul 17 09:11:37 version 2.2.2
Jul 18 09:14:21 version 2.2.2
Jul 18 15:53:51 version 2.4.6
Jul 18 13:46:39 version 2.4.6
Jul 19 18:30:04 version 2.4.6

Distinct (--distinct)

distinct部分遍歷日誌文件,並根據消息類型將所有行分組在一起(它使用“log2code”匹配器)。然後,它將爲每個組輸出一行,按降序排列的最大組排序。這將返回日誌文件中出現的行類型的良好概述。

如果日誌文件很大,則此操作可能需要一些時間。

例如:

mloginfo mongod.log --distinct

除了默認信息外,此命令還輸出按消息類型分組的不同消息列表,按匹配行數排序,如下所示。

DISTINCT

776367    connection accepted from ... # ... ( ... now open)
776316    end connection ... ( ... now open)
 25526    info DFM::findAll(): extent ... was empty, skipping ahead. ns:
  9402    ERROR: key too large len: ... max:
    93    Btree::insert: key too large to index, skipping
     6    unindex failed (key too big?) ... key:
     5    old journal file will be removed:
     1    ClientCursor::yield can't unlock b/c of recursive lock ... ns: ... top:
     1    key seems to have moved in the index, refinding.

distinct couldn't match 6 lines
to show non-matched lines, run with --verbose.

如果某些行不能與log2code matcher匹配,則在最後打印未匹配的行數。要顯示無法匹配的所有行,請使用附加的--verbose命令運行mloginfo。

Connections (--connections)

connections部分返回日誌文件中打開和關閉連接的一般信息,以及每個惟一IP地址的打開和關閉連接的統計信息。

例如:

mloginfo mongod.log --connections

除了默認信息外,此命令還輸出連接信息,如下所示。

CONNECTIONS

     total opened: 156765
     total closed: 155183
    no unique IPs: 4
socket exceptions: 915

192.168.0.15      opened: 39758      closed: 39356
192.168.0.17      opened: 39606      closed: 39207
192.168.0.21      opened: 39176      closed: 38779
192.168.0.24      opened: 38225      closed: 37841

Replica Set State Changes (--rsstate)

輸出關於每個檢測到的複製集狀態變化的信息。

例如:

mloginfo mongod.log --rsstate

除了默認信息外,此命令還輸出複製集狀態更改。

RSSTATE
date               host                        state/message

Oct 07 23:22:20    example.com:27017 (self)    replSet info electSelf 0
Oct 07 23:22:21    example.com:27017 (self)    PRIMARY
Oct 07 23:23:14    example.com:27017 (self)    replSet total number of votes is even - add arbiter or give one member an extra vote
Oct 07 23:23:16    example.com:27018           STARTUP2
Oct 07 23:23:32    example.com:27018           RECOVERING
Oct 07 23:23:34    example.com:27018           SECONDARY

Transactions (--transactions)

事務部分將解析日誌文件以查找與事務相關的信息(MongoDB 4.0+)。自動提交指示是否爲事務啓用了自動提交。readConcern信息可以從OperationContext_txnResourceStash獲取。TimeActiveMicrosTimeInactiveMicros表示在事務期間活動和不活動的微處理器數量。duration字段包含以毫秒爲單位的值,並指示每個事務所花費的時間量。

例如:

mloginfo mongod.log --transactions

除了默認信息外,該命令還將輸出TRANSACTIONS部分:

TRANSACTION

DATETIME                       TXNNUMBER       AUTOCOMMIT      READCONCERN     TIMEACTIVEMICROS    TIMEINACTIVEMICROS   DURATION

2019-06-18T12:31:03.180+0100           1         false         "snapshot"                 11142                     3   7
2019-03-18T12:31:03.180+0100           2         false         "snapshot"                 11143                     4   6
2019-07-18T12:31:03.180+0100           3         false         "snapshot"                 11144                     3   4
2019-08-18T12:31:03.180+0100           4         false         "snapshot"                 11145                     4   7
2019-06-18T12:31:03.180+0100           5         false         "snapshot"                 11146                     3   3

--tsort

此選項可用於對--transaction表的結果以及“duration”關鍵字進行排序。

例如:

mloginfo mongod.log --transaction --tsort duration

除非在--transactionduration之間指定,否則此選項無效。

Cursors (--cursors)

如果遊標因超過事務超時而被捕獲,則輸出信息。事務的時間戳、遊標ID以及從日誌中捕獲遊標的時間。

例如:

mloginfo mongod.log --cursors
DATETIME                            CURSORID    REAPEDTIME

2019-06-14 12:31:04.180000+01:00    abc1        2019-06-18 12:31:04.180000+01:00
2019-06-14 12:31:04.180000+01:00    abc2        2019-06-18 12:31:06.180000+01:00
2019-06-14 12:31:04.180000+01:00    abc3        2019-06-18 12:31:08.180000+01:00

Storage Stats (--storagestats)

輸出慢事務的存儲統計信息。

例如:

mloginfo mongod.log --storagestats
namespace                 operation    bytesRead    bytesWritten    timeReadingMicros    timeWritingMicros

config.system.sessions    update       None         None            None                 None
local.myCollection        insert       None         None            None                 None
local.myCollection        update       None         None            None                 None
local1.myCollection       insert       None         None            None                 None
invoice-prod.invoices     insert       12768411     22233323        86313                12344
invoice-prod.invoices     insert       12868411     22233323        86313                12344
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章