This topic describes how to generate a tenant master key in a MySQL-compatible mode tenant. After the tenant master key is generated, you can use the transparent data encryption (TDE), column encryption, and function encryption features.
Applicability
Community Edition of OceanBase Database does not support tenant master key-related features.
Prerequisites
- You have created a MySQL-compatible mode tenant.
- You have logged in to the tenant as the administrator.
Generate a tenant master key
Before you generate a tenant master key, make sure that the following conditions are met:
- To enable the TDE feature, you must generate a tenant master key whose value is not
none. To avoid a circular dependency during log replay, if thetde_methodparameter is set tointernal, the TDE clogs are not encrypted. - To enable the column encryption feature, you must generate a tenant master key whose value is not
none. - To enable the function encryption feature, you must generate a tenant master key whose value is not
none. - We recommend that you set the
tde_methodparameter toobcloudfor the TDE, column encryption, and function encryption features.
The following example shows how to generate a tenant master key by using the obcloud method. If you want to use an external key management service (KMS), set the tde_method parameter to obcloud and configure the external_kms_info parameter.
Log in to the MySQL tenant of the cluster as the administrator.
Execute the following statement to enable the
obcloudencryption method.The
tde_methodparameter specifies the storage method of the tenant master key. The default value isnone, which indicates that encryption is disabled.For more information about the
tde_methodparameter, see tde_method.Notice
Once the
tde_methodparameter is set, it cannot be modified.ALTER SYSTEM SET tde_method='obcloud';Execute the following statement to confirm that the value of the
tde_methodparameter isobcloudon all OBServer nodes of the tenant.SHOW PARAMETERS LIKE 'tde_method';Execute the following statement to configure the KMS proxy service parameters.
For more information about the
external_kms_infoparameter, see external_kms_info.-- The following example is for reference only. Replace the KMS endpoint and key information with actual values. ALTER SYSTEM SET external_kms_info='{ "kms_host": "https://kms.example.oceanbase.com", "access_key_id": "******", "access_key_secret": "******", "cmk_id": "your_customer_master_key_id"}';Notice
When you execute this statement, the system immediately connects to the KMS service specified by
kms_hostfor verification. Ensure that the KMS service is available and the authentication information is correct; otherwise, the statement fails and returns thekms server connect failederror.Execute the following statement to generate a tenant master key.
Note
This statement can be executed only when the value of the
tde_methodparameter isobcloudon all OBServer nodes of the tenant andexternal_kms_infohas been configured successfully.ALTER INSTANCE ROTATE INNODB MASTER KEY;
Rotate a tenant master key
For security reasons, we recommend that you rotate the tenant master key regularly. After the tenant master key is rotated, new data is encrypted with the new key, and old data can still be decrypted with the old key.
Notice
The following statement can rotate the tenant master key successfully only when the value of tde_method is obcloud on all OBServer nodes of the tenant and external_kms_info has been configured successfully.
ALTER INSTANCE ROTATE INNODB MASTER KEY;
What to do next
After you generate a tenant master key, you can:
- Use the TDE feature: For more information, see Enable transparent encryption for a new table.
- Use the column encryption feature: For more information, see Create a column encryption rule.
- Use the function encryption feature: For more information, see ENHANCED_AES_ENCRYPT and ENHANCED_AES_DECRYPT.