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 are connecting to the 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.

View connection address

  1. In the Dashboard, from the top menu, click Products 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 the 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> — 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> — administrator password. You set the password when creating the cluster. After creation, the password cannot be viewed in the Control Panel, but it can be changed.

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