Skip to main content

Connect to a ClickHouse® cluster

You can connect to a ClickHouse® cluster:

SSL connection is used for all methods.

When connecting, specify the port and address.

Connection ports

Use the following ports to connect to ClickHouse®:

Connection addresses

You can select an address for connection depending on one of the scenarios:

You can view the connection address in the Dashboard.

Connecting to a cluster from a private subnet

If you are connecting to a cluster from a private subnet, use the private IP address.

To connect from another private subnet, first connect both private subnets to a cloud router.

Connecting to a cluster from the Internet

If you connect to the cluster from the internet, use a public IP address.

View connection address

  1. In the control panel, in the top menu, click Products and select Cloud Databases.
  2. Open the tab Active.
  3. Open the database cluster page → tab Connection.
  4. In the Connection addresses block, open the tab of the node group whose addresses you want to view.

Connect to the cluster

  1. Create a configuration file config.xml:

    if [ "$USER" = "root" ]; then
    CONFIG_DIR="/root/.clickhouse-client"
    else
    CONFIG_DIR="/home/${USER}/.clickhouse-client"
    fi

    mkdir -p ${CONFIG_DIR}

    cat > ${CONFIG_DIR}/config.xml << EOF
    <config>
    <openSSL>
    <client>
    <caConfig>${CONFIG_DIR}/root.crt</caConfig>
    <verificationMode>strict</verificationMode>
    <invalidCertificateHandler>
    <name>RejectCertificateHandler</name>
    </invalidCertificateHandler>
    </client>
    </openSSL>
    </config>
    EOF
  2. Download the root certificate and place it in the folder ~/.clickhouse-client/:

    wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.clickhouse-client/root.crt
    chmod 0600 ~/.clickhouse-client/root.crt
  3. Connect to the node:

    clickhouse-client --host <host> \
    --secure \
    --user admin \
    --database <database_name> \
    --port <port> \
    --password <password>

    Specify:

    • <host> — node IP address;
    • <database_name> — database name. When connecting to the cluster for the first time, specify the default database — default. After connecting for the first time, you can create new databases;
    • <port> — connection port;
    • <password> — administrator user password. The password is set when creating a cluster. After creation, the password cannot be viewed in the control panel, but can be changed.

ClickHouse® is a registered trademark of ClickHouse, Inc. https://clickhouse.com.