Skip to content

ClickHouse Requirements#

System Requirements#

Item Minimum Recommended
Version 26.3 26.3
Memory 16GB 32GB
CPU 4vCPUs 8vCPUs
Disk Space 1TB 3TB

Table: Minimum and recommended system requirements for ClickHouse

Recommended Container Image

Use an Altinity Stable image when deploying ClickHouse. Altinity Stable images are recommended because they provide a longer support period.

Server-Level Settings#

The following settings must be configured at the ClickHouse server level before proceeding with user provisioning.

Setting Value Details
allow_materialized_view_with_bad_select 1 Required for migrations to MES 11.0.0+ when moving to an external ClickHouse Cloud setup. Must be configured prior to starting the migration. See ClickHouse Migration ↗.

Table: Mandatory server-level ClickHouse settings

Databases#

As of MES version 11.0.0, the platform uses four ClickHouse databases. Their names are derived from the MES System Name — the example below assumes a system named MES:

Database Naming pattern Purpose
MES <SystemName> Main operational database
MESCDM <SystemName>CDM Common Data Model database
MESODS <SystemName>ODS Operational Data Store database
MESDWH <SystemName>DWH Data Warehouse database

SQL Server Database Deprecation

The ODS and DWH databases on SQL Server are deprecated. New MES implementations should use the ClickHouse versions instead for improved performance and scalability.

Reserved Names#

MES deployment and runtime operations rely on a fixed naming convention for ClickHouse roles, settings profiles, and quotas. The following object names must not be used for any other purpose in the ClickHouse instance.

Reserved Name Object Type Description
<SystemName>_<KEY>_ROLE Role Role attached to the MES user that holds the grants required to perform MES operations.
<SystemName>_<KEY>_PROFILE Settings Profile Settings profile assigned to the role to enforce the mandatory user-level ClickHouse settings.
<SystemName>_<KEY>_QUOTA Quota Quota assigned to the role. It is created only for roles that need runtime usage limits, currently the DWH Playground (Read) role. Otherwise, it is dropped during provisioning.

Table: ClickHouse reserved names

Where <SystemName> is the name of the MES, the same value that gives the databases their names, and <KEY> is one of the keys listed in Users, Roles, and ACLs.

The role attached to the Default User is not covered by this convention. The customer creates and names that role.

Users, Roles, and ACLs#

MES requires two categories of ClickHouse users:

For each MES user, the role must first be created and assigned to the user before the permissions in the sections below can be applied. The name of the role is built from the name of the system and a fixed key, in the form <SystemName>_<KEY>_ROLE:

CREATE ROLE IF NOT EXISTS `<SystemName>_<KEY>_ROLE`;
GRANT `<SystemName>_<KEY>_ROLE` TO <user>;

Each MES user has its own key:

Key User
CLICKHOUSE_MES_READWRITE MES (Read/Write)
CLICKHOUSE_ANALYTICS_READ Analytics (Read)
CLICKHOUSE_ANALYTICS_READWRITE_ADMIN Analytics (Read/Write) Admin
CLICKHOUSE_ANALYTICS_READ_DWH_WRITE Analytics (Read) / DWH (Read/Write)
CLICKHOUSE_DWH_READ DWH (Read)
CLICKHOUSE_DWH_READ_PLAYGROUND DWH Playground (Read)

Table: ClickHouse role keys

On a system named MES, the role of the Analytics (Read) user is MES_CLICKHOUSE_ANALYTICS_READ_ROLE.

The permissions assigned to MES users follow the standard ClickHouse security model. For a detailed breakdown of each privilege, refer to ClickHouse SQL Reference: GRANT Permissions ↗.

Default User#

The Default User is the account that must already exist in the customer ClickHouse installation. This user is either created manually by the customer or corresponds to the default user provided by their ClickHouse setup.

The Environment Manager uses this account to connect to ClickHouse during environment creation and configuration. Therefore, the following administrative grants must be assigned to a role attached to this user to allow for the automatic provisioning of users required by Critical Manufacturing MES.

Category Permissions WITH Grant Option?
User Management CREATE USER, ALTER USER, DROP USER No
Role Management CREATE ROLE, ALTER ROLE, DROP ROLE, ROLE ADMIN No
Settings & Profiles CREATE SETTINGS PROFILE, ALTER SETTINGS PROFILE, DROP SETTINGS PROFILE No
Quota Management CREATE QUOTA, ALTER QUOTA, DROP QUOTA No
Backup & Restore BACKUP No
Database Management CREATE DATABASE, DROP DATABASE, SHOW Yes
Data Management SELECT, INSERT, ALTER, CREATE TABLE, DROP TABLE, UNDROP TABLE, CREATE TEMPORARY TABLE, CREATE VIEW, DROP VIEW, CREATE DICTIONARY, DROP DICTIONARY, TRUNCATE, OPTIMIZE, CREATE ROW POLICY, ALTER ROW POLICY, DROP ROW POLICY, SHOW ROW POLICIES, DICTGET Yes

Table: Default User required permissions — all scoped to *.* (Global)

You can apply all the above permissions using the following SQL statement:

GRANT
    CREATE USER, ALTER USER, DROP USER,
    CREATE ROLE, ALTER ROLE, DROP ROLE, ROLE ADMIN,
    CREATE SETTINGS PROFILE, ALTER SETTINGS PROFILE, DROP SETTINGS PROFILE,
    CREATE QUOTA, ALTER QUOTA, DROP QUOTA,
    BACKUP, SHOW ACCESS
ON *.* TO <default_user>_role;

GRANT 
    CREATE DATABASE, DROP DATABASE, SHOW, SELECT, INSERT, ALTER,
    CREATE TABLE, DROP TABLE, UNDROP TABLE, CREATE TEMPORARY TABLE, 
    CREATE VIEW, DROP VIEW, CREATE DICTIONARY, DROP DICTIONARY, TRUNCATE, OPTIMIZE, 
    CREATE ROW POLICY, ALTER ROW POLICY, DROP ROW POLICY, SHOW ROW POLICIES, DICTGET, CLUSTER
ON *.* TO <default_user>_role WITH GRANT OPTION;

Permission Hierarchy

Permissions like ALL are administrative shorthands that encompass multiple granular privileges (e.g., SELECT, INSERT, CREATE TABLE). When configuring the Default User, ensure that the WITH GRANT OPTION is included to allow the Environment Manager to delegate these functional rights to the MES sub-users.

Analytics (Read/Write) Admin#

Administrative user with extended privileges for managing all analytics databases and deployments.

  • Databases: <SystemName>, <SystemName>ODS, <SystemName>CDM, <SystemName>DWH
  • Required Permissions:

    GRANT
        CREATE DATABASE, DROP DATABASE, SHOW, SELECT,
        INSERT, ALTER, CREATE TABLE, DROP TABLE, UNDROP TABLE,
        CREATE TEMPORARY TABLE, CREATE VIEW, DROP VIEW,
        CREATE DICTIONARY, DROP DICTIONARY, TRUNCATE, OPTIMIZE,
        CREATE ROW POLICY, ALTER ROW POLICY, DROP ROW POLICY, 
        SHOW ROW POLICIES, DICTGET, CLUSTER
    ON <SystemName>*.* TO `<SystemName>_CLICKHOUSE_ANALYTICS_READWRITE_ADMIN_ROLE`;
    

MES (Read/Write)#

User responsible for reading and writing core operational MES data.

  • Databases: <SystemName>
  • Required Permissions:

    GRANT
        SELECT, INSERT, ALTER, CREATE TABLE, CREATE VIEW, CREATE DICTIONARY, CLUSTER
    ON <SystemName>.* TO `<SystemName>_CLICKHOUSE_MES_READWRITE_ROLE`;
    

Analytics (Read)#

User with read-only access for general reporting and data consumption across all Analytics databases.

  • Databases: <SystemName>, <SystemName>ODS, <SystemName>CDM, <SystemName>DWH, system
  • Required Permissions:

    GRANT 
        SELECT ON <SystemName>*.* TO `<SystemName>_CLICKHOUSE_ANALYTICS_READ_ROLE`,
        SELECT(volume_name, policy_name) ON system.storage_policies,
        SELECT(value, name) ON system.build_options,
        CREATE TEMPORARY TABLE ON *.*
    TO `<SystemName>_CLICKHOUSE_ANALYTICS_READ_ROLE`;
    

Analytics (Read) / DWH (Read/Write)#

User responsible for processes that populate the DWH, with read-only access to source databases.

  • Databases: <SystemName>CDM, <SystemName>DWH
  • Required Permissions:

    GRANT SELECT ON <SystemName>CDM.* TO `<SystemName>_CLICKHOUSE_ANALYTICS_READ_DWH_WRITE_ROLE`;
    
    GRANT
        SHOW,
        SELECT, INSERT, ALTER, CREATE TABLE, CREATE VIEW, CREATE DICTIONARY,
        DROP TABLE, DROP VIEW, DROP DICTIONARY, UNDROP TABLE, TRUNCATE, OPTIMIZE,
        CREATE ROW POLICY, ALTER ROW POLICY, DROP ROW POLICY, SHOW ROW POLICIES, 
        DICTGET, CLUSTER
    ON <SystemName>DWH.* TO `<SystemName>_CLICKHOUSE_ANALYTICS_READ_DWH_WRITE_ROLE`;
    

DWH (Read)#

User with read-only access exclusively to the Data Warehouse.

  • Databases: <SystemName>DWH
  • Required Permissions:

    GRANT SELECT ON <SystemName>DWH.* TO `<SystemName>_CLICKHOUSE_DWH_READ_ROLE`;
    

DWH Playground (Read)#

User with read-only access to the Data Warehouse for Cube Explorer ad-hoc queries. Unlike other MES users that run controlled application-driven workloads, this user can be unpredictable in cost. Quotas are applied to protect the ClickHouse cluster from runaway queries.

  • Databases: <SystemName>DWH
  • Required Permissions:

    GRANT SELECT ON <SystemName>DWH.* TO `<SystemName>_CLICKHOUSE_DWH_READ_PLAYGROUND_ROLE`;
    
  • Recommended Quotas:

    CREATE QUOTA OR REPLACE `<SystemName>_CLICKHOUSE_DWH_READ_PLAYGROUND_QUOTA`
        FOR INTERVAL 1 hour MAX execution_time = 900,
        FOR INTERVAL 1 hour MAX result_rows = 1000000
        TO `<SystemName>_CLICKHOUSE_DWH_READ_PLAYGROUND_ROLE`;
    

User-Level Settings Profiles#

Once users and roles are created, a settings profile must be applied to ensure correct MES operation. The following settings are mandatory for all MES ClickHouse users:

Setting Value Details
compatibility 26.3 Locks ClickHouse behavior to version 26.3 semantics. Ensures consistent query execution and feature availability regardless of the actual ClickHouse server version.
do_not_merge_across_partitions_select_final 0 Prevents data duplication in ODS state tables (e.g., CoreDataModel_T_Material). While default in ClickHouse 25.3 and automatically enforced from MES 11.2.3+, it must be manually verified for older versions or custom configurations to ensure it remains at 0.
http_max_field_value_size 262144 Raises the maximum length (in bytes) of an HTTP header field value (256 KiB, up from the 128 KiB default). Required to support the large queries that the CDM Builder sends over HTTP when it batches multiple records into a single statement.
max_query_size 10000000 Raises the maximum size (in bytes) of the SQL string that the parser will accept (~10 MB, up from the 256 KiB default). Required to support the large queries generated by MES analytics workloads (for example, queries with extensive IN clauses).
throw_on_max_partitions_per_insert_block 0 Prevents insert failures when data spans a large number of partitions. Disabling this check ensures bulk inserts into partitioned tables complete without errors.
transform_null_in 1 Ensures correct NULL handling in IN clauses by enabling NULL-safe equality comparisons. Required for accurate query results across MES analytics queries.

Table: Mandatory user-level ClickHouse settings

When using automatic provisioning, MES creates these profiles automatically. For manual provisioning, run the following statement once for each MES user role:

-- Run this once for each MES user role, replacing <KEY> with one of:
--   CLICKHOUSE_MES_READWRITE
--   CLICKHOUSE_ANALYTICS_READ
--   CLICKHOUSE_ANALYTICS_READWRITE_ADMIN
--   CLICKHOUSE_ANALYTICS_READ_DWH_WRITE
--   CLICKHOUSE_DWH_READ
--   CLICKHOUSE_DWH_READ_PLAYGROUND
CREATE SETTINGS PROFILE OR REPLACE `<SystemName>_<KEY>_PROFILE`
  SETTINGS
    compatibility = '26.3',
    do_not_merge_across_partitions_select_final = 0,
    http_max_field_value_size = 262144,
    max_query_size = 10000000,
    throw_on_max_partitions_per_insert_block = 0,
    transform_null_in = 1
  TO `<SystemName>_<KEY>_ROLE`;

Row Policies#

The MES creates ClickHouse row policies to restrict the rows that a Data Platform query returns. Each policy is created with its table and applies to the <SystemName>_CLICKHOUSE_ANALYTICS_READ_ROLE role.

The privileges that support this behavior are already listed in the sections above:

  • CREATE TEMPORARY TABLE ON *.* on the Analytics (Read) role. Data Platform creates a temporary table for each request to hold the Data Groups of the caller, and the row policy reads that table.
  • CREATE ROW POLICY, ALTER ROW POLICY, DROP ROW POLICY, and SHOW ROW POLICIES on the Analytics (Read/Write) Admin role and on the role attached to the Default User.

Do not remove these privileges. Without them, tables are created without a policy, and every Data Platform query returns every row.

Info

For more information on what the policies do, see Data Set Data Access Security.

High Availability#

For new on-premises deployments of Critical Manufacturing MES, configure a ClickHouse cluster. A cluster with more than one replica keeps a copy of the data on multiple servers, so that Data Platform stays available when a server fails. A single-replica cluster has no redundant copy of the data.

The requirements depend on how you deploy ClickHouse.

Deployment Replication Requirements
ClickHouse in the MES stack Single replica None. The MES package deploys a cluster with one replica and an embedded Keeper. No load balancer is required. You cannot add replicas to this deployment; move to an external self-managed cluster to use more replicas. Internal ClickHouse is not supported in Staging or Production environments.
External self-managed ClickHouse Supported A cluster defined in the ClickHouse server configuration and at least three ClickHouse Keeper instances. For high availability, use two or more replicas and a load balancer. See ClickHouse Keeper for sizing.
ClickHouse Cloud Supported None. The service handles replication for you.

Table: ClickHouse replication support per deployment option

ClickHouse Keeper#

A self-managed cluster needs at least three ClickHouse Keeper instances. Always use an odd number of instances. For sizing, use the smallest odd number greater than the number of ClickHouse replicas: three Keeper instances for two replicas, or five Keeper instances for three or four replicas.

ClickHouse Keeper needs a majority of instances to agree on the state of the data. With three instances, the cluster keeps working when one instance fails, because the other two still form a majority.

The single-replica cluster in the MES stack includes an embedded Keeper, so you do not provision separate Keeper instances. ClickHouse Cloud manages replication internally and does not require customer-managed Keeper instances.

Load Balancer#

A self-managed ClickHouse cluster with more than one replica requires a load balancer. Configure the MES connection settings to use its endpoint. The single-replica cluster in the MES stack does not require a load balancer. ClickHouse Cloud provides its own endpoint and does not require a customer-managed load balancer.

Configure failover so that another replica takes over when the replica serving a connection fails. If the load balancer distributes connections across replicas, enable sticky sessions based on the source IP address, with a session duration of at least 24 hours. Longer durations are supported. All connections from the same source IP address must reach the same replica during that period.

The Aggregation Engine uses dbt to read back the data it has just written. Sending a subsequent read to a replica that has not caught up can make the aggregation fail.

For the configuration steps, see ClickHouse Connection Setup.

Cluster Name#

On a self-managed cluster, the MES needs the name of the ClickHouse cluster. Set the Cluster Name when you create the Customer Environment.

The name must match the cluster defined in the ClickHouse server configuration. The Environment Manager, the HouseKeeper, and the Aggregation Engine use this name to create and change tables on the cluster. Configure the cluster name even when the self-managed cluster has only one replica. Leave it empty for ClickHouse Cloud, where the service manages replication.

Table Engines#

The MES chooses the table engine based on the deployment:

  • Self-managed cluster - tables use the Replicated*MergeTree engine family.
  • Single-replica cluster in the MES stack - tables use the Replicated*MergeTree engine family. The deployment includes only one replica, so there is no redundant copy of the data.
  • ClickHouse Cloud - tables use the standard *MergeTree engine family, and the service converts them to Shared*MergeTree tables.

Note

The Shared*MergeTree engine family exists only in ClickHouse Cloud, and the Replicated*MergeTree engine family is not supported there. The MES handles this difference for you.

Read-After-Write Consistency#

The Data Platform builds the analytics models with dbt, which needs to read the data it has just written. On a replicated cluster, a query that reaches a different replica may not see that data yet.

  • Self-managed cluster - configure failover and, when distributing connections across replicas, source-IP-based sticky sessions lasting at least 24 hours. This keeps reads and writes from the same source IP address on the same replica. See Load Balancer.
  • ClickHouse Cloud - MES sets select_sequential_consistency to 1 in the settings profile of each MES user. For more information, see User-Level Settings Profiles.

Migration of Existing Installations#

When you upgrade an existing environment to version 12.0 with a cluster name configured, the MES converts the databases and the tables that already exist to the cluster and to the Replicated*MergeTree engine family. You do not need to convert them yourself.

For a restored non-replicated backup, the installation must include the ClickHouseRunMigration step to perform this conversion. Native restore and a change to the cluster name do not rerun already installed packages by themselves.