|NO.Z.00026|——————————|BigDataEnd|——|Hadoop&OLAP_ClickHouse.V07|——|ClickHouse.v07|ClickHouse:ClickHouse副本分片|分片|

一、分片
### --- 修改配置参数文件:

~~~     # 修改配置文件参数
[root@hadoop01 ~]# vim /etc/clickhouse-server/config.d/metrika.xml
 ~~~ 下列为分片机制配置参数
<yandex>
    <!-- 修改remote-servers集群配置节点信息 -->
    <clickhouse_remote_servers>
        <perftest_3shards_1replicas>
            <shard>
                <internal_replication>true</internal_replication>
                <replica>
                    <host>hadoop01</host>
                    <port>9000</port>
                </replica>
            </shard>
            <shard>
                <replica>
                <internal_replication>true</internal_replication>
                    <host>hadoop02</host>
                    <port>9000</port>
                </replica>
            </shard>
            <shard>
                <internal_replication>true</internal_replication>
                <replica>
                    <host>hadoop03</host>
                    <port>9000</port>
                </replica>
            </shard>
        </perftest_3shards_1replicas>
    </clickhouse_remote_servers>

    <!--zookeeper集群配置信息 -->
    <zookeeper-servers>
        <node index="1">
            <host>hadoop01</host>
            <port>2181</port>
        </node>
        <node index="2">
            <host>hadoop02</host>
            <port>2181</port>
        </node>
        <node index="3">
            <host>hadoop03</host>
            <port>2181</port>
        </node>
    </zookeeper-servers>

    <!--副本存放地址:不同主机配置不同主机名 -->
    <macros>
        <shard>01</shard>
        <replica>hadoop01</replica>
    </macros>

    <networks>
        <ip>::/0</ip>
    </networks>

    <!--压缩信息配置 -->
    <clickhouse_compression>
        <case>
            <min_part_size>10000000000</min_part_size>
            <min_part_size_ratio>0.01</min_part_size_ratio>
            <method>lz4</method>
        </case>
    </clickhouse_compression>
</yandex>
### --- 注意修改其它两台主机副本存放

~~~     # 修改其它两台主机的副本存放地址
[root@hadoop02 ~]# vim /etc/clickhouse-server/config.d/metrika.xml 
    <!--副本存放地址:不同主机配置不同主机名 -->
    <macros>
        <shard>02</shard>
        <replica>hadoop02</replica>

[root@hadoop03 ~]# vim /etc/clickhouse-server/config.d/metrika.xml
    </macros>
    <!--副本存放地址:不同主机配置不同主机名 -->
    <macros>
        <shard>03</shard>
        <replica>hadoop03</replica>
    </macros>
### --- 修改config.xml

[root@hadoop01 ~]# vim /etc/clickhouse-server/config.xml
 
    <include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
    <zookeeper incl="zookeeper-servers" optional="true" />
二、分片机制参数说明
### --- 查看表中分片机制的参数

hadoop01 :) select * from system.macros;
┌─macro───┬─substitution─┐
│ replica │ hadoop01     │
│ shard   │ 01           │
└─────────┴──────────────┘
hadoop02 :) select * from system.macros;
┌─macro───┬─substitution─┐
│ replica │ hadoop02     │
│ shard   │ 02           │
└─────────┴──────────────┘
hadoop03 :) select * from system.macros;
┌─macro───┬─substitution─┐
│ replica │ hadoop03     │
│ shard   │ 03           │
└─────────┴──────────────┘
#---OR
hadoop01 :) select * from remote ('hahoop01:9000','system','macros','default');
三、在集群上创建表
### --- 创建表

hadoop01 :) create table clutable 
            on cluster perftest_3shards_1replicas(id UInt64)
            engine = ReplicatedMergeTree('/clickhouse/tables/{shard}/clutable','{replica}')
            order by id;
~~~输出参数
┌─host─────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ hadoop02 │ 90000 │       │                   21 │
└──────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host─────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ hadoop01 │ 90000 │       │                   10 │
└──────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host─────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ hadoop03 │ 90000 │       │                   00 │
└──────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
### --- 查看创建的表

~~~     # 查看分布式表
hadoop01 :) show tables;
┌─name─────┐
│ clutable │
└──────────┘
hadoop02 :) show tables;
┌─name─────┐
│ clutable │
└──────────┘
hadoop03 :) show tables;
┌─name─────┐
│ clutable │
└──────────┘

 
 
 
 
 
 
 
 
 

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  阅读(20)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
< 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

导航

统计

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