此答案基于@Denny Crane 的评论:https://altinity.com/blog/clickhouse-and-s3-compatible-object-storage,我确实将 cmets 放在了没有足够解释的地方,并在链接失效时保留它。
-
- 将您的 S3 磁盘添加到新的配置文件中(比如说
/etc/clickhouse-server/config.d/storage.xml:
<yandex>
<storage_configuration>
<disks>
<!-- This tag is the name of your S3-emulated disk, used for the rest of this tutorial -->
<your_s3>
<type>s3</type>
<!-- Set this to the endpoint of your S3-compatible provider -->
<endpoint>https://nyc3.digitaloceanspaces.com</endpoint>
<!-- Set this to your access key ID provided by your provider -->
<access_key_id>*****</access_key_id>
<!-- Set this to your access key Secret provided by your provider -->
<secret_access_key>*****</secret_access_key>
</your_s3>
</disks>
<!-- Don't leave this file yet! We still have things to do there -->
...
</storage_configuration>
</yandex>
<!-- Put this after the three dots in the snippet above -->
<policies>
<shared>
<volumes>
<default>
<!-- Default is the disk that is present in the default question -->
<disk>default</disk>
</default>
<your_s3>
<disk>your_s3</disk>
</your_s3>
</volumes>
</shared>
</policies>
完成后,您可以使用以下插入语句创建表:
CREATE TABLE visits (...)
ENGINE = MergeTree
TTL toStartOfYear(time) + interval 3 year to volume 'your_s3'
SETTINGS storage_policy = 'shared';
其中shared 是您的策略名称,your_s3 是您在该策略中的磁盘名称。