我想做某些监控,想将show master status、show slave status、show slave hosts等结果集插入到监控表中,怎么插入呢?
或者告诉我这个show语句是从哪些系统表中读出来的?

解决方案 »

  1.   

     mysql数据库中的slave_开头的表
      

  2.   


    mysql> use mysql;
    Database changed
    mysql> 
    mysql> show tables;
    +---------------------------+
    | Tables_in_mysql           |
    +---------------------------+
    | columns_priv              |
    | db                        |
    | event                     |
    | func                      |
    | general_log               |
    | help_category             |
    | help_keyword              |
    | help_relation             |
    | help_topic                |
    | host                      |
    | ndb_binlog_index          |
    | plugin                    |
    | proc                      |
    | procs_priv                |
    | proxies_priv              |
    | servers                   |
    | slow_log                  |
    | tables_priv               |
    | time_zone                 |
    | time_zone_leap_second     |
    | time_zone_name            |
    | time_zone_transition      |
    | time_zone_transition_type |
    | user                      |
    +---------------------------+
    24 rows in set (0.00 sec)
    没看到相关表呀
      

  3.   

    user INFORMATION_SCHEMA;
    show tables;然后查看MYSQL官方免费手册中对这些表的说明。
      

  4.   

    在MySQL 5.6.2之前,slave记录的master信息以及slave应用binlog的信息存放在文件中,即master.info与relay-log.info。在5.6.2版本之后,允许记录到table中,参数设置如下:
    master-info-repository  = TABLE    ---FILE表示以文件方式
    relay-log-info-repository = TABLE   ---FILE表示以文件方式
    对应的表分别为mysql.slave_master_info与mysql.slave_relay_log_info,且这两个表均为innodb引擎表。
    mysql> select * from mysql.slave_master_info\G:
    *************************** 1. row ***************************
           Number_of_lines: 23
           Master_log_name: mysql-bin.000129
            Master_log_pos: 760146983
                      Host: 192.168.6.111
                    User_name: repl
             User_password: password
                      Port: 3307
             Connect_retry: 60
               Enabled_ssl: 0
                    Ssl_ca: 
                Ssl_capath: 
                  Ssl_cert: 
                Ssl_cipher: 
                   Ssl_key: 
    Ssl_verify_server_cert: 0
                 Heartbeat: 1800
                      Bind: 
        Ignored_server_ids: 0
                      Uuid: 6c8a10ed-ed0b-11e4-91eb-00163ec546aa
               Retry_count: 86400
                   Ssl_crl: 
               Ssl_crlpath: 
     Enabled_auto_position: 1
    1 row in set (0.07 sec)
    并且你想要show slave hosts 从库还得设置更加精细的参数
    report-host=192.168.6.111
    report-port=3307
      

  5.   

    检查一下GLOBAL_STATUS表,估计应该在这里面。