Setting Up A MASS-Java Cluster

Overview

Once your application is packaged into a standalone JAR, it is ready for execution on a cluster of machines. In general, MASS requires that all machines participating in the cluster to have the following configuration:

It is also recommended to place the application JAR on a shared network location, mounted on all nodes, to ensure that each node is executing the same version of your application. If you cannot use a shared folder, place your files in the same location on every node.

If your application accesses large data files, you should experiment with placing those files either on a shared network filesystem or locally to balance convenience and performance. Locating data files on a shared filesystem may be more convenient but can also impact overall performance. A file server could be overwhelmed by a large number of nodes/threads accessing files simultaneously and might be a performance bottleneck.

Configuring the master node

Simple Configuration

A single configuration file is used to specify which nodes will participate in the cluster. If you have a homogeneous collection of machines, with identical resources and filesystem mountings, you may use a simple text file (typically named “machinefile.txt”) that contains only the hostnames or IP addresses of follower nodes, one per line. An example “machinefile.txt” might look like the following:

#!text
eniac.seas.upenn.edu
univac.unisys.com
binac.northropgrumman.com
wopr.af.mil

Of course, you will not be able to specify per-node customization parameters such as location of Java JRE, working directory, and such.

Advanced Configuration

If your cluster contains a mixture of operating systems (Linux, Windows, OSX), or different locations for the Java runtime environment or application and data files, then you may use the XML-based configuration file. The XML schema includes elements to configure most aspects of MASS on a per-node basis.

There are examples of both types of configuration files located in the “src/main/resources” folder of this project. The XML-based configuration file contains comments to explain which elements are required and what each represents.

Setting up SSH Keys for Password-less Logins

Overview

The MASS library will automatically establish sessions with remote nodes and launch your application. MASS accomplishes these tasks by using SSH to login to the remote node; the login process requires authentication, which is performed using SSH public and private keys.

Creating Public and Private Keys

The first step is to generate the keys that will be used for authentication. The simple way to accomplish this is to login to the node that you have selected as the master node, and enter the following command:

#!text
ssh-keygen

You will be prompted for the default file location, hit enter to accept the default. When prompted for a passphrase, hit enter for a blank passphrase.

A private key will be created in your home directory, under the “.ssh” folder, with a name of “id_rsa”. Do not share this file with anyone or copy it outside of your home directory! The public key is stored in a file named “id_rsa.pub”; this file (or its contents) can be shared.

Copying Your Public Key to Worker Nodes

After your public and private keys have been created, you must copy this key to remote nodes and accept remote host authenticity. To do this, enter the following command from within your home directory on the master node:

#!text
ssh-copy-id <your user id>@<worker hostname>

For example, if your username was “dlister” and you were copying your key to “starbug.red-dwarf.com”, the command would be as follows:

#!text
ssh-copy-id dlister@starbug.red-dwarf.com

You may be prompted to verify the authenticity of the host (answer “yes” if valid). You will be prompted to enter your password, and after successful entry of the password your public key will be copied to the worker node.

It is important to test the SSH connection and login process:

#!text
ssh <your user id>@<worker hostname>

You should NOT be prompted to establish the authenticity of the host or enter your password. If you are taken to a command prompt on the remote node the SSH key copy process and host verification are complete and this worker node may now be used with your MASS application. ## Notes ## * The remote nodes must be set up properly to accept public-key authentication. Make sure the following line is uncommented in “/etc/ssh/sshd_config” (CentOS 8 example):

#!java

PubkeyAuthentication yes