LINUX.ORG.RU
решено ФорумAdmin

nginx-log-collector clickhouse DB::Exception: Replica name must be a string literal

 


0

1

Установил кластер clickhouse с помощью https://github.com/danwerspb/ansible-clickhouse-dp

Пытаюсь создать таблицу из этого файла https://github.com/avito-tech/nginx-log-collector/blob/master/etc/examples/clickhouse/table_schema.sql

clickhouse-client 
ClickHouse client version 19.17.6.36 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 19.17.6 revision 54428.

nginx-log-collector-apatsev-2 :) CREATE TABLE nginx.error_log
(
    event_datetime DateTime,
    event_date Date,
    server_name LowCardinality(String),
    http_referer String,
    pid UInt32,
    sid UInt32,
    tid UInt64,
    host LowCardinality(String),
    client String,
    request String,
    message String,
    login String,
    upstream String,
    subrequest String,
    hostname LowCardinality(String)
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/logs_replicator/nginx.error2_log', _SET_ME_, event_date, (server_name, request, event_date), 8192)

CREATE TABLE nginx.error_log
(
    `event_datetime` DateTime, 
    `event_date` Date, 
    `server_name` LowCardinality(String), 
    `http_referer` String, 
    `pid` UInt32, 
    `sid` UInt32, 
    `tid` UInt64, 
    `host` LowCardinality(String), 
    `client` String, 
    `request` String, 
    `message` String, 
    `login` String, 
    `upstream` String, 
    `subrequest` String, 
    `hostname` LowCardinality(String)
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/logs_replicator/nginx.error2_log', _SET_ME_, event_date, (server_name, request, event_date), 8192)

Received exception from server (version 19.17.6):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Replica name must be a string literal

Попытался поменять logs_replicator на {shard}

CREATE TABLE nginx.error_log
(
    event_datetime DateTime,
    event_date Date,
    server_name LowCardinality(String),
    http_referer String,
    pid UInt32,
    sid UInt32,
    tid UInt64,
    host LowCardinality(String),
    client String,
    request String,
    message String,
    login String,
    upstream String,
    subrequest String,
    hostname LowCardinality(String)
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/nginx.error2_log', _SET_ME_, event_date, (server_name, request, event_date), 8192)

CREATE TABLE nginx.error_log
(
    `event_datetime` DateTime, 
    `event_date` Date, 
    `server_name` LowCardinality(String), 
    `http_referer` String, 
    `pid` UInt32, 
    `sid` UInt32, 
    `tid` UInt64, 
    `host` LowCardinality(String), 
    `client` String, 
    `request` String, 
    `message` String, 
    `login` String, 
    `upstream` String, 
    `subrequest` String, 
    `hostname` LowCardinality(String)
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/nginx.error2_log', _SET_ME_, event_date, (server_name, request, event_date), 8192)

Received exception from server (version 19.17.6):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Replica name must be a string literal

Как сделать реплику?

Сделал вот так:

CREATE TABLE nginx.error_log
(
    event_datetime DateTime,
    event_date Date,
    server_name LowCardinality(String),
    http_referer String,
    pid UInt32,
    sid UInt32,
    tid UInt64,
    host LowCardinality(String),
    client String,
    request String,
    message String,
    login String,
    upstream String,
    subrequest String,
    hostname LowCardinality(String)
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/logs_replicator/nginx.error2_log', '{replica}', event_date, (server_name, request, event_date), 8192)

chemtech
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.