Skip to main content
Version: 6.0-SNAPSHOT

Start a Local Cluster with the CLI

Follow this five-minute tutorial to set up a Hazelcast cluster for testing or evaluation purposes. In five minutes, you will learn how to install Hazelcast with a package manager, start a local cluster with the CLI, write data to memory and visualize that data.

Step 1. Install Hazelcast​

  1. To install Hazelcast, use the appropriate command for your operating system:

    To install on macOS, use the Homebrew package manager.

    bash
    brew tap hazelcast/hz
    brew trust hazelcast/hz
    brew install [email protected]
  2. Check that Hazelcast Platform is correctly installed:

    shell
    hz -V

    You should see the version of both Hazelcast and the command line tool.

Step 2. Start a Local Cluster​

Hazelcast clusters consist of servers that we call members. These members communicate with each other to form a distributed network. It's these members that store and process your data.

  1. To start a standalone Hazelcast member, use the following command:

    shell
    hz start

    You should see the following in the console:

    shell
    INFO: [192.168.1.164]:5701 [dev] [6.0.0-SNAPSHOT] (1)

    Members {size:1, ver:1} [ (2)
    Member [192.168.1.164]:5701 - 4221d540-e34e-4ff2-8ad3-41e060b895ce this
    ]
    1 The local IP address of your Hazelcast member followed by the default cluster name (dev) and the version of Hazelcast that you are running.
    2 The size of your cluster. Here, you just have one member, so the size is 1.
  2. To add one more member to the cluster, open another terminal window and run the start command again.

    shell
    hz start

    The members discover each other automatically and form a two-member cluster. You should see the following in the console:

    shell
    Members {size:2, ver:2} [
    Member [127.0.0.1]:5701 - e40081de-056a-4ae5-8ffe-632caf8a6cf1 this
    Member [127.0.0.1]:5702 - 93e82109-16bf-4b16-9c87-f4a6d0873080
    ]
note

These members use the default configuration, which is defined in the hazelcast.xml file. The location of this file is printed on the first line of the output of the start command.

Step 3. Connect the Management Center​

Management Center is a user interface for managing and monitoring your cluster.

In this step, you install and start a local instance of Management Center and connect it to your cluster.

  1. To install Management Center, use one of the following methods, depending on your operating system:

    To install on macOS, use the Homebrew package manager.

    bash
    brew tap hazelcast/hz
    brew trust hazelcast/hz
    brew install hazelcast/hz/[email protected]
  2. Check that Management Center is installed.

    shell
    hz-mc -V

    You should see the version of Management Center.

  3. Start Management Center.

    shell
    hz-mc start
  4. In a web browser, go to localhost:8080 to open Management Center.

  5. On the landing page of Management Center, enable dev mode.

    Enabling dev mode in Management center

  6. Create a connection, using the default settings.

    You should see that you cluster is in an active state and has a single member. An active cluster is stable and operating without restrictions.

    An active cluster in Management Center

Step 4. Write Data to Memory​

Hazelcast has lots of distributed data structures available for writing data to memory on your cluster. One of the most popular ways of writing data to memory is to use a distributed map. Maps store key/value pairs called entries, which are replicated and distributed across a cluster.

The quickest way to write some data to a map is to use the CLI console.

  1. To start the console, use the following command:

    shell
    hz-cli console
  2. Enter the following to create a map and write some data to it:

    • ns my-distributed-map

    • m.put "1" "John"

    • m.put "2" "Mary"

    • m.put "3" "Jane"

      You'll see that each of the m.put lines returns null, which means that the data was written to the map.

  3. In Management Center, go to Storage > Maps.

    You should see that your cluster has a map called my-distributed-map with three entries (keys and values). You'll also see the total amount of memory that those entries are taking up in your cluster.

Next Steps​

In this quickstart, you have learnt how to start a local cluster, write data to it and visualize that data in Management Center. To continue your journey through Hazelcast, check the following resources:

If you need some help, reach out via support.