Building ClickHouse - linux-on-ibm-z/docs GitHub Wiki

Building ClickHouse

The instructions provided below specify the steps to build ClickHouse version 26.8.15.10 on Linux on IBM Z for the following distributions:

  • RHEL (8.10, 9.6, 9.8, 10.0, 10.2)
  • SLES (15 SP7, 16)
  • Ubuntu (22.04, 24.04)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Porting Notes:

The following third-party integrations are excluded from this build to focus on core ClickHouse functionality:

  • Storage / formats: PARQUET, ORC, HDFS, HIVE, AVRO, ICEBERG, PAIMON, PUFFIN, DELTALAKE

  • Networking / RPC: GRPC, ARROW_FLIGHT

  • Cloud storage: AZURE_BLOB_STORAGE

  • Compression: SZ3

  • Search: VECTORSCAN

  • Databases: MYSQL

  • Analytics: DATASKETCHES includes countmin and uniq_theta

  • Language processing: NLP

  • Kafka support cannot be tested because the test harness does not support s390x.

Testing Notes

  • Tests for unsupported functionality will not pass.
  • The following tests fail due to s390x platform differences:
Test Name Failure Reason
01502_jemalloc_percpu_arena A warning that should be suppressed is being output on s390x but the test passes otherwise. <jemalloc>: Number of CPUs detected is not deterministic. Per-CPU arena disabled.
01505_pipeline_executor_UAF A warning that should be suppressed is being output on s390x but the test passes otherwise. <jemalloc>: Number of CPUs detected is not deterministic. Per-CPU arena disabled.
02947_merge_tree_index_table_2 Column ordering is not specified and differs on big endian because it is determined by std::hash which is endian dependent.
02947_merge_tree_index_table_4 Column ordering is not specified and differs on big endian because it is determined by std::hash which is endian dependent.
03321_system_tables_parametrized_view_params Column ordering is not specified and differs on big endian because it is determined by std::hash which is endian dependent.
05234_restore_duplicate_definition_secret_mask Fails because the test uses AzureBlobStorage in part of the test but passes otherwise.
02784_connection_string Fails in environments where IPV6 network binding is not supported.
02896_dwarf_format Manually confirmed DWARF format works on s390x but the test input is a little endian executable and the llvm DWARF functions expect native endian.
05139_dwarf_format_header_types Manually confirmed DWARF format works on s390x but the test input is a little endian executable and the llvm DWARF functions expect native endian.
00974_query_profiler Two results doesn't match for query profiler. Query profiling tests are known to be flaky and are being reworked in newer versions.
04357_join_runtime_filter_size_from_hash_table_stats One result doesn't match for query profiler. Query profiling tests are known to be flaky and are being reworked in newer versions.
01158_zookeeper_log_long Test is passing except for different hash values in part name which is not a bug.
00092_obfuscator The clickhouse obfuscator a utility program for generating perf data and is endian dependent.
00096_obfuscator_save_load The clickhouse obfuscator a utility program for generating perf data and is endian dependent.
00175_obfuscator_schema_inference The clickhouse obfuscator a utility program for generating perf data and is endian dependent.
04305_adaptive_codec_default_merge The compressed bytes size of LZ4 compressed string columns differs slightly from expected but LZ4 does not guarantee identical byte streams on different endianness platforms.
03707_analyzer_convert_outer_any_to_inner The order of some column ids does not match little endian but the data returned is correct.
03023_group_by_use_nulls_analyzer_crashes There is no order by in some queries. The correct values are returned but the order differs from little endian platforms.
02481_analyzer_optimize_aggregation_arithmetics There is no order by in these queries. The correct values are returned but the order differs from little endian platforms.
01222_system_codecs This test queries the compression codecs in the database but on s390x the SZ3 codec is disabled and so does not match the expected value.
01086_odbc_roundtrip This test uses the odbc bridge which is not available for s390x.
02207_s3_content_type This tests executes the aws cli binary which is not available on s390x.
03917_row_number_csv_file This tests uses the _row_number magic column for CSV format but _row_number is not available when the PARQUET format is disabled.

Build and Install ClickHouse

Prerequisites:

  • For RHEL and Ubuntu distributions, docker can be installed by following the instructions here.
  • For SLES distribution, Docker can be installed directly using the system package manager.

1. Build using script

If you want to build ClickHouse using manual steps, go to Step 2.

Use the following commands to build ClickHouse using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/ClickHouse/26.8.15.10/build_clickhouse.sh

# Build ClickHouse
bash build_clickhouse.sh   [Provide -t option for executing build with tests]

In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

2. Install Dependencies

export SOURCE_ROOT=/<source_root>/
export PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/ClickHouse/26.8.15.10/patch"

2.1. Install basic dependencies

  • RHEL (8.10, 9.6, 9.8)

    sudo yum install -y git curl wget python3.12 python3.12-requests
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
    sudo update-alternatives --set python3 /usr/bin/python3.12

    Note: Add the --allowerasing option to the yum command above if any dependency conflicts are encountered.

  • RHEL (10.0, 10.2)

    sudo yum install -y git curl wget python3 python3-requests

    Note: Add the --allowerasing option to the yum command above if any dependency conflicts are encountered.

  • SLES 15 SP7

    export DOCKER_BUILDKIT=1
    sudo zypper install -y git curl wget python311 python311-requests
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
    sudo update-alternatives --set python3 /usr/bin/python3.11
  • SLES 16

    export DOCKER_BUILDKIT=1
    sudo zypper install -y git curl wget python3 python3-requests
  • Ubuntu (22.04, 24.04)

    sudo apt-get update
    sudo apt-get install -y git curl wget python3 python3-requests

3. Build and Install ClickHouse

  • Clone ClickHouse and apply patches

    cd "$SOURCE_ROOT"/
    git clone --recurse-submodules --shallow-submodules --depth 1 --jobs $(( $(nproc) - 1 )) -b v26.8.15.10-lts https://github.com/ClickHouse/ClickHouse.git
    cd ClickHouse
    
    # Apply patches to add s390x support to the ClickHouse CI build system
    curl -sSL $PATCH_URL/clickhouse-ci.patch | git apply -
    # Apply patches to add s390x support to the ClickHouse source
    curl -sSL $PATCH_URL/clickhouse.patch | git apply -
    
    # Fix s390x sysroot which is missing an empty lib dir
    mkdir -p contrib/sysroot/linux-s390x/s390x-linux-gnu/libc/usr/lib
  • Build the ClickHouse builder Docker images

    Note: The fasttest and cctools images have a recursive dependency on each other, so fasttest must be built twice.

    cd "$SOURCE_ROOT/ClickHouse"
    # Some Dockerfiles hard-code uid/gid 1000; patch them to match the current user to ensure files can be created
    # with the correct permissions.
    sed -i \
      -e "s/addgroup --gid 1000 clickhouse && adduser --uid 1000 --gid 1000 --disabled-password clickhouse$/addgroup --gid $(id -g) clickhouse \&\& adduser --uid $(id -u) --gid $(id -g) --disabled-password clickhouse/g" \
      -e "s/addgroup --gid 1001 clickhouse2 && adduser --uid 1001 --gid 1001 --disabled-password clickhouse2$/addgroup --gid $(( $(id -g) + 1 )) clickhouse2 \&\& adduser --uid $(( $(id -u) + 1 )) --gid $(( $(id -g) + 1 )) --disabled-password clickhouse2/g" \
      -e "s/groupadd --system --gid 1000 clickhouse/groupadd --system --gid $(id -g) clickhouse/g" \
      -e "s/useradd --system --gid 1000 --uid 1000 -m clickhouse/useradd --system --gid $(id -g) --uid $(id -u) -m clickhouse/g" \
      ci/docker/fasttest/Dockerfile
    
    cd ci/docker/fasttest/
    docker build --network=host --progress=plain --build-arg=CCTOOLS_AVAILABLE=without-cctools -t clickhouse/fasttest .
    cd ../cctools/
    docker build --network=host --progress=plain --build-arg=CCTOOLS_AVAILABLE=without-cctools -t clickhouse/cctools .
    cd ../fasttest/
    docker build --network=host --progress=plain --build-arg=CCTOOLS_TAG=latest -t clickhouse/fasttest .
    cd ../binary-builder/
    docker build --network=host --progress=plain --build-arg=FROM_TAG=latest --build-arg=CCTOOLS_TAG=latest --build-arg=TOOLCHAIN_COMMIT=none -t clickhouse/binary-builder .
  • Build ClickHouse

    cd "$SOURCE_ROOT/ClickHouse"
    python3 -m ci.praktika run --docker "clickhouse/binary-builder:latest" --param=cmake "Build (s390x_release)"
  • Build the ClickHouse server Docker image

    cd "$SOURCE_ROOT/ClickHouse/ci/tmp/"
    python3 -m http.server 8888 > /dev/null 2>&1 &
    SERVER_PID=$!
    
    cd "$SOURCE_ROOT/ClickHouse/docker/server/"
    docker build --progress=plain \
      --add-host=host.docker.internal:host-gateway \
      --build-arg=DIRECT_DOWNLOAD_URLS="http://host.docker.internal:8888/clickhouse-common-static_26.8.15.1_s390x.deb http://host.docker.internal:8888/clickhouse-server_26.8.15.1_s390x.deb http://host.docker.internal:8888/clickhouse-client_26.8.15.1_s390x.deb" \
      -t "clickhouse-server:v26.8.15.10-lts" .
    
    kill $SERVER_PID

The ClickHouse packages (.deb, .rpm and .tgz files) will be generated in $SOURCE_ROOT/ClickHouse/ci/tmp/.

4. Test (Optional)

cd $SOURCE_ROOT/ClickHouse
  • Build the test Docker images

    # patch uid/gid in the stateless-test Dockerfile to match the current user (same sed as Step 3)
    sed -i \
      -e "s/addgroup --gid 1000 clickhouse && adduser --uid 1000 --gid 1000 --disabled-password clickhouse$/addgroup --gid $(id -g) clickhouse \&\& adduser --uid $(id -u) --gid $(id -g) --disabled-password clickhouse/g" \
      -e "s/addgroup --gid 1001 clickhouse2 && adduser --uid 1001 --gid 1001 --disabled-password clickhouse2$/addgroup --gid $(( $(id -g) + 1 )) clickhouse2 \&\& adduser --uid $(( $(id -u) + 1 )) --gid $(( $(id -g) + 1 )) --disabled-password clickhouse2/g" \
      -e "s/groupadd --system --gid 1000 clickhouse/groupadd --system --gid $(id -g) clickhouse/g" \
      -e "s/useradd --system --gid 1000 --uid 1000 -m clickhouse/useradd --system --gid $(id -g) --uid $(id -u) -m clickhouse/g" \
      ci/docker/stateless-test/Dockerfile
    
    cd ci/docker/test-base/
    docker build --network=host --progress=plain --build-arg=CCTOOLS_TAG=latest -t clickhouse/test-base .
    cd ../stateless-test/
    docker build --network=host --progress=plain --build-arg=MINIO_SOURCE=local --build-arg=CCTOOLS_TAG=latest -t clickhouse/stateless-test .
  • Prepare the test environment

    cd "$SOURCE_ROOT/ClickHouse"
    rm -rf ci/tmp-build/
    mv ci/tmp/ ci/tmp-build/
    mkdir -p ci/tmp
    cp ci/tmp-build/build/programs/clickhouse ci/tmp/
  • Run tests

    cd "$SOURCE_ROOT/ClickHouse"
    # Randomized test settings in the stateless tests can cause the tests to run very slowly
    # and doesn't provide any value outside of ClickHouse CI. Disable it here.
    sed -i \
      's/runner_options\s*=\s*""/runner_options = " --no-random-settings --no-random-merge-tree-settings "/' \
      ci/jobs/functional_tests.py
    
    python3 -m ci.praktika run --docker "clickhouse/stateless-test:latest" "Stateless tests (s390x_binary, parallel)"
    # Save the parallel test directories to prepare for running the sequential tests
    mv ci/tmp/ ci/tmp-parallel/
    mkdir -p ci/tmp
    cp ci/tmp-build/build/programs/clickhouse ci/tmp/
    # Some stateless test leave files behind. Clean up the known ones.
    sudo rm -rf 03371_qbit_read_write_test_* __cache__/ disks/ queries_* ssh_key tests/queries/0_stateless/00408_test_* uuid_test_* || true
    
    python3 -m ci.praktika run --docker "clickhouse/stateless-test:latest" "Stateless tests (s390x_binary, sequential)"
    # Save the sequential test directories to prepare for restoring the build environment
    mv ci/tmp/ ci/tmp-sequential/
    # Some stateless test leave files behind. Clean up the known ones.
    sudo rm -rf 03371_qbit_read_write_test_* __cache__/ disks/ queries_* ssh_key tests/queries/0_stateless/00408_test_* uuid_test_* || true
  • Restore the build environment after testing

    cd "$SOURCE_ROOT/ClickHouse"
    rm -rf ci/tmp/
    mv ci/tmp-build/ ci/tmp/

References:

⚠️ **GitHub.com Fallback** ⚠️