zoukankan      html  css  js  c++  java
  • ubuntu 安装使用 mytop

    apt搜索一下

    $ sudo apt search mytop
    Sorting... Done
    Full Text Search... Done
    mytop/focal,focal,now 1.9.1-4 all
      top like query monitor for MySQL

    然后安装一下

     sudo apt-get install mytop  

    直接执行 mytop 报错

    $ mytop
    Cannot connect to MySQL server. Please check the:
    
      * database you specified "" (default is "")
      * username you specified "root" (default is "root")
      * password you specified "" (default is "")
      * hostname you specified "localhost" (default is "localhost")
      * port you specified "3306" (default is 3306)
      * socket you specified "" (default is "")
    
    The options my be specified on the command-line or in a ~/.mytop or
    ~/.my.cnf config file. See the manual (perldoc mytop) for details.
    
    Here's the exact error from DBI. It might help you debug:
    
    Access denied for user 'root'@'localhost' (using password: NO)

    说我没有找到 .mytop 或者 my.cnf 文件,那么这个文件应该怎么配置呢?通过find寻找发现了跟mytop有关的文件夹

    $ sudo find / -name "mytop"
    find: ‘/proc/2308/task/2308/net’: Invalid argument
    find: ‘/proc/2308/net’: Invalid argument
    find: ‘/run/user/1001/doc’: Permission denied
    find: ‘/run/user/1001/gvfs’: Permission denied
    /usr/bin/mytop
    /usr/share/doc/mytop

    这个就是可执行文件,不是它

    $ ll /usr/bin/mytop 
    -rwxr-xr-x 1 root root 60K 1月  10  2017 /usr/bin/mytop*

     发现这个有配置,然后查看一下这个默认配置有个参考

    $ ll /usr/share/doc/mytop
    total 12K
    -rw-r--r-- 1 root root 2.2K 1月  10  2017 changelog.Debian.gz
    -rw-r--r-- 1 root root 1.3K 1月  10  2017 copyright
    -rw-r--r-- 1 root root  871 1月  10  2017 mytop.sample.conf

    发现了这个 simple conf 。好了,如此以来应该是要按这个配置,看一下它的内容

    # Copy this file to ~/.mytop and customize it to your own needs
    
    # Username to use when logging in to the MySQL server
    user=root
    # Password to use when logging in to the MySQL server
    pass=
    # Hostname of the MySQL server.
    host=localhost
    # Port number of the MySQL server.
    port=3306
    # Connect to specific database by default.
    db=test
    # How long between display refreshes.
    delay=5
    # Use direct socket instead of TCP/IP network to connect to the MySQL server.
    socket=
    # Run mytop only once and than exit.
    batchmode=0
    # Display headers or not.
    header=1
    # Use colors if available.
    color=1
    # Display idle threads.
    idle=1
    # Resolve IP addresses to names.
    resolve=1
    # Compact large numbers for better readability, e.g. 10.000 -> 10.0k.
    long=0
    # Reverse sort order from ascending to descending using Idle time.
    sort=0
    # Use vt100 escape sequences to reduce screen flicker.
    vt100=0

    然后配置一份文件到 

    touch ~/.mytop

    这个文件里面配置如下内容

    # Copy this file to ~/.mytop and customize it to your own needs
    
    # Username to use when logging in to the MySQL server
    user=root
    # Password to use when logging in to the MySQL server
    pass=密码
    # Hostname of the MySQL server.
    host=localhost
    # Port number of the MySQL server.
    port=3306
    # Connect to specific database by default.
    db=test
    # How long between display refreshes.
    delay=5
    # Use direct socket instead of TCP/IP network to connect to the MySQL server.
    socket=/tmp/mysql.sock
    # Run mytop only once and than exit.
    batchmode=0
    # Display headers or not.
    header=1
    # Use colors if available.
    color=1
    # Display idle threads.
    idle=1
    # Resolve IP addresses to names.
    resolve=1
    # Compact large numbers for better readability, e.g. 10.000 -> 10.0k.
    long=0
    # Reverse sort order from ascending to descending using Idle time.
    sort=0
    # Use vt100 escape sequences to reduce screen flicker.
    vt100=0

     如此以来就配置好了。重新启动一下看看。

    $ mytop

    得到

     这样以来就可以用它监控mysql 的 qps 了

  • 相关阅读:
    最流行的javascript 代码规范
    jquery里阻止冒泡ev.stopPropagation()
    jquery里阻止冒泡ev.stopPropagation()
    响应式页面设计原理
    fromCharCode()的用法
    slice的用法
    java 反转数组
    java 一个数组的长度
    Java访问数组
    java 数组的定义
  • 原文地址:https://www.cnblogs.com/lizhaoyao/p/15319547.html
Copyright © 2011-2022 走看看