DEV Community

Alparslan Avcı for Hazelcast

Posted on • Originally published at hazelcast.com

Hazelcast Command Line is released!

Alt Text

We are pleased to announce that Hazelcast Command Line 4.2020.12 is now available. It supports Hazelcast IMDG 4.1.1 and Hazelcast Management Center 4.2020.12. It took longer than anticipated to get a proper CLI for Hazelcast, however, we hope you will find it was worth the wait.

In this blog post, we will go through what problems we aim to solve with Hazelcast CLI, as well as how to use it. If you're more of a hands-on learned, feel free to skip directly to the end for tips on using it.

Installing and starting an Hazelcast instance, the long way

As you most likely know, you can use Hazelcast in two main topologies: Embedded and Client-Server. You add Hazelcast as a dependency to your Java application if you choose the former architecture.

But, if you would like to design your architecture using a client-server approach, you need to start Hazelcast member instances. Before the Hazelcast CLI, you had to perform multiple steps to run a Hazelcast member standalone.

Install Java

Since Hazelcast member is a Java application, it requires a JRE to be installed in the environment. If you are not familiar with Java, it might be difficult to find the proper version and install it.

Download Hazelcast distribution

Hazelcast is available for download at https://hazelcast.com/get-started/. You had to visit this page and download the Hazelcast version distribution that you would like to install.

Run the instance using start.sh script

After downloading the distribution, you had to extract it to a proper location and then run the “start.sh” script that resides in the “bin/” directory.

After all these steps complete successfully, you (finally) have a running Hazelcast member instance.

However, this method is a manual process. There is support for neither package managers nor version control. Moreover, installing Hazelcast Management Center requires the same steps again.

The easy way: using Hazelcast Command Line

To make the Hazelcast installation easier, we developed Hazelcast Command Line. Please note that it is only targeted at developers and not recommended for usage in production environments for the time being. Now, you only need to use your favourite package manager to install Hazelcast, and then run the hz start command to start a Hazelcast member instance!

Even better, we have deployed the CLI in the most common repository managers.

Install with Homebrew

To install with Homebrew, you first need to tap the hazelcast/hz repository. Once you’ve tapped the repo, you can use brew install to install:

$ brew tap hazelcast/hz
$ brew install hazelcast

Install with yum/dnf

The RPM packages for Hazelcast Command Line are kept in Hazelcast's RPM repository. Just run the following commands to install it using yum/dnf:

$ wget https://repository.hazelcast.com/rpm/hazelcast-rpm.repo -O hazelcast-rpm.repo
$ sudo mv hazelcast-rpm.repo /etc/yum.repos.d/
$ sudo yum install hazelcast

Install with apt

You can find the Debian packages for Hazelcast Command Line in Hazelcast's Debian repository. Run the following commands to install it using apt:

$ wget -qO - https://repository.hazelcast.com/api/gpg/key/public | sudo apt-key add -
$ echo "deb https://repository.hazelcast.com/debian stable main" | sudo tee -a /etc/apt/sources.list
$ sudo apt update && sudo apt install hazelcast

All these package managers will handle the Java dependencies for you. Also, you can pick the previous versions by using the proper commands for each package manager.

After the installation, run the following command to see everything is completed successfully:

$ hz
Hazelcast IMDG 4.1.1
Usage: hz [-hV] [COMMAND]
Utility for the Hazelcast operations.

Global options are:

  -h, --help Show this help message and exit.
  -V, --version Print version information and exit.
Commands:
  start Starts a new Hazelcast IMDG member
  mc Utility for Hazelcast Management Center operations.

A quick intro to Hazelcast CLI

The main command of Hazelcast Command Line is hz. To start a Hazelcast instance, just run hz start and a new instance will run with the default configuration:

$ hz start
Aug 21, 2020 1:40:04 PM com.hazelcast.config.FileSystemYamlConfig
INFO: Configuring Hazelcast from '/Users/myuser/hazelcast-command-line/distro/build/dist/config/hazelcast.yaml'.
...

If you want to configure the instance with an external Hazelcast configuration file, use -c option with the command as below:

$ hz start -c /full/path/to/config-file.yaml

The -h option reveals further available options:

$ hz start -h
Usage: hz start [-hvV] [-vv] [-c=<file>] [-i=<interface>] [-p=<port>] [-j=<path>
                [,<path>...]]... [-J=<option>[,<option>...]]...
Starts a new Hazelcast IMDG member
  -h, --help Show this help message and exit.
  -V, --version Print version information and exit.
  -c, --config=<file> Use <file> for Hazelcast configuration. Accepted
      formats are XML and YAML.
  -p, --port=<port> Bind to the specified <port>. Please note that if the
      specified port is in use, it will auto-increment to
      the first free port. (default: 5701)
  -i, --interface=<interface>
      Bind to the specified <interface>.
  -j, --jar=<path>[,<path>...]
      Add <path> to Hazelcast classpath (Use ',' to separate
      multiple paths). You can add jars, classes, or the
      directories that contain classes/jars.
  -J, --JAVA_OPTS=<option>[,<option>...]
      Specify additional Java <option> (Use ',' to separate
      multiple options).
  -v, --verbose Output with FINE level verbose logging.
  -vv, --vverbose Output with FINEST level verbose logging.

As we mentioned above, you can also start a Hazelcast Management Center using Hazelcast Command Line. Please run the following command to start a Hazelcast Management Center instance:

$ hz mc start

If you would like to start a Hazelcast Management Center with custom context path and port, please run the following command:

$ hz mc start -c [new-context-path] -p [port]

Future

Currently, Hazelcast CLI is only targeted at developers and not recommended for usage in production environments. Also, there is no support for Windows environments. We are working on them and will include more features in future releases.

Your feedback as a user is very valuable to us. We would appreciate your thoughts and feedback with us by creating an issue on Hazelcast Command Line Github repository.

Top comments (0)