记一次clickhouse手动更改分片数异常

背景:clickhouse中之前是1分片1副本,随着数据量增多,想将分片数增多,于是驻场人员手动添加了分片数的节点信息

<clickhouse>
    <!-- 集群配置 -->
    <clickhouse_remote_servers>
        <feihuang_ck_cluster>
         <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>feihuang3</host>
                <port>9000</port>
                <user>default</user>
                <password>xxxxxxxx</password>
            </replica>
            <replica>
                <host>feihuang5</host>
                <port>9000</port>
                <user>default</user>
                <password>xxxxxxxx</password>
            </replica>
        </shard>
        <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>feihuang12</host>
                <port>9000</port>
                <user>default</user>
                <password>xxxxxxxx</password>
            </replica>
            <replica>
                <host>feihuang13</host>
                <port>9000</port>
                <user>default</user>
                <password>xxxxxxxx</password>
            </replica>
        </shard>
       </feihuang_ck_cluster>
    </clickhouse_remote_servers>

    <!-- 本节点服务器的副本名称 -->
    <macros>
        <cluster>feihuang_ck_cluster</cluster>
        <shard>2</shard>
        <replica>feihuang13</replica>
    </macros>

    <!-- ZK配置信息 -->
    <zookeeper-servers>
        <node index="1">
            <host>feihuang6</host>
            <port>2181</port>
        </node>
        <node index="2">
            <host>feihuang7</host>
            <port>2181</port>
        </node>
         <node index="3">
            <host>feihuang8</host>
            <port>2181</port>
        </node>
    </zookeeper-servers>

    <!-- 数据压缩算法 -->
    <clickhouse_compression>
        <case>
            <min_part_size>10000000000</min_part_size>
            <min_part_size_ratio>0.01</min_part_size_ratio>
            <method>zstd</method>
        </case>
    </clickhouse_compression>
</clickhouse>
```xml
 
但是发现每次写入一条数据,结果表中却又两条一样的数据。

解决思路:排查配置文件,查看所有节点中的

        feihuang_ck_cluster
        2
        feihuang13
    
    中的 2是不是都为2,结果发现全部都是2,这样对ck来说,配置了两个分片的节点信息,但是这都属于一个分片,导致数据写入两份,最后,将接地那shard分成两组,2个节点改为1,另外两个节点改为2,重启好了

你可能感兴趣的:(clickhouse)