This topic describes how to enable transparent data encryption for a newly created table by creating an encrypted tablespace.
In OceanBase AI Database, the unit of data encryption is the tablespace. OceanBase AI Database is not a multi-data-file database system; the concept of tablespaces is designed for compatibility and can be simply understood as a collection of tables.
This topic uses creating a table named t1 in the encrypted tablespace sectest_ts1 as an example to provide step-by-step guidance for enabling transparent data encryption:
- Configure the encryption method. This topic provides configuration examples for the
internalmethod and theobcloudmethod in OBCloud deployment. - Create a tablespace and specify the encryption algorithm. This topic uses
aes-256as an example.
Limitations
- The system tenant cannot enable encryption.
- Once a tenant has TDE configured, it cannot switch to other encryption methods unless the tenant is rebuilt.
Configure encryption
This topic provides configuration examples for the internal method and the obcloud method in OBCloud deployment.
Configure transparent data encryption for the internal method
The tenant master key for the internal method has its encryption information primarily managed in internal tables. To avoid circular dependencies during log replay, clogs are not encrypted in this encryption method.
Log in to the user tenant of the cluster as the administrator.
Execute the following statement to enable transparent data encryption for the internal method.
The
tde_methodconfiguration item sets the method for transparent tablespace encryption. The default value isnone, which means transparent tablespace encryption is disabled.For more information about the
tde_methodconfiguration item, see tde_method.Notice
Once the
tde_methodconfiguration item is set, it cannot be modified.obclient> ALTER SYSTEM SET tde_method='internal';Execute the following statement to confirm that the value of the
tde_methodconfiguration item isinternalon all OBServer nodes of the tenant.obclient> SHOW PARAMETERS LIKE 'tde_method';After confirmation, execute the following statement to generate the master key.
Note
This statement can be executed only if the value of the
tde_methodconfiguration item isinternalon all OBServer nodes of the tenant.obclient> ALTER INSTANCE ROTATE INNODB MASTER KEY;Create a tablespace and specify the encryption algorithm.
You can specify the encryption algorithms
aes-256,aes-128,aes-192,sm4-cbc,aes-128-gcm,aes-192-gcm,aes-256-gcm, andsm4-gcm. If you use'y', aes-256 is used by default.Example:
obclient> CREATE TABLESPACE sectest_ts1 encryption = 'y';
Configure transparent data encryption using obcloud
The obcloud method is suitable for OBCloud deployments, where the tenant master key is managed by the OceanBase Cloud KMS proxy service. For private cloud OCP deployments, use ocp. For specific configurations, see tde_method.
- Log in to the user tenant of the cluster as the administrator.
Note
Steps 2 through 5 are used to configure the obcloud encryption method, set up the KMS proxy service, and generate the tenant master key.If this tenant has already completed the same configuration by referring to Generate tenant master key, skip these steps. For ease of reading and operation, the entire process is listed in detail below.
Execute the following statement to enable transparent data encryption using the
obcloudmethod.The
tde_methodconfiguration item specifies the method for transparent tablespace encryption. The default value isnone, which disables transparent tablespace encryption.For more information about the
tde_methodconfiguration item, see tde_method.obclient> ALTER SYSTEM SET tde_method = 'obcloud';Execute the following statement to confirm that the value of the
tde_methodconfiguration item isobcloudon all OBServer nodes of the tenant.obclient> SHOW PARAMETERS LIKE 'tde_method';Execute the following statement to configure the KMS proxy service configuration items.
obclient> ALTER SYSTEM SET external_kms_info = '{ "kms_host": "https://kms.example.oceanbase.com", "access_key_id": "LTAI****************", "access_key_secret": "your_access_key_secret", "cmk_id": "your_customer_master_key_id" }';After confirmation, execute the following statement to generate the master key.
obclient> ALTER INSTANCE ROTATE INNODB MASTER KEY;Create a tablespace and specify the encryption algorithm.
You can specify the encryption algorithms
aes-256,aes-128,aes-192,sm4-cbc,aes-128-gcm,aes-192-gcm,aes-256-gcm, andsm4-gcm. If you use'y', aes-256 is used by default.obclient> CREATE TABLESPACE sectest_ts1 encryption = 'y';
Notice
The preceding values are examples. Replace them with your actual KMS endpoint and key information. For more information, see tde_method and external_kms_info.
Create a new table in an encrypted tablespace
After configuring the encryption method, you can create a new table in the encrypted tablespace. The steps are as follows:
Log in to the database as a regular user.
After entering the corresponding database, create a table and specify its tablespace.
obclient> CREATE TABLE t1 (id1 int, id2 int) TABLESPACE sectest_ts1;After creation, any transaction related to this table must be encrypted.
Confirm whether the table in the tablespace is marked as encrypted.
Execute the following statement to check if
encryptionalgis the previously setaes-256.obclient> SELECT table_name,encryptionalg,encrypted FROM oceanbase.V$OB_ENCRYPTED_TABLES; +------------+---------------+-----------+ | table_name | encryptionalg | encrypted | +------------+---------------+-----------+ | t1 | aes-256 | YES | +------------+---------------+-----------+ 1 row in setIf
encryptionalgisaes-256andencryptedisYES, the table encryption configuration is successful.For more information about the fields in the
V$OB_ENCRYPTED_TABLESview, see V$OB_ENCRYPTED_TABLES.