配置clickhouse冷热数据分离

在 config.d 中加入如下配置

  • 配置存储目录
<disks>
    <fast_disk> <!-- disk name -->
        <path>/mnt/fast_ssd/clickhouse</path>  #ssd 数据目录
    </fast_disk>
    <disk1>
        <path>/mnt/hdd1/clickhouse</path> # 普通盘数据目录
        <keep_free_space_bytes>10485760</keep_free_space_bytes> # 磁盘预留空间
    </disk1>
    <disk2>
        <path>/mnt/hdd2/clickhouse</path> # 普通盘数据目录
        <keep_free_space_bytes>10485760</keep_free_space_bytes> # 磁盘预留空间
    </disk2>
</disks>
 
  • 配置存储策略
<policies>
       <ssd_to_hdd>
        <volumes>
            <hot>
                <disk>fast_disk</disk>
                <max_data_part_size_bytes>1073741824</max_data_part_size_bytes>   # 数据块大小
            </hot>
            <cold>
                <disk>disk1</disk>
                <disk>disk2</disk>
            </cold>
            <move_factor>0.2</move_factor>  # 当SSD数据盘低于20%存储时会将历史数据存储到hdd
        </volumes>
    </ssd_to_hdd>
</policies>
 
  • 在创建表时引用数据存储策略
CREATE TABLE table_with_non_default_policy (
    EventDate Date,
    OrderID UInt64,
    BannerID UInt64,
    SearchPhrase String
) ENGINE = MergeTree
ORDER BY (OrderID, BannerID)
PARTITION BY toYYYYMM(EventDate)
SETTINGS storage_policy = 'ssd_to_hdd'

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ORA-00001: 违反唯一约束条件 (.) 错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常。 O...
    我想起个好名字阅读 10,786评论 0 9
  • feisky云计算、虚拟化与Linux技术笔记posts - 1014, comments - 298, trac...
    不排版阅读 9,319评论 0 5
  • 一. Java基础部分.................................................
    wy_sure阅读 9,228评论 0 11
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,793评论 1 32
  • 1. 简介 1.1 什么是 MyBatis ? MyBatis 是支持定制化 SQL、存储过程以及高级映射的优秀的...
    笨鸟慢飞阅读 11,078评论 0 4