|NO.Z.00003|——————————|Deployment|——|Hadoop&OLAP数据库管理系统.v03|——|ClickHouse.v03|表引擎|MergeTree|MergeTree存储策略|JBOC策略|

一、JBOD策略
### --- 配置方式在config.xml配置文件中指定:

~~~     # 在集群主机上config.xml配置JBOD策略
[root@hadoop01 ~]# vim /etc/clickhouse-server/config.xml
~~~ 在config.xml文件最后一行:</yandex>参数之上添加JBOD参数
<storage_configuration>
    <disks>
        <disk_hot1>
            <path>/var/lib/clickhouse/chbase/hotdata1/</path>
        </disk_hot1>
        <disk_hot2>
            <path>/var/lib/clickhouse/chbase/hotdata2/</path>
        </disk_hot2>
        <disk_cold>
            <path>/var/lib/clickhouse/chbase/colddata/</path>
        </disk_cold>
    </disks>
    <policies>
        <default_jbod>
            <volumes>
                <jbod>
                    <disk>disk_hot1</disk>:
                    <disk>disk_hot2</disk>
                </jbod>
            </volumes>
            <move_factor>0.2</move_factor>
        </default_jbod>
    </policies>
</storage_configuration>
### --- 发送到其它节点并重启服务

~~~     # 发送到其它所有主机
[root@hadoop01 ~]# rsync-script /etc/clickhouse-server/config.xml
~~~     # 所有节点重启服务
[root@hadoop01 ~]# systemctl restart clickhouse-server
二、JBOD策略配置是否生效
### --- 查看JBOD策略是否生效

~~~     # 查看JBOD策略是否生效:system.disk系统表,刚才配置的三块磁盘已经生效
[root@hadoop01 ~]# clickhouse-client -m

hadoop01 :) select name, path, formatReadableSize(free_space) as free, formatReadableSize(total_space) as total, formatReadableSize(keep_free_space) as reserved from system.disks;

SELECT 
    name,
    path,
    formatReadableSize(free_space) AS free,
    formatReadableSize(total_space) AS total,
    formatReadableSize(keep_free_space) AS reserved
FROM system.disks

┌─name──────┬─path─────────────────────────────────┬─free──────┬─total─────┬─reserved─┐
│ default   │ /var/lib/clickhouse/                 │ 60.37 GiB │ 64.96 GiB │ 0.00 B   │
│ disk_cold │ /var/lib/clickhouse/chbase/colddata/ │ 60.37 GiB │ 64.96 GiB │ 0.00 B   │
│ disk_hot1 │ /var/lib/clickhouse/chbase/hotdata1/ │ 60.37 GiB │ 64.96 GiB │ 0.00 B   │
│ disk_hot2 │ /var/lib/clickhouse/chbase/hotdata2/ │ 60.37 GiB │ 64.96 GiB │ 0.00 B   │
└───────────┴──────────────────────────────────────┴───────────┴───────────┴──────────┘
### --- system.storage_policies系统表可以看到刚才配置的策略

~~~     # system.storage_policies系统表可以看到刚才配置的策略也生效了。
hadoop01 :) select policy_name, volume_name, volume_priority, disks, formatReadableSize(max_data_part_size) max_data_part_size, move_factor from system.storage_policies;

SELECT 
    policy_name,
    volume_name,
    volume_priority,
    disks,
    formatReadableSize(max_data_part_size) AS max_data_part_size,
    move_factor
FROM system.storage_policies

┌─policy_name─────────────────┬─volume_name─┬─volume_priority─┬─disks─────────────────────┬─max_data_part_size─┬─move_factor─┐
│ default                     │ default     │               1['default']0.00 B0 │
│ default_jbod                │ jbod        │               1['disk_hot1','disk_hot2']0.00 B0.2 │
│ moving_from_hot_to_cold     │ hot         │               1['disk_hot1']1.00 GiB           │         0.2 │
│ moving_from_hot_to_cold     │ cold        │               2['disk_cold']0.00 B0.2 │
│ moving_from_hot_to_cold_new │ hot         │               1['disk_hot2']1.00 MiB           │         0.2 │
│ moving_from_hot_to_cold_new │ cold        │               2['disk_cold']0.00 B0.2 │
└─────────────────────────────┴─────────────┴─────────────────┴───────────────────────────┴────────────────────┴─────────────┘
三、JBOD策略示例
### --- 创建表并导入数据

~~~     # 创建jbod_table表
hadoop01 :) create table jbod_table (id UInt64) engine = MergeTree order by id settings storage_policy = 'default_jbod';

CREATE TABLE jbod_table
(
    `id` UInt64
)
ENGINE = MergeTree
ORDER BY id
SETTINGS storage_policy = 'default_jbod'

Ok
~~~     # 导入数据

hadoop01 :) insert into table jbod_table select rand() from numbers(10);

INSERT INTO jbod_table SELECT rand()
FROM numbers(10)

Ok.
~~~     # 查看jbod_table表

hadoop01 :) select name,disk_name from system.parts where table='jbod_table';

SELECT 
    name,
    disk_name
FROM system.parts
WHERE table = 'jbod_table'

┌─name──────┬─disk_name─┐
│ all_1_1_0 │ disk_hot1 │
└───────────┴───────────┘
### --- 在此再插入一条数据:

hadoop01 :) insert into table jbod_table select rand() from numbers(10);

INSERT INTO jbod_table SELECT rand()
FROM numbers(10)

Ok.
hadoop01 :) select name,disk_name from system.parts where table='jbod_table';

SELECT 
    name,
    disk_name
FROM system.parts
WHERE table = 'jbod_table'

┌─name──────┬─disk_name─┐
│ all_1_1_0 │ disk_hot1 │
│ all_2_2_0 │ disk_hot2 │
└───────────┴───────────┘
四、触发合并操作
### --- 触发合并操作:

~~~     # 触发合并
hadoop01 :) optimize table jbod_table;

OPTIMIZE TABLE jbod_table

Ok.
~~~     # 查看库表
~~~     验证JBOD策略的工作方式,多个磁盘组成了一个磁盘组volume卷,
~~~     新生成的数据分区,分区目录会按照volume卷中的磁盘定义顺序,轮询写入数据。

hadoop01 :) SELECT name, disk_name FROM system.parts WHERE table = 'jbod_table' ;

SELECT 
    name,
    disk_name
FROM system.parts
WHERE table = 'jbod_table'

┌─name──────┬─disk_name─┐
│ all_1_1_0 │ disk_hot1 │
│ all_1_2_1 │ disk_hot1 │
│ all_2_2_0 │ disk_hot2 │
└───────────┴───────────┘

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

posted on   yanqi_vip  阅读(56)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示