Running Hazelcast Using Hazelcast Command Line
In this blog post, we will go through what problems Hazelcast CLI aims to solve, as well as how to use the CLI itself.
Join the DZone community and get the full member experience.Join For Free
Until recently, you had to follow a manual approach to install and run Hazelcast instances on your environment. Now, there is an easier way to run Hazelcast using Hazelcast Command Line tool. 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 learner, 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.
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 favorite 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:
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:
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:
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:
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:
If you want to configure the instance with an external Hazelcast configuration file, use
-c option with the command as below:
-h option reveals further available options:
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:
If you would like to start a Hazelcast Management Center with custom context path and port, please run the following command:
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.
Published at DZone with permission of Alparslan Avcı. See the original article here.
Opinions expressed by DZone contributors are their own.