tencent cloud

Tencent Cloud TCHouse-D

TDE Transparent Encryption

다운로드
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-11-09 20:27:17
AI 번역
TDE (Transparent Data Encryption) is a storage-layer static encryption capability provided by TCHouse-D, designed to prevent plaintext leakage caused by the theft of persisted data such as physical disks, backup files, and snapshots. TDE only applies to encryption and decryption when data is persisted, and is completely transparent to upper-layer SQL: write, query, index, Compaction, backup and recovery operations on the business side require no SQL modifications.

Related Concepts

Key Hierarchy

TDE uses a three-tier key system.
Level
Note
Function
Root Key
The outermost key, stored in a local FE file or managed in Tencent Cloud KMS.
It does not participate in data encryption or decryption and is only used to encrypt the Master Key. It is unique across the entire cluster.
Master Key
Encrypted by the Root Key, with plaintext cached in FE memory.
Divided into AES256 / SM4 families, used to encrypt and decrypt Data Keys.
Data Key
One for each Tablet, with the ciphertext persisted along with the Tablet metadata.
Actually used to encrypt and decrypt data Blocks.
Supported Encryption Algorithm
AES256: AES-256-CTR, generally recommended.
SM4: SM4-CTR, a Chinese cryptographic algorithm.
PLAINTEXT: no encryption (default value, indicating that the table is persisted in plaintext).
Note:
The algorithms for the Root Key and Master Key are specified by the encryption_algorithm parameter.
The algorithm used by the Data Key is determined by the tde_algorithm table property at table creation, and a table can use only one algorithm.

Root Key Provisioning Methods

TDE supports two Root Key Provider methods:
1. LOCAL: The Root Key is stored in a local FE file, and the file content is the Base64-encoded key bytes.
2. TENCENT_KMS: The Root Key is hosted in Tencent Cloud KMS and referenced by its CMK ID.
For both methods, you must set the Root Key through SQL upon first use. For details, see Step 1: Set the Root Key.

Prerequisites and Limitations

Prerequisites

1. You have created a TCHouse-D cluster and have the ADMIN privilege for the cluster.
2. Prepare the corresponding resources based on the selected Root Key Provider method:
LOCAL method: A local file for storing the Root Key has been prepared. The file content is the Base64-encoded key bytes and has been uploaded successfully through the console configuration file.
TENCENT_KMS method: A CMK (customer master key) has been created in Tencent Cloud KMS, and its CMK ID, Region, and the AccessKey/SecretKey required to call the key have been obtained.
Note:
Security note: The Root Key is critical for decrypting data. Keep the Root Key secure and store it separately from cluster data.
LOCAL method: Make sure to back up the Root Key file independently. If the file is lost, encrypted data can never be decrypted.
TENCENT_KMS method: Enable deletion protection for the CMK and enable key backup on the KMS side. If the CMK is accidentally deleted or its permissions are changed, data cannot be decrypted.

Use Limits

1. Encryption can only be specified during table creation: The tde_algorithm property takes effect only during table creation and cannot be modified through ALTER TABLE. Existing plaintext tables cannot be converted to encrypted tables online, and encrypted tables cannot have their algorithm changed or encryption disabled online.
2. Partition-level encryption is not supported: The encryption property in ADD PARTITION ... PROPERTIES ("tde_algorithm" = ...) is silently ignored, and the new partition still inherits the table-level algorithm.
3. The Root Key can only be SET once: ADMIN SET ENCRYPTION ROOT KEY is a one-time operation. To change the Root Key, you must use ADMIN ROTATE TDE ROOT KEY.
4. Root Key types cannot be interchanged: When ROTATE ROOT KEY is used, the type must be consistent with the current Root Key type (LOCAL and TENCENT_KMS cannot be switched to each other). To change the provisioning method, you need to export data + rebuild the cluster.
5. Column-level encryption is not supported: Encryption granularity is at the table or Tablet level, and encrypting only a specific column is not supported.

Operation Steps

Step 1: Setting the Root Key

Before using TDE, you must set the Root Key. The Root Key can only be set once, and repeated setting will cause an error. To change it later, use Step 4: Rotate the Root Key.
LOCAL method: Log in to the Tencent Cloud TCHouse-D console and go to Cluster Details > Modify Configuration > Upload Configuration File.
TENCENT_KMS method:
ADMIN SET ENCRYPTION ROOT KEY PROPERTIES (
"type" = "TENCENT_KMS",
"encryption_algorithm" = "AES256",
"cmk_id" = "kms-cmk-xxxx",
"region" = "ap-guangzhou",
"endpoint" = "kms.tencentcloudapi.com",
"ak" = "<AccessKey>",
"sk" = "<SecretKey>"
);
Parameter description:
Parameter
Note
type
Root Key provider type. Supported values: TENCENT_KMS
encryption_algorithm
Root key encryption algorithm. Supported values: AES256 / SM4
cmk_id
KMS CMK ID
region
Region where KMS resides
endpoint
KMS service endpoint
ak / sk
AccessKey / SecretKey required to call KMS
After successful execution, the system generates two Master Keys, AES256 and SM4 (version = 1), and starts a thread for scheduled Master Key rotation.

Step 2: Viewing Key Status

After setting the Root Key, you can view the current key status:
SHOW ENCRYPTION ROOT KEY;
SHOW ENCRYPTION MASTER KEYS;
Note:
1. All the above commands require ADMIN privileges.
2. The return values will have the following security desensitization measures:
ak displays only the first 4 characters + **** + the last 4 characters.
sk is never returned.
The plaintext of the Master Key is never returned.
Only the first 8 characters of the Master Key ciphertext are retained, and the rest are displayed as ****.

Step 3: Creating an Encrypted Table

Specify the encryption algorithm through the tde_algorithm table property in the CREATE TABLE statement:
CREATE TABLE t_enc (
id BIGINT,
val VARCHAR(64)
)
DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 3
PROPERTIES (
"replication_num" = "3",
"tde_algorithm" = "AES256"
);
Note:
tde_algorithm supports AES256 / SM4 / PLAINTEXT.
If not specified, the default value of the cluster configuration item doris_tde_algorithm is used (default: PLAINTEXT).
Writes, queries, indexes, and Compaction on encrypted tables are fully transparent, and no SQL changes are required.

Step 4: Rotating the Root Key (Optional)

To replace the Root Key, use the following command. After the replacement, the Master Key plaintext remains unchanged and is only re-encrypted with the new Root Key. This process is fully transparent to data reads, and historical data does not need to be re-encrypted.
Note:
During rotation, the type must remain consistent with the current Root Key type (LOCAL and TENCENT_KMS cannot be interchanged).
1. LOCAL → LOCAL: Re-upload the Root Key file in the console.
2. TENCENT_KMS → TENCENT_KMS: Replace the CMK.
ADMIN ROTATE TDE ROOT KEY PROPERTIES (
"doris_tde_key_provider" = "TENCENT_KMS",
"doris_tde_key_id" = "kms-cmk-yyyy",
"doris_tde_key_ak" = "<AK>",
"doris_tde_key_sk" = "<SK>",
"doris_tde_key_endpoint" = "kms.tencentcloudapi.com",
"doris_tde_key_region" = "ap-guangzhou"
);
Parameter description:
Parameters
Parameter Description
doris_tde_key_provider
Root Key provider type. Must be consistent with the current type (TENCENT_KMS).
doris_tde_key_id
New KMS CMK ID
doris_tde_key_ak / doris_tde_key_sk
AccessKey / SecretKey required to call KMS
doris_tde_key_endpoint
KMS service endpoint
doris_tde_key_region
Region where KMS resides
Note:
Before rotating the Root Key, ensure that the new Root Key has been properly backed up (for LOCAL, back up the key file; for KMS, back up the CMK and its backup). The rotation process performs a complete key validation, and the new key takes effect only after the validation passes, avoiding a partially successful state.

Subsequent Operation Steps

Permission Description

ADMIN SET ENCRYPTION ROOT KEY, ADMIN ROTATE TDE ROOT KEY, SHOW ENCRYPTION ROOT KEY, and SHOW ENCRYPTION MASTER KEYS all require ADMIN global privileges.
If a regular user executes the above commands, they will receive an Access denied error.
Creating and querying encrypted tables follow the same privilege model as regular tables, and encryption is transparent to the privilege model.

Converting Plaintext Tables to Encrypted Tables

To convert an existing plaintext table to an encrypted table, consider the following workarounds:
CREATE TABLE t_new (...) PROPERTIES ("tde_algorithm" = "AES256");
INSERT INTO t_new SELECT * FROM t_old;
ALTER TABLE t_old RENAME t_old_bak;
ALTER TABLE t_new RENAME t_old;

Observability and Ops

Key Metrics (Prometheus)

Metric
Note
doris_fe_tde_rotate_master_key_success
Master Key rotation success quantity
doris_fe_tde_rotate_master_key_failed
Master Key rotation failure quantity
doris_fe_tde_rotate_root_key_success
Root Key rotation success quantity
doris_fe_tde_rotate_root_key_failed
Root Key rotation failure quantity
doris_fe_tde_kms_call_failed
KMS call failure quantity

Key Logs (fe.log)

Log
Note
TDE is enabled, loading master keys
FE starts up and loads the Master Key.
Load master key successfully
A single Master Key is decrypted and loaded successfully.
Rotate master key successfully
Master Key rotated automatically.
Rotate root key successfully
Root Key rotated successfully.
failed to load master key ... FE will exit
CRC verification failed. FE exits proactively to prevent misuse.

Backup and Disaster Recovery Recommendations

1. LOCAL method: The Root Key file must be backed up independently and stored separately from cluster data. If the file is lost, the data can never be decrypted.
2. TENCENT_KMS method: Enable deletion protection for the CMK and enable key backup on the KMS side.
3. The Master Key plaintext exists only in FE memory. All data persisted to disk is ciphertext and can only be decrypted with the Root Key.
4. During cross-cluster backup and recovery, the target cluster must be able to access the same Root Key (the same key file for LOCAL, or the same CMK for KMS). Otherwise, the data cannot be decrypted after recovery.

More Restriction Notes

1. WAL encryption independent switch: In Group Commit async_mode, data is first written to the WAL file and then flushed to Rowset. Whether WAL is encrypted is controlled by the independent BE configuration enable_wal_tde, which is disabled by default. If you use encrypted tables with Group Commit async_mode and require WAL encryption, explicitly set enable_wal_tde = true on all BE nodes. Regular synchronous writes and sync_mode Group Commit do not involve WAL and are not affected by this switch.
2. CRC check failure causes FE to exit: If FE detects a CRC mismatch when loading the Master Key during startup, it exits immediately. This is a defensive design. During troubleshooting, first check whether the Root Key is available (for LOCAL, whether the key file has been accidentally deleted or its permissions changed; for KMS, whether the CMK has been accidentally deleted or its permissions changed) and whether the image is up to date.
3. Key export capability is restricted: No API returns the key plaintext, and encrypted table data cannot be explicitly exported as plaintext or re-encrypted through SQL.
4. Custom IV/Nonce is not supported: It is automatically derived by BE and cannot be controlled by users.
5. The write path is fixed as compression before encryption: Switching the order is not supported.

FAQs

Q1: What if I create an encrypted table without setting the Root Key first?

An error is reported: Root key not set , or table creation fails. Execute ADMIN SET ENCRYPTION ROOT KEY before creating the table.

Q2: Why does SHOW ENCRYPTION MASTER KEYS return empty?

If the Root Key is not SET, an empty result is returned. After it is SET, there are at least 2 keys (AES256 v1 + SM4 v1).

Q3: Can encrypted tables still be read and written after a primary/secondary FE switchover?

Yes. All key changes are synchronized to Followers, and service resumes after the new leader switchover is complete.

Q4: Can master be used as a column name?

Yes. MASTER has been added to the non-reserved keyword list, so both SELECT master FROM t; and CREATE TABLE t (master INT) can be used normally.

Q5: What is the performance overhead after encryption?

The CPU overhead of AES256/SM4 in CTR mode is approximately 5% to 10%, which can be significantly reduced through AES-NI instruction set hardware acceleration.


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백