| 1 |
# ---------------------------------------------------------------------- |
| 2 |
# Setup |
| 3 |
# Creating local configuration file for keyring component: component_keyring_file |
| 4 |
# Creating manifest file for current MySQL server instance |
| 5 |
# Re-starting mysql server with manifest file |
| 6 |
# ---------------------------------------------------------------------- |
| 7 |
######################################################################### |
| 8 |
# START : WITHOUT KEYRING PLUGIN |
| 9 |
######################################################################### |
| 10 |
# Taking backup of local manifest file for MySQL server instance |
| 11 |
######### |
| 12 |
# SETUP # |
| 13 |
######### |
| 14 |
CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd' |
| 15 |
ENGINE=InnoDB ENCRYPTION="N"; |
| 16 |
CREATE TABLE t1(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts; |
| 17 |
set global innodb_buf_flush_list_now = 1; |
| 18 |
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 19 |
WHERE NAME='encrypt_ts'; |
| 20 |
NAME ENCRYPTION |
| 21 |
encrypt_ts N |
| 22 |
SELECT * FROM t1 LIMIT 10; |
| 23 |
c1 |
| 24 |
SOME VALUES |
| 25 |
SOME VALUES |
| 26 |
SOME VALUES |
| 27 |
SOME VALUES |
| 28 |
SOME VALUES |
| 29 |
SOME VALUES |
| 30 |
SOME VALUES |
| 31 |
SOME VALUES |
| 32 |
SOME VALUES |
| 33 |
SOME VALUES |
| 34 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 35 |
ERROR HY000: Can't find master key from keyring, please check in the server log if a keyring is loaded and initialized successfully. |
| 36 |
######################################################################### |
| 37 |
# RESTART 1 : WITH KEYRING PLUGIN |
| 38 |
######################################################################### |
| 39 |
# Restore local manifest file for MySQL server instance from backup |
| 40 |
# Monitoring connection |
| 41 |
UPDATE performance_schema.setup_consumers SET ENABLED='YES'; |
| 42 |
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 43 |
WHERE NAME='encrypt_ts'; |
| 44 |
NAME ENCRYPTION |
| 45 |
encrypt_ts N |
| 46 |
SELECT * FROM performance_schema.setup_consumers |
| 47 |
WHERE NAME LIKE "%stages%"; |
| 48 |
NAME ENABLED |
| 49 |
events_stages_current YES |
| 50 |
events_stages_history YES |
| 51 |
events_stages_history_long YES |
| 52 |
SELECT * FROM performance_schema.setup_instruments |
| 53 |
WHERE NAME LIKE "%encryption%"; |
| 54 |
NAME ENABLED TIMED PROPERTIES FLAGS VOLATILITY DOCUMENTATION |
| 55 |
wait/synch/mutex/innodb/resume_encryption_cond_mutex YES YES NULL 0 NULL |
| 56 |
wait/synch/cond/innodb/resume_encryption_cond YES YES NULL 0 NULL |
| 57 |
stage/innodb/alter tablespace (encryption) YES YES progress NULL 0 NULL |
| 58 |
select count(*) from performance_schema.events_stages_current |
| 59 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 60 |
count(*) |
| 61 |
0 |
| 62 |
# Default connection |
| 63 |
############################################################ |
| 64 |
# ALTER TABLESPACE 1 : Unencrypted => Encrypted # |
| 65 |
############################################################ |
| 66 |
|
| 67 |
# Set Encryption process to wait after page 5 so that we can monitor |
| 68 |
# progress in performance_schema table |
| 69 |
SET DEBUG_SYNC = 'alter_encrypt_tablespace_wait_after_page5 SIGNAL s1 WAIT_FOR s2'; |
| 70 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 71 |
# Monitoring connection |
| 72 |
SET DEBUG_SYNC = 'now WAIT_FOR s1'; |
| 73 |
# Wait for Encryption progress monitoring to appear in PFS table |
| 74 |
# Wait for some progress to appear in PFS table |
| 75 |
select WORK_ESTIMATED, WORK_COMPLETED |
| 76 |
FROM performance_schema.events_stages_current |
| 77 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)'; |
| 78 |
WORK_ESTIMATED WORK_COMPLETED |
| 79 |
6 5 |
| 80 |
SET DEBUG_SYNC = 'now SIGNAL s2'; |
| 81 |
# Default connection |
| 82 |
# Once done, select count from PFS tables |
| 83 |
SELECT COUNT(*) |
| 84 |
FROM performance_schema.events_stages_current |
| 85 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 86 |
COUNT(*) |
| 87 |
0 |
| 88 |
SELECT COUNT(*) |
| 89 |
FROM performance_schema.events_stages_history |
| 90 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 91 |
COUNT(*) |
| 92 |
1 |
| 93 |
SELECT COUNT(*) |
| 94 |
FROM performance_schema.events_stages_history_long |
| 95 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 96 |
COUNT(*) |
| 97 |
1 |
| 98 |
SELECT COUNT(*) |
| 99 |
FROM performance_schema.events_stages_summary_global_by_event_name |
| 100 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 101 |
COUNT_STAR>0; |
| 102 |
COUNT(*) |
| 103 |
1 |
| 104 |
COUNT(*) |
| 105 |
1 |
| 106 |
SELECT COUNT(*) |
| 107 |
FROM performance_schema.events_stages_summary_by_user_by_event_name |
| 108 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 109 |
COUNT_STAR>0; |
| 110 |
COUNT(*) |
| 111 |
1 |
| 112 |
SELECT COUNT(*) |
| 113 |
FROM performance_schema.events_stages_summary_by_host_by_event_name |
| 114 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 115 |
COUNT_STAR>0; |
| 116 |
COUNT(*) |
| 117 |
1 |
| 118 |
SELECT COUNT(*) |
| 119 |
FROM performance_schema.events_stages_summary_by_account_by_event_name |
| 120 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 121 |
COUNT_STAR>0; |
| 122 |
COUNT(*) |
| 123 |
1 |
| 124 |
# Check that Encryption done successfully. |
| 125 |
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 126 |
WHERE NAME='encrypt_ts'; |
| 127 |
NAME ENCRYPTION |
| 128 |
encrypt_ts Y |
| 129 |
SELECT * FROM t1 LIMIT 10; |
| 130 |
c1 |
| 131 |
SOME VALUES |
| 132 |
SOME VALUES |
| 133 |
SOME VALUES |
| 134 |
SOME VALUES |
| 135 |
SOME VALUES |
| 136 |
SOME VALUES |
| 137 |
SOME VALUES |
| 138 |
SOME VALUES |
| 139 |
SOME VALUES |
| 140 |
SOME VALUES |
| 141 |
######################################################################### |
| 142 |
# RESTART 2 : WITHOUT KEYRING PLUGIN |
| 143 |
######################################################################### |
| 144 |
# Taking backup of local manifest file for MySQL server instance |
| 145 |
SELECT * FROM t1 LIMIT 10; |
| 146 |
ERROR HY000: Can't find master key from keyring, please check in the server log if a keyring is loaded and initialized successfully. |
| 147 |
######################################################################### |
| 148 |
# RESTART 3 : WITH KEYRING PLUGIN |
| 149 |
######################################################################### |
| 150 |
# Restore local manifest file for MySQL server instance from backup |
| 151 |
UPDATE performance_schema.setup_consumers SET ENABLED='NO'; |
| 152 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='N'; |
| 153 |
########### |
| 154 |
# Cleanup # |
| 155 |
########### |
| 156 |
SELECT COUNT(*) FROM t1; |
| 157 |
COUNT(*) |
| 158 |
32 |
| 159 |
DROP TABLE t1; |
| 160 |
DROP TABLESPACE encrypt_ts; |
| 161 |
# ---------------------------------------------------------------------- |
| 162 |
# Teardown |
| 163 |
# Removing manifest file for current MySQL server instance |
| 164 |
# Removing local keyring file for keyring component: component_keyring_file |
| 165 |
# Removing local configuration file for keyring component: component_keyring_file |
| 166 |
# Restarting server without the manifest file |
| 167 |
# ---------------------------------------------------------------------- |