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

  • An EMR ClickHouse cluster is created. For more information, see Create a ClickHouse cluster.
  • An SLB instance is created. For more information, see Create and manage a CLB instance.
    Important 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-facing 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 EMR console. In the left-side navigation pane, click EMR on ECS.
    2. In the top navigation bar, select the region where your cluster resides and select a resource group based on your business requirements.
    3. In the left-side navigation pane, choose Clusters > EMR on ECS. On the EMR on ECS page, find the cluster you want to manage and click Nodes in the Actions column.
      IP addresses
  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.
    Important
    • 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. Enter tcp_port in the search box. The displayed value of the tcp_port parameter 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. Enter http_port in the search box. The displayed value of the http_port parameter is the HTTP port used by the ClickHouse cluster.
  2. On the Instances page of the SLB console, 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.