CREATE TABLE user_activity( event_date Date MATERIALIZED toDate(now()), time_stamp DateTime MATERIALIZED toDateTime(now()), device_id String, partner_id UInt32 DEFAULT toUInt32(0), event_id String, os String, ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/user_activity', '{replica}', event_date, (partner_id, os, time_stamp, event_id, device_id), 8192)<macros> <shard>01</shard> <replica>clickhouseserver2</replica></macros>
<macros> <shard>02</shard> <replica>clickhouseserver1/replica></macros>CREATE TABLE user_activity_distribute AS user_activity ENGINE = Distributed(clickhouse, datalayer, retargeting, partner_id);
2017.02.17 09:05:06.829412 [ 3 ] <Debug> datalayer.user_activity (StorageReplicatedMergeTree): Creating table /clickhouse/tables/01/user_activity
2017.02.17 09:05:06.898994 [ 3 ] <Debug> datalayer.user_activity (StorageReplicatedMergeTree): Creating replica /clickhouse/tables/01/user_activity/replicas/clickhouseserver2
<remote_servers> <datalayer> <shard> <weight>1</weight> <internal_replication>true</internal_replication> <replica> <host>clickhouseserver1</host> <port>9000</port> </replica> <replica> <host>clickhouseserver2</host> <port>9000</port> </replica> </shard> <shard> <weight>1</weight> <internal_replication>true</internal_replication> <replica> <host>clickhouseserver2</host> <port>9000</port> </replica> <replica> <host>clickhouseserver1</host> <port>9000</port> </replica> </shard> </datalayer></remote_servers>Code: 44. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Cannot insert column event_date.
ALTER TABLE datalayer.user_activity RESHARD TO '/clickhouse/tables/01/user_activity' WEIGHT 1, '/clickhouse/tables/02/user_activity' WEIGHT 1 USING partner_id
Code: 310. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Table is inconsistent accross shards.