• 2.Mongodb问题诊断工具mtools


    1.前言

      mtools是一组分析、过滤和可视化mongodb日志的帮助脚本,它还包含了mlaunch,一个用于在本地机器上快速设置复杂MongoDB 测试环境的使用程序,已经mtransfer,一个用于在Mongdb实例之间传输数据库的工具。

    来自githup:https://github.com/rueckstiess/mtools

    mtools is a collection of helper scripts to parse, filter, and visualize MongoDB log files (mongod, mongos). mtools also includes mlaunch, a utility to quickly set up complex MongoDB test environments on a local machine, and mtransfer, a tool for transferring databases between MongoDB instances.

    Mtools主要有以下组件:

    mlogfilter
    mloginfo
    mplotqueries
    mlogvis
    mlaunch
    mgenerate

    1.mlogfilter语法:可以简单理解为日志的过滤器  

    mlogfilter [-h] [--version] logfile [logfile ...]
               [--verbose] [--shorten [LENGTH]]
               [--human] [--exclude] [--json]
               [--timestamp-format {ctime-pre2.4, ctime, iso8601-utc, iso8601-local}]
               [--markers MARKERS [MARKERS ...]] [--timezone N [N ...]]
               [--namespace NS] [--operation OP] [--thread THREAD]
               [--slow [SLOW]]  [--fast [FAST]] [--scan]
               [--word WORD [WORD ...]]
               [--from FROM [FROM ...]] [--to TO [TO ...]]

    2.mloginfo:可以过滤总结出slow query的情况,以及为日志各类最常出现情况进行统计

    mloginfo [-h] [--version] logfile
             [--verbose] 
             [--queries] [--restarts] [--distinct] [--connections] [--rsstate]

    3.mplotqueryies:可视化具有不同类型的日志文件

    mplotqueries [-h] [--version] logfile [logfile ...]
                 [--group GROUP]
                 [--logscale]
                 [--type {nscanned/n,rsstate,connchurn,durline,histogram,range,scatter,event} ]
                 [--overlay [ {add,list,reset} ]]
                 [additional plot type parameters]

    4安装:

      1.python3环境部署,centos 7默认的python版本是2.7,mtools工具需要依赖python3的环境 

    # yum install python3
    # python3 --version

      2.安装mtools工具  

    # wget -c https://github.com/rueckstiess/mtools/archive/refs/tags/v1.6.4.tar.gz
    # tar xf v1.6.4.tar.gz -C /usr/local/
    # cd /usr/local/mtools-1.6.4/
    # python3 setup.py install

    5.用法

    https://mongoing.com/eshu_mtools

    https://www.cnblogs.com/littleatp/p/9114471.html

    https://blog.csdn.net/weixin_37692493/article/details/118399164

    这里奇怪,我的mloginfo等工具不能解析mong.log日志

    [root@mongodb mongo_log]# mlogfilter mongo.log  --slow --json
    Error: <mongo.log> does not appear to be a supported MongoDB log file format

    出现如上报错,这里先记录一下。。。

  • 相关阅读:
    C# 編譯錯誤 CS0016 解決方案
    Javascript 日期
    Javascript Url处理
    Linq中in用法
    oracle中的排名函数用法
    webservices [WebServiceBinding(ConformsTo = WsiProfiles.None)]
    C#中的多态
    C# Math类简介 (转)
    客服工单任务系统发展简史 商商
    jQuery LigerUI 使用教程表格篇(2) 服务器数据交互
  • 原文地址:https://www.cnblogs.com/zmc60/p/16274151.html
Copyright © 2020-2023  润新知