content_image/807366.jpg content_image/807367.jpg
The following example demonstrates how to enable the stage/innodb/alter tablespace (encryption)  stage event instrument and related consumer tables to monitor general tablespace or mysql  system tablespace encryption progress. For information about Performance Schema stage event instruments and related consumers, see Section 27.12.5, “Performance Schema Stage Event Tables” . 

1. Enable the stage/innodb/alter tablespace (encryption)  instrument: 

mysql> USE performance_schema; mysql> UPDATE setup_instruments SET ENABLED = ’YES’ WHERE NAME LIKE ’stage/innodb/alter tablespace (encryption)’; 

2. Enable the stage event consumer tables, which include events_stages_current , events_stages_history , and events_stages_history_long . 

mysql> UPDATE setup_consumers SET ENABLED = ’YES’ WHERE NAME LIKE ’%stages%’; 

3. Run a tablespace encryption operation. In this example, a general tablespace named ts1  is encrypted. 

mysql> ALTER TABLESPACE ts1 ENCRYPTION = ’Y’; 

4. Check the progress of the encryption operation by querying the Performance Schema events_stages_current  table. WORK_ESTIMATED  reports the total number of pages in the tablespace. WORK_COMPLETED  reports the number of pages processed. 

mysql> SELECT EVENT_NAME, WORK_ESTIMATED, WORK_COMPLETED FROM events_stages_current; 

<img src='content_image/807366.jpg'>

The events_stages_current  table returns an empty set if the encryption operation has completed. In this case, you can check the events_stages_history  table to view event data for the completed operation. For example: 

mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED FROM events_stages_history; 

<img src='content_image/807367.jpg'>

## Encryption Usage Notes 

•Plan appropriately when altering an existing file-per-table tablespace with the ENCRYPTION  option. Tables residing in file-per-table tablespaces are rebuilt using the COPY  algorithm. The INPLACE algorithm is used when altering the ENCRYPTION  attribute of a general tablespace or the mysql  system tablespace. The INPLACE  algorithm permits concurrent DML on tables that reside in the general tablespace. Concurrent DDL is blocked. 

•When a general tablespace or the mysql  system tablespace is encrypted, all tables residing in the tablespace are encrypted. Likewise, a table created in an encrypted tablespace is encrypted. 

•If the server exits or is stopped during normal operation, it is recommended to restart the server using the same encryption settings that were configured previously. 

•The first master encryption key is generated when the first new or existing tablespace is encrypted. 

•Master key rotation re-encrypts tablespaces keys but does not change the tablespace key itself. To change a tablespace key, you must disable and re-enable encryption. For file-per-table tablespaces, 

