skip to Main Content

There is a running ClickHouse container

clickhouse-server:
    image: yandex/clickhouse-server
    container_name: clickhouse-server
    ports:
        - '8123:8123'
        - '9000:9000'
    volumes:
        - ./db:/var/lib/clickhouse
    ulimits:
        nofile: 262144

There are configured connection parameters in .env

CLICKHOUSE_HOST=clickhouse-server
CLICKHOUSE_PORT=8123
CLICKHOUSE_DATABASE=memorial_analitucs
CLICKHOUSE_USERNAME=default
CLICKHOUSE_PASSWORD=
CLICKHOUSE_TIMEOUT_CONNECT=5
CLICKHOUSE_TIMEOUT_QUERY=5

When performing the migration, it returns the following error

2024_04_18_182025_create_analytics_table ............................................................................................ 3,710ms FAIL

  ClickHouseDBExceptionQueryException 

  Could not resolve host: clickhouse-server

When clicking on the link http://localhost:8123 outputs "OK". Can you tell me what the problem might be?

2

Answers


  1. Chosen as BEST ANSWER

    Adding a network parameter worked in container.


  2. config/database.php open add

    'clickhouse' => [
                'driver' => 'clickhouse',
                'host' => env('CLICKHOUSE_HOST'),
                'port' => env('CLICKHOUSE_PORT','8123'),
                'database' => env('CLICKHOUSE_DATABASE','default'),
                'username' => env('CLICKHOUSE_USERNAME','default'),
                'password' => env('CLICKHOUSE_PASSWORD',''),
                'timeout_connect' => env('CLICKHOUSE_TIMEOUT_CONNECT',2),
                'timeout_query' => env('CLICKHOUSE_TIMEOUT_QUERY',2),
                'https' => (bool)env('CLICKHOUSE_HTTPS', null),
                'retries' => env('CLICKHOUSE_RETRIES', 0),
                'settings' => [ // optional
                    'max_partitions_per_insert_block' => 300,
                ],
            ], 

    under "connections" array put it and try again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search