• 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

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

  • 相关阅读:
    Forrester:开源APM发展势头强劲
    Forrester:开源APM发展势头强劲
    canvas 绘图api的位置问题
    canvas 绘图api的位置问题
    canvas 绘图api的位置问题
    canvas 绘图api的位置问题
    Android应用层View绘制流程与源码分析
    Android应用层View绘制流程与源码分析
    Android应用层View绘制流程与源码分析
    未来5年到底是做什么生意最好?
  • 原文地址:https://www.cnblogs.com/zmc60/p/16274151.html
Copyright © 2020-2023  润新知