插入数据时单击house cluster multiple record

ru9i0ody  于 2021-07-15  发布在  ClickHouse
关注(0)|答案(0)|浏览(152)

我在clickhouse中使用replicatedmergetree和分布式表来创建ha集群。我认为应该在集群中存储两个副本,当其中一个节点出现问题时就可以了。这是我的一些配置(config.xml):。。。

<logs>
        <shard>
            <weight>1</weight>
            <internal_replication>true</internal_replication>
            <replica>
                <host>node1</host>
                <port>9000</port>
            </replica>
            <replica>
                <host>node2</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <weight>1</weight>
            <internal_replication>true</internal_replication>
            <replica>
                <host>node2</host>
                <port>9000</port>
            </replica>
            <replica>
                <host>node3</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <weight>1</weight>
            <internal_replication>true</internal_replication>
            <replica>
                <host>node3</host>
                <port>9000</port>
            </replica>
            <replica>
                <host>node1</host>
                <port>9000</port>
            </replica>
        </shard>
        </logs>
...
<!-- each node is different -->
<macros>
    <layer>01</layer>
    <shard>01</shard>
    <replica>node1</replica>
</macros>
<!-- below is node2 and node3 configuration 

<macros>
    <layer>02</layer>
    <shard>02</shard>
    <replica>node2</replica>
</macros>

<macros>
    <layer>03</layer>
    <shard>03</shard>
    <replica>node3</replica>
</macros>
-->
...

然后我通过clickhouse client--host cmd在每个节点中创建表:

create table if not exists game(uid Int32,kid Int32,level Int8,datetime Date) 
ENGINE = ReplicatedMergeTree('/clickhouse/data/{shard}/game','{replica}') 
PARTITION BY  toYYYYMMDD(datetime)  
ORDER BY (uid,datetime);

在创建了replicatedmergetree表之后,我在每个节点中创建了distribute表(只针对每个节点有这个表,实际上它只在一个节点上创建)

CREATE TABLE game_all AS game  
ENGINE = Distributed(logs, default, game ,rand())

现在还可以。我也认为在game\u all中插入数据是可以的。但是当我从game表和game\u all表中查询数据时,我发现一定是出了问题。因为我在game\ u all表中插入了一条记录,但是结果是3,它必须是1,我查询每个game表,只有一个表有1条记录。最后我检查每个节点的磁盘,这个表中似乎没有副本,因为只有一个节点的磁盘使用量超过4kb,其他节点没有磁盘使用量只有4kb。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题