在使用 sys 架构之前,必须满足本节所述的先决条件。Before using the sys schema, the
prerequisites described in this section must be satisfied.
因为 sys 架构提供了一种访问 Performance Schema 的替代方式,因此必须启用 Performance Schema 才能使 sys 架构正常工作。请参见 第 29.3 节,“Performance Schema 启动配置”。Because the sys schema provides an
alternative means of accessing the Performance Schema, the
Performance Schema must be enabled for the
sys schema to work. See
Section 29.3, “Performance Schema Startup Configuration”.
要完全访问 sys 架构,用户必须具备以下权限:For full access to the sys schema, a
user must have these privileges:
EXECUTE对所有sys存储过程和函数EXECUTEon allsysstored procedures and functionsINSERT和UPDATE用于sys_config表,如果要对其进行更改INSERTandUPDATEfor thesys_configtable, if changes are to be made to it某些
sys架构存储过程和函数的额外权限,如其描述中所示(例如ps_setup_save()过程)Additional privileges for certainsysschema stored procedures and functions, as noted in their descriptions (for example, theps_setup_save()procedure)
还需要对 sys 架构对象所依赖的对象拥有权限:It is also necessary to have privileges for the objects underlying
the sys schema objects:
SELECT权限用于访问由sys架构对象访问的任何 Performance Schema 表,以及使用sys架构对象更新的任何表的UPDATE权限SELECTon any Performance Schema tables accessed bysysschema objects, andUPDATEfor any tables to be updated usingsysschema objectsPROCESS权限用于INFORMATION_SCHEMA的INNODB_BUFFER_PAGE表PROCESSfor theINFORMATION_SCHEMAINNODB_BUFFER_PAGEtable
必须启用某些 Performance Schema 工具和消费者,并且(对于工具)进行计时,以充分利用 sys 架构的功能:Certain Performance Schema instruments and consumers must be
enabled and (for instruments) timed to take full advantage of
sys schema capabilities:
所有
wait工具Allwaitinstruments所有
stage工具Allstageinstruments所有
statement工具Allstatementinstruments所有事件的
和xxx_current消费者xxx_history_longandxxx_currentconsumers for all eventsxxx_history_long
您可以使用 sys 架构本身来启用所有额外的工具和消费者:You can use the sys schema itself to
enable all of the additional instruments and consumers:
CALL sys.ps_setup_enable_instrument('wait');
CALL sys.ps_setup_enable_instrument('stage');
CALL sys.ps_setup_enable_instrument('statement');
CALL sys.ps_setup_enable_consumer('current');
CALL sys.ps_setup_enable_consumer('history_long');
对于 sys 模式的许多用途,默认的 Performance Schema 已经足够用于数据收集。启用上面提到的所有工具和消费者会影响性能,因此最好只启用您需要的额外配置。此外,请记住,如果启用了额外的配置,可以轻松地像这样恢复默认配置:For many uses of the sys schema, the default
Performance Schema is sufficient for data collection. Enabling
all the instruments and consumers just mentioned has a
performance impact, so it is preferable to enable only the
additional configuration you need. Also, remember that if you
enable additional configuration, you can easily restore the
default configuration like this:
CALL sys.ps_setup_reset_to_default(TRUE);