Добрый день! Установил ClickHouse для изучения, не получается настроить репликацию таблицы.
Подскажите пожалуйста, в чем может быть ошибка и как отладить репликацию.
Исходные данные:
3 виртуальные ОС ubuntu-16.04
Zookeeper version: 3.4.8-1--1
ClickHouse client version 1.1.54023
ClickHouse server version 1.1.54023
Конфигурация CH /etc/clickhouse-server/config.xml (на всех нодах)
...
<remote_servers>
<my_test>
<shard>
<weight>1</weight>
<internal_replication>false</internal_replication>
<replica>
<host>ubuntu02</host>
<port>9000</port>
</replica>
</shard>
<shard>
<weight>1</weight>
<internal_replication>false</internal_replication>
<replica>
<host>ubuntu01</host>
<port>9000</port>
</replica>
<replica>
<host>ubuntu03</host>
<port>9000</port>
</replica>
</shard>
</my_test>
</remote_servers>
<zookeeper>
<node index="1">
<host>ubuntu01</host>
<port>2181</port>
</node>
<node index="2">
<host>ubuntu02</host>
<port>2181</port>
</node>
<node index="3">
<host>ubuntu03</host>
<port>2181</port>
</node>
</zookeeper>
...
Проверка описание кластера:
select * from system.clusters;
┌─cluster──┬─shard_num─┬─shard_weight─┬─replica_num─┬─host_name─┬─host_address──┬─port─┬─is_local─┬─user────┬─default_database─┐
│ my_test │ 1 │ 1 │ 1 │ ubuntu02 │ ip_ubuntu02 │ 9000 │ 0 │ default │ │
│ my_test │ 2 │ 1 │ 1 │ ubuntu01 │ 127.0.1.1 │ 9000 │ 0 │ default │ │
│ my_test │ 2 │ 1 │ 2 │ ubuntu03 │ ip_ubuntu03 │ 9000 │ 0 │ default │ │
└──────────┴───────────┴──────────────┴─────────────┴───────────┴───────────────┴──────┴──────────┴─────────┴──────────────────┘
На ubuntu01 выполнен запрос:
CREATE TABLE test.test_tbl(UID UInt64,\
rec_date Date DEFAULT today(),\
event_date DateTime,\
event_type String\
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/02/test_tbl', '01', rec_date, (event_date, event_type, UID), 8192);
Индексы шарды и реплики подставлены в соотв. с паттерном:
ReplicatedMergeTree('/clickhouse/tables/{shard}/test_tbl', '{replica}', ...)
На ubuntu03 выполнен запрос:
CREATE TABLE test.test_tbl(UID UInt64,\
rec_date Date DEFAULT today(),\
event_date DateTime,\
event_type String\
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/02/test_tbl', '02', rec_date, (event_date, event_type, UID), 8192);
На ubuntu01 выполнен запрос:
INSERT INTO test.test_tbl (UID, event_date, event_type) VALUES (770, '2014-01-01 02:00:00', 'test_type2');
На ubuntu03 выполнен запрос:
select * from test.test_tbl;
SELECT *
FROM test.test_tbl
→ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Ok.
0 rows in set. Elapsed: 0.001 sec.
На реплике ubuntu03, куда предположительно должны доехать данные, мы видим пустую таблицу.
Состояние zookeeper:
SELECT *
FROM system.zookeeper
WHERE path = '/clickhouse/tables/02/test_tbl'
columns columns format version: 1 4 columns: `UID` UInt64 `rec_date` Date DEFAULT today() `event_date` DateTime `event_type` String
replicas last added replica: 02
При этом, если на ubuntu03 сделать вставку такой же записи, то она не появляется:
:) INSERT INTO test.test_tbl (UID, event_date, event_type) VALUES (770, '2014-01-01 02:00:00', 'test_type2');
INSERT INTO test.test_tbl (UID, event_date, event_type) VALUES
Ok.
1 rows in set. Elapsed: 0.297 sec.
:) select * from test.test_tbl;
SELECT *
FROM test.test_tbl
↘ Progress: 0.00 rows, 0.00 B (0.00 rows/s., 0.00 B/s.) Ok.
0 rows in set. Elapsed: 0.001 sec.