Encryption at rest in ClickHouse secures on-disk data by storing it on encrypted disks or volumes, protecting sensitive information if physical storage is compromised.
ClickHouse supports file-system level encryption through the Encrypted
disk type. All data written to this disk is transparently encrypted with AES-256-CTR and salted HMAC for integrity.
Add a <disk>
section inside storage_configuration
in config.xml
.Provide the path, optional cache size, and a 256-bit hex key or an environment variable reference.
<disk name="encrypted_disk" type="encrypted">
<path>/var/lib/clickhouse/encrypted/</path>
<encryption_key/>${CLICKHOUSE_KEY}</encryption_key>
</disk>
Define a <volume>
element that lists the encrypted disk. The volume can include multiple disks for redundancy.
<volume name="secure_volume">
<disk>encrypted_disk</disk>
</volume>
Specify the volume in the ON VOLUME
clause while creating a table or use ALTER TABLE ...MOVE PARTITION
.
CREATE TABLE Orders (
id UInt64,
customer_id UInt64,
order_date Date,
total_amount Decimal(12,2)
) ENGINE = MergeTree()
ORDER BY id
ON VOLUME secure_volume;
Change the key in config.xml
, restart ClickHouse, and run SYSTEM DISK ENCRYPTION ROTATE KEY encrypted_disk
to re-encrypt existing data.
config.xml
permissions to the clickhouse
user.Yes.Create an S3Encrypted
disk or enable server-side encryption in your bucket. Specify the disk in a volume just like a local encrypted disk.
AES-NI hardware acceleration keeps overhead <5 %. Benchmark with production workloads to tune read/write
thread pools and cache sizes.
.
With AES-NI CPUs, overhead is below 5 % for most workloads. Benchmark to confirm.
Yes, place security-sensitive tables on an encrypted volume and others on regular disks.
Yes. ClickHouse re-encrypts parts in the background while remaining available.