You can access a ClickHouse cluster in E-MapReduce (EMR) by using Java Database Connectivity (JDBC) or Server Load Balancer (SLB). This topic describes how to access an EMR ClickHouse cluster by using the two methods.

Background information

  • Architecture of accessing a ClickHouse cluster by using JDBC JDBC
  • Architecture of accessing a ClickHouse cluster by using SLB SLB

Prerequisites

  • A ClickHouse cluster is created. For more information, see Create a cluster.
  • An SLB instance is created. For more information, see Create a CLB instance.
    Notice If you want to access a ClickHouse cluster by using SLB, you must create an SLB instance. If you set the Instance Type parameter to Intranet when you create the SLB instance, you must set the VPC parameter to the virtual private cloud (VPC) in which the ClickHouse cluster is deployed.

Access a ClickHouse cluster by using JDBC

  1. Obtain the IP addresses of the hosts in the ClickHouse cluster.
    1. Log on to the Alibaba Cloud EMR console.
    2. In the top navigation bar, select the region where your cluster resides and select a resource group based on your business requirements.
    3. Click the Cluster Management tab.
    4. On the Cluster Management page, find your cluster and click Details in the Actions column.
    5. In the left-side navigation pane of the Cluster Overview page, click Instances.
      On the Instances page, you can view the IP addresses of the hosts in the ClickHouse cluster. IP Address
  2. Configure a JDBC driver for the EMR ClickHouse cluster. For more information, see ClickHouse JDBC driver.

Access a ClickHouse cluster by using SLB

  1. Configure the SLB instance. For more information, see Configure a CLB instance.
    In most cases, you must configure an HTTP listener and a TCP listener for your SLB instance if you want to access a ClickHouse cluster by using SLB. You can also configure an HTTPS listener based on your business requirements. For more information about how to configure the listeners, see Add a TCP listener, Add an HTTP listener, and Add an HTTPS listener.
    Notice
    • The backend servers in the vServer group associated with the TCP listener must use the TCP port that the ClickHouse cluster uses to connect to the backend servers. By default, port 9000 is used by a ClickHouse cluster. To obtain the actual TCP port used by the ClickHouse cluster, go to the ClickHouse service page of the EMR console and click the Configure tab. In the Configuration Filter section, enter tcp_port in the Search field and click the search icon. The value of the tcp_port parameter displayed in the Service Configuration section is the TCP port used by the ClickHouse cluster.
    • The backend servers in the vServer group associated with the HTTP listener must use the HTTP port that the ClickHouse cluster uses to connect to the backend servers. By default, port 8123 is used by a ClickHouse cluster. To obtain the actual HTTP port used by the ClickHouse cluster, go to the ClickHouse service page of the EMR console and click the Configure tab. In the Configuration Filter section, enter http_port in the Search field and click the search icon. The value of the http_port parameter displayed in the Service Configuration section is the HTTP port used by the ClickHouse cluster.
  2. On the Instances page, obtain the IP address of the SLB instance.
  3. Configure a JDBC driver for the EMR ClickHouse cluster. For more information, see ClickHouse JDBC driver.