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

To connect to ClickHouse, use the following ports:

Connection addresses

The connection address depends on where you are connecting from. You can choose an address based on one of the following scenarios:

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.

You can view the connection address in the Control Panel.

Connecting to a cluster from the Internet

If you are connecting to a cluster from the Internet, use a public IP address. The private subnet must meet the requirements. If the subnet does not meet the requirements, prepare it for a public IP address connection.

You can view the connection address in the Control Panel.

View the connection address

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

Connect to a cluster

  1. Create a config.xml configuration file:

    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 ~/.clickhouse-client/ folder:

    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> — the database name. When connecting to the cluster for the first time, specify the default database — default. After the first connection, you can create new databases;
    • <port>connection port;
    • <password> — the administrator user password. The password is set when creating the cluster. After creation, the password cannot be viewed in the Control Panel, but it can be changed.