在MySQL的5.7版本中,性能模式是默认开启的,如果想要显式的关闭的话需要修改配置文件,不能直接进行修改,会报错Variable ‘performance_schema’ is a read only variable。

    1. --查看performance_schema的属性
    2. mysql> SHOW VARIABLES LIKE 'performance_schema';
    3. +--------------------+-------+
    4. | Variable_name | Value |
    5. +--------------------+-------+
    6. | performance_schema | ON |
    7. +--------------------+-------+
    8. 1 row in set (0.01 sec)
    9. --在配置文件中修改performance_schema的属性值,on表示开启,off表示关闭
    10. [mysqld]
    11. performance_schema=ON
    12. --切换数据库
    13. use performance_schema;
    14. --查看当前数据库下的所有表,会看到有很多表存储着相关的信息
    15. show tables;
    16. --可以通过show create table tablename来查看创建表的时候的表结构
    17. mysql> show create table setup_consumers;
    18. +-----------------+---------------------------------
    19. | Table | Create Table
    20. +-----------------+---------------------------------
    21. | setup_consumers | CREATE TABLE `setup_consumers` (
    22. `NAME` varchar(64) NOT NULL,
    23. `ENABLED` enum('YES','NO') NOT NULL
    24. ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8 |
    25. +-----------------+---------------------------------
    26. 1 row in set (0.00 sec)

    理解两个基本概念:

    • instruments:生产者

    用于采集mysql中各种各样的操作产生的事件信息,对应配置表中的配置项我们可以称为监控采集配置项。

    • consumers:消费者

    对应的消费者表用于存储来自instruments采集的数据,对应配置表中的配置项我们可以称为消费存储配置项。