工具mtools安装

mtools是一个用于解析、过滤和可视化MongoDB日志文件的Python脚本集合,包括mlogfilter、mloginfo等。此外,它还提供mlaunch用于快速搭建本地测试环境。本文介绍了mtools的组成部分、安装过程以及依赖项,适用于Python 2.7和3.6版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Mtools工具介绍

可以在源码包解压目录中,读取README.rst。也可以在github上https://github.com/rueckstiess/mtools下拉菜单可以看到,和readme.rst 是一样的

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.

Mtools是帮助解析、过滤、可视化mongodb日志文件的一系列集合。它也包含mlaunch工具(可以快速的在本地服务器上部署复杂的mongodb测试环境)

Mtools工具组成
The following tools are in the mtools collection:

  • mlogfilter

slices log files by time, merges log files, filters slow queries, finds table scans, shortens log lines, filters by other attributes, convert to JSON

  • mloginfo

returns info about log file, like start and end time, version, binary, special sections like restarts, connections, distinct view

  • mplotqueries

visualize log files with different types of plots (requires matplotlib)

  • mlogvis

creates a self-contained HTML file that shows an interactive visualization in a web browser (as an alternative to mplotqueries)

  • mlaunch

a script to quickly spin up local test environments, including replica sets and sharded systems (requires pymongo)
For more information, see the mtools documentation.

安装需求和说明
The mtools collection is written in Python, and most of the tools only use the standard packages shipped with Python. The tools are currently tested with Python 2.7 and 3.6.
Some of the tools have additional dependencies, which are listed under the specific tool’s section. See the installation instructionsfor more information.
The mtools suite is only tested with actively supported (non End-of-Life) versions of the MongoDB server. As of April 2018, that includes MongoDB 3.2 or newer.

Mtools工具下载

https://github.com/rueckstiess/mtools

在下面中的release中可以选择要下载的版本

截止笔记整理今天(2018-09-02),最新的版本是mtools-1.5.1,下载源码包

Mtools工具安装

安装python3.7

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

[root@mysql-2 ~]# tar -xvf Python-3.7.0.tgz

[root@mysql-2 ~]# cd Python-3.7.0/
[root@mysql-2 Python-3.7.0]# ./configure –prefix=/usr/local/python3.7

[root@mysql-2 Python-3.7.0]# make
[root@mysql-2 Python-3.7.0]# make install

在make install最后报错如下
ModuleNotFoundError: No module named ‘_ctypes’
make: * [install] Error 1

解决是安装下面包
[root@mysql-2 Python-3.7.0]# yum install libffi-devel -y

然后从新make install最后就得到下面
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

[root@mysql-2 Python-3.7.0]# cd /usr/local/python3.7/
[root@mysql-2 python3.7]# ls
bin include lib share
[root@mysql-2 python3.7]# cd bin
[root@mysql-2 bin]# ls
2to3 easy_install-3.7 idle3.7 pip3.7 pydoc3.7 python3.7 python3.7m python3-config pyvenv-3.7
2to3-3.7 idle3 pip3 pydoc3 python3 python3.7-config python3.7m-config pyvenv

安装mtools工具

在源码包解压目录里,有个INSTALL.md文件。也可以从github上看到如下图

两个说法是一样的,有两种安装Installation from source和Installation with pip。Pip需要上网,因此采用source安装

[root@mysql-2 ~]# tar -xvf mtools-1.5.1.tar.gz
[root@mysql-2 ~]# cd mtools-1.5.1/
[root@mysql-2 mtools-1.5.1]# /usr/local/python3.7/bin/python3.7 setup.py install

中途输出,可以看出有些工具安装在python目录下了
Adding mtools 1.5.1 to easy-install.pth file
Installing mgenerate script to /usr/local/python3.7/bin
Installing mlaunch script to /usr/local/python3.7/bin
Installing mlogfilter script to /usr/local/python3.7/bin
Installing mloginfo script to /usr/local/python3.7/bin
Installing mlogvis script to /usr/local/python3.7/bin
Installing mplotqueries script to /usr/local/python3.7/bin

最后输出
Installed /usr/local/python3.7/lib/python3.7/site-packages/six-1.11.0-py3.7.egg
Finished processing dependencies for mtools==1.5.1

[root@mysql-2 bin]# cd /usr/local/python3.7/bin
[root@mysql-2 bin]# ll -thr
total 27M
-rwxr-xr-x 2 root root 14M Sep 4 00:20 python3.7m
-rwxr-xr-x 2 root root 14M Sep 4 00:20 python3.7
-rwxr-xr-x 1 root root 451 Sep 4 00:21 pyvenv-3.7
-rwxr-xr-x 1 root root 94 Sep 4 00:21 pydoc3.7
-rwxr-xr-x 1 root root 109 Sep 4 00:21 idle3.7
-rwxr-xr-x 1 root root 111 Sep 4 00:21 2to3-3.7
-rwxr-xr-x 1 root root 3.1K Sep 4 00:21 python3.7m-config
lrwxrwxrwx 1 root root 9 Sep 4 00:21 python3 -> python3.7
lrwxrwxrwx 1 root root 17 Sep 4 00:21 python3.7-config -> python3.7m-config
lrwxrwxrwx 1 root root 16 Sep 4 00:21 python3-config -> python3.7-config
lrwxrwxrwx 1 root root 7 Sep 4 00:21 idle3 -> idle3.7
lrwxrwxrwx 1 root root 8 Sep 4 00:21 pydoc3 -> pydoc3.7
lrwxrwxrwx 1 root root 8 Sep 4 00:21 2to3 -> 2to3-3.7
lrwxrwxrwx 1 root root 10 Sep 4 00:21 pyvenv -> pyvenv-3.7
-rwxr-xr-x 1 root root 252 Sep 4 00:21 easy_install-3.7
-rwxr-xr-x 1 root root 234 Sep 4 00:21 pip3.7
-rwxr-xr-x 1 root root 234 Sep 4 00:21 pip3
-rwxr-xr-x 1 root root 403 Sep 4 00:30 mlogfilter
-rwxr-xr-x 1 root root 397 Sep 4 00:30 mlaunch
-rwxr-xr-x 1 root root 401 Sep 4 00:30 mgenerate
-rwxr-xr-x 1 root root 407 Sep 4 00:30 mplotqueries
-rwxr-xr-x 1 root root 397 Sep 4 00:30 mlogvis
-rwxr-xr-x 1 root root 399 Sep 4 00:30 mloginfo
[root@mysql-2 bin]#

### 如何在 Windows 上安装 Mtools 对于希望在 Windows 操作系统上使用 `mtools` 的用户来说,需要注意的是 `mtools` 主要设计用于 Unix-like 系统如 Linux 和 macOS,在这些平台上可以直接通过包管理器轻松获取并安装。然而,在 Windows 平台上并没有官方提供的直接安装方式[^2]。 尽管如此,有几种方法可以让 Windows 用户运行 `mtools`: #### 方法一: 使用 WSL (Windows Subsystem for Linux) 微软推出的 WSL 功能允许用户无需修改 BIOS 设置即可在同一台机器上同时运行 Windows 和类 Unix 环境下的应用程序。这为想要在 Windows 中利用 `mtools` 提供了一个理想的解决方案。 1. 安装 WSL 及其首选的 Linux 发行版。 2. 打开已安装的 Linux 终端窗口。 3. 利用发行版自带的软件源来安装 `mtools`,例如在基于 Debian 或 Ubuntu 的环境中可以执行如下命令: ```bash sudo apt-get update && sudo apt-get install mtools ``` 这种方法不仅能让用户获得完整的 `mtools` 功能集,而且还能享受到其他众多 GNU/Linux 工具带来的便利。 #### 方法二: 编译自定义版本 如果确实需要原生支持,则可能要考虑自行编译适用于 Windows 的 `mtools` 版本。不过这种方式较为复杂,涉及到跨平台开发的知识和技术栈,通常只推荐给具备一定编程经验的技术人员尝试。 考虑到上述情况,建议大多数情况下优先考虑采用 WSL 来间接实现目标需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值