MySQL管理工具MySQL Utilities — mysqlserverinfo(22)

默北 MySQLMySQL管理工具MySQL Utilities — mysqlserverinfo(22)已关闭评论9,776字数 6449阅读21分29秒阅读模式

mysqlserverinfo 用于显示和诊断服务器信息,查看当前mysql进行的运行环境配置,内容有:

  • 服务器连接信息
  • 服务器版本信息
  • 数据目录路径名称
  • 基础目录路径名称
  • 插件目录路径名称
  • 配置文件位置与名称
  • 当前二进制日志位置与名称
  • 当前relay 日志位置与名称

该工具也可以查看离线状态下的mysql信息。如果想查看离线状态下的信息,该工具启动服务只读模式。在这种情况下,必需指定--basedir, --datadir 和 --start 选项。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

输出格式

指定以何种格式显示输出,通过--format 选项指定:文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

  • grid (default)

    Display output in grid or table format like that of the mysql client command-line tool.

  • csv

    Display output in comma-separated values format.

  • tab

    Display output in tab-separated format.

  • vertical

    Display output in single-column format like that of the \G command for the mysql client command-line tool.

这里就不再累述的解释了。MySQL Utilities 工具基本上就是这几种格式输出的,前面文章都有解释的,不清楚可以看看前面的文章。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

如果要关闭 grid, csv 和 tab 输出格式的头部,可以指定 --no-headers 选项。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

# mysqlserverinfo --server=instance_3306 -d --format=grid -vvv  --show-defaults  --no-headers        
# Source on localhost: ... connected.
+-----------------+---------------------------+------------------------+-----------------+------------+----------------+-------------+--------------------+----------+---------------------------+--------------+-------------------+------------------------+---------------------------------------------+----------------------+-----------------+----------------------+---------------------------+
| localhost:3306  | /etc/my.cnf, /usr/my.cnf  | mysql-bin-3306.000002  | 276714          |            |                | 5.6.22-log  | /data/mydata3306/  | /usr     | /usr/lib64/mysql/plugin/  | OFF          |                   |                        | /data/mydata3306/localhost.localdomain.err  | 17612 bytes          | OFF             |                      |                           |
+-----------------+---------------------------+------------------------+-----------------+------------+----------------+-------------+--------------------+----------+---------------------------+--------------+-------------------+------------------------+---------------------------------------------+----------------------+-----------------+----------------------+---------------------------+
  
Defaults for server localhost:3306
#...done.
# mysqlserverinfo --server=instance_3306 -d --format=grid -vvv  --show-defaults  
# Source on localhost: ... connected.
+-----------------+---------------------------+------------------------+-----------------+------------+----------------+-------------+--------------------+----------+---------------------------+--------------+-------------------+------------------------+---------------------------------------------+----------------------+-----------------+----------------------+---------------------------+
| server          | config_file               | binary_log             | binary_log_pos  | relay_log  | relay_log_pos  | version     | datadir            | basedir  | plugin_dir                | general_log  | general_log_file  | general_log_file_size  | log_error                                   | log_error_file_size  | slow_query_log  | slow_query_log_file  | slow_query_log_file_size  |
+-----------------+---------------------------+------------------------+-----------------+------------+----------------+-------------+--------------------+----------+---------------------------+--------------+-------------------+------------------------+---------------------------------------------+----------------------+-----------------+----------------------+---------------------------+
| localhost:3306  | /etc/my.cnf, /usr/my.cnf  | mysql-bin-3306.000002  | 276714          |            |                | 5.6.22-log  | /data/mydata3306/  | /usr     | /usr/lib64/mysql/plugin/  | OFF          |                   |                        | /data/mydata3306/localhost.localdomain.err  | 17612 bytes          | OFF             |                      |                           |
+-----------------+---------------------------+------------------------+-----------------+------------+----------------+-------------+--------------------+----------+---------------------------+--------------+-------------------+------------------------+---------------------------------------------+----------------------+-----------------+----------------------+---------------------------+
  
Defaults for server localhost:3306
#...done.

查看共同默认设置的配置文件,使用 --show-defaults 选项。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

可以查看多个服务实例,需要指定多个 --server 选项。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

查看本机上运行的mysql服务,使用 --show-servers 选项,显示所有服务的进程ID和数据目录。Windows下只显示进程ID和端口号。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

# mysqlserverinfo --server=instance_3306 -d --format=vertical   --show-defaults  --no-headers  --server=instance_3307 --show-servers
# 
# The following MySQL servers are active on this host:
#  Process id:   8185, Data path: 
#  Process id:   8186, Data path: 
#  Process id:   8464, Data path: 
#  Process id:  20050, Data path: 
# 
# Source on localhost: ... connected.
# Source on localhost: ... connected.
*************************       1. row *************************
                   server: localhost:3306
              config_file: /etc/my.cnf, /usr/my.cnf
               binary_log: mysql-bin-3306.000002
           binary_log_pos: 276714
                relay_log: 
            relay_log_pos: 
                  version: 5.6.22-log
                  datadir: /data/mydata3306/
                  basedir: /usr
               plugin_dir: /usr/lib64/mysql/plugin/
              general_log: OFF
         general_log_file: 
    general_log_file_size: 
                log_error: /data/mydata3306/localhost.localdomain.err
      log_error_file_size: 17612 bytes
           slow_query_log: OFF
      slow_query_log_file: 
 slow_query_log_file_size: 
*************************       2. row *************************
                   server: localhost:3307
              config_file: /etc/my.cnf, /usr/my.cnf
               binary_log: mysql-bin-3307.000002
           binary_log_pos: 1016538
                relay_log: 
            relay_log_pos: 
                  version: 5.6.22-log
                  datadir: /data/mydata3307/
                  basedir: /usr
               plugin_dir: /usr/lib64/mysql/plugin/
              general_log: OFF
         general_log_file: 
    general_log_file_size: 
                log_error: /data/mydata3307/localhost.localdomain.err
      log_error_file_size: 22415 bytes
           slow_query_log: OFF
      slow_query_log_file: 
 slow_query_log_file_size: 
2 rows.
  
Defaults for server localhost:3307
#...done.

选项

# mysqlserverinfo --help
MySQL Utilities mysqlserverinfo version 1.5.3 
License type: GPLv2
Usage: mysqlserverinfo --server=user:pass@host:port:socket --format=grid

mysqlserverinfo - show server information

Options:
  --version             show program's version number and exit
  --help                display a help message and exit
  --license             display program's license and exit
  --server=SERVER       connection information for the server in the form:
                        <user>[:<password>]@<host>[:<port>][:<socket>] or
                        <login-path>[:<port>][:<socket>] or <config-
                        path>[<[group]>].
  --ssl-ca=SSL_CA       The path to a file that contains a list of trusted SSL
                        CAs.
  --ssl-cert=SSL_CERT   The name of the SSL certificate file to use for
                        establishing a secure connection.
  --ssl-key=SSL_KEY     The name of the SSL key file to use for establishing a
                        secure connection.
  -f FORMAT, --format=FORMAT
                        display the output in either grid (default), tab, csv,
                        or vertical format
  -h, --no-headers      do not show column headers (only applies to formats:
                        grid, tab, csv).
  -d, --show-defaults   show defaults from the config file per server
  -s, --start           start server in read only mode if offline
  --basedir=BASEDIR     the base directory for the server。离线时需要
  --datadir=DATADIR     the data directory for the server。离线时需要
  --port-range=PORTS    the port range to search for running mysql servers on
                        Windows systems。此选项仅适用于Windows,如果有使用 --show-servers 
                        选项,该选项被忽略。默认范围:3306:3333。
  --show-servers        show any known MySQL servers running on this host
  --start-timeout=START_TIMEOUT
                        Number of seconds to wait for the server to start.
                        Default = 10.
  -v, --verbose         control how much information is displayed. e.g., -v =
                        verbose, -vv = more verbose, -vvv = debug

权限

读取mysql数据库访问数据目录的权限。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/ 文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/

weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
默北
  • 本文由 发表于 27/02/2015 01:00:10
  • 转载请务必保留本文链接:https://www.ttlsa.com/mysql/mysql-utilities-mysqlserverinfo/