Connect to Apache ZooKeeper Using Command Line

zkCli.sh is a utility to connect to a local or remote ZooKeeper service and execute some commands. This article describes how zkCli.sh can be used to connect to clusters in Instaclustr. In this article, we assume that your cluster has been set up and provisioned properly as shown in our previous tutorial “Creating a Cluster”.

 

Table of Contents

Prerequisites

You also need ZooKeeper binaries which can be downloaded from https://zookeeper.apache.org/releases.html. We recommend a matching ZooKeeper binaries version with your ZooKeeper cluster. You don’t have to install after downloading and extracting.

The public IP address of your machine must be added to the ZooKeeper Allowed Addresses under Firewall Rules in the navigation menu of your cluster in the Instaclustr console. (Refer this support article).

Username, password and certificate file can be found on the Connection Info page of your cluster. Certificate files are required to connect to your cluster with SSL.

Screenshot of Zookeeper Certificate Location

User Authentication

Apache ZooKeeper does not enforce authentication. Users can always connect to ZooKeeper servers as a “world” user.  However, access to the data (znodes) can be limited by ACL that are associated with an authenticated user. We provide a default user that you can opt to use when connecting to the ZooKeeper servers. If you decide to do so, create a file containing the credential (e.g., jaas.conf) with the following content:

and set the environment variable before connecting as described in the following sections.

Connecting to Instaclustr without SSL

If encryption is not enabled in your cluster, you can connect to it using zkCli.sh without SSL.

For Mac/Linux, open your terminal and use the following command to connect to your cluster.

If you opt to provide credential, set the following environment variable.

Connecting to Instaclustr with SSL

If encryption is enabled in your cluster, SSL is needed for connecting to the cluster and you need to get the truststore.jks from the cluster certificate.

For Mac/Linux, open your terminal and using the following command, set the environment variable.

Connect to the cluster.

If you opt to provide credential, add the following flag to the the environment variable before connecting

By Instaclustr Support
Need Support?
Experiencing difficulties on the website or console?
Already have an account?
Need help with your cluster?
Contact Support
Why sign up?
To experience the ease of creating and managing clusters via the Instaclustr Console
Spin up a cluster in minutes