Updated on 2024-07-23 GMT+08:00

Using a Client to Access a ClickHouse Cluster

You can use SQL to access a cluster on an ECS. For details about how to install the client, see Installing the Client.

The VPC and security group of the cluster to be created must be the same as those of the ECS on the public network. Otherwise, the client cannot access the cluster.

Installing the Client

  1. Prepare a Linux ECS. For details, see Preparing an ECS.
  2. Log in to the CloudTable management console, click Help in the navigation pane on the left, and click Download Client on the right of the page to download the client installation package.

    Figure 1 Downloading the ClickHouse client

  3. Install the client and connect to the cluster.

    1. Use the SSH login tool to remotely log in to the Linux ECS through the EIP.

      For details, see Login Using an SSH Password in the Elastic Cloud Server User Guide.

    2. Go to the root directory of the SSH login tool.
      cd /
    3. Create a folder in the root directory.
      mkdir Folder name
    4. Go to the directory of the created folder.
      cd /Folder name/
    5. Place the client in the directory.
    6. Decompress the client package.
      tar  -zxf   Client package name
    7. Load the .so file.
      sh install.sh
    8. Go to the bin directory.
      cd bin/

      Grant the 700 permission to the directory.

      chmod 700 clickhouse
    9. Connect to the ClickHouse cluster. For details about the port, see Table 1.
      Use the following command to connect to a normal cluster.
      ./clickhouse client --host Private IP address of the cluster   --port Port --user admin --password Password

      For details about the security cluster connection command. For details, see Connecting to a Security Cluster.

      ./clickhouse client --host Private IP address of the cluster --port port --user admin --password Password --secure --config-file /root/config.xml
      • Private IP address of the cluster: cluster access address on the cluster details page. Replace it with the access address of the cluster you purchased.
      • Password: the password set when you purchase the cluster. If there are special characters, use backslashes (\) to escape them. If the password is enclosed in single quotation marks ('), the special characters do not need to be escaped.
      Table 1 Custom security rules

      Direction

      Action

      Port/Range

      Type

      Destination/Source Address

      Usage

      Outbound

      Allow

      All

      IPv4/IPv6

      0.0.0.0/0

      Permit in the outbound direction

      Inbound

      Allow

      8123

      Security group of the CloudTable ClickHouse cluster

      ClickHouse HTTP port number

      Allow

      9000

      ClickHouse TCP port number

      Allow

      8443

      ClickHouse HTTPS port number

      Allow

      9440

      Secure TCP security port of ClickHouse