This topic describes how to create an encrypted tablespace to enable storage encryption for a new table.
Background information
OceanBase Database provides data encryption methods that are compatible with Oracle Database and encrypts data in tablespaces. OceanBase Database does not support multiple files, and the concept of tablespaces is designed for compatibility. A tablespace is a collection of tables.
The following sections describe how to enable data storage encryption for the t1 table in the encrypted sectest_ts1 tablespace.
Enable storage encryption in internal mode
In internal mode, the encryption information of the master key is managed in internal tables, and clogs are not encrypted to avoid circular dependency during log replay.
Log on to an Oracle tenant of the database as the administrator.
Execute the following statement to enable storage encryption in internal mode:
The
tde_methodparameter specifies the encryption method for a transparent tablespace. The default value isnone, which indicates that encryption is disabled for the transparent tablespace.For more information about the
tde_methodparameter, see tde_method.Notice
After the
tde_methodparameter is set, it cannot be modified.obclient> ALTER SYSTEM SET tde_method='internal';Execute the following statement to check whether the value of the
tde_methodparameter isinternalon all OBServer nodes of the tenant:obclient> SHOW PARAMETERS LIKE 'tde_method';Create a Keystore.
The SQL syntax is as follows:
obclient>ADMINISTER KEY MANAGEMENT CREATE KEYSTORE keystore_name IDENTIFIED BY password;For example:
obclient> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE sectest1 IDENTIFIED BY ******;Enable the Keystore.
The SQL syntax is as follows:
obclient> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY password;You must replace
passwordwith the key specified for the Keystore in the previous step.For example:
obclient> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY ******;Execute the following statement to generate the master key:
obclient> ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY password;You must replace
passwordwith the key specified for the Keystore in the previous step.For example:
obclient> ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY ******;Create a tablespace and specify the encryption algorithm.
You can specify any one of the following encryption algorithms:
aes-256,aes-128,aes-192, andsm4-cbc.For example:
obclient> CREATE TABLESPACE sectest_ts1 ENCRYPTION USING 'aes-256';
Check whether encryption is enabled as expected
To check whether encryption is enabled as expected, perform the following steps:
Log on to the Oracle tenant as a regular user.
Create a table and specify the tablespace.
obclient> CREATE TABLE t1 (id1 int, id2 int) TABLESPACE sectest_ts1;After the table is created, all transactions related to the table are encrypted.
Check whether table
t1in the tablespace is marked as encrypted.Execute the following statement to check whether the value of the
ENCRYPTIONALGcolumn isaes-256or as specified:obclient> SELECT TABLE_NAME,ENCRYPTIONALG FROM v$encrypted_tables; +------------+---------------+ | TABLE_NAME | ENCRYPTIONALG | +------------+---------------+ | T1 | aes-256 | +------------+---------------+ 1 row in setIf the value of the
ENCRYPTIONALGcolumn isaes-256or as specified, the table is encrypted.For more information about fields in the
V$ENCRYPTED_TABLESview, see V$ENCRYPTED_TABLES.