Main Content

Configure Advanced Options for MATLAB Job Scheduler Integration

Follow these instructions to configure advanced options during integration of MATLAB® Job Scheduler with your cluster.

Note

If this is the first time you integrate MATLAB Job Scheduler, see the following for the most common configuration options: Install for MATLAB Job Scheduler with Network License Manager.

In the following instructions, matlabroot refers to the location of your installed MATLAB Parallel Server™ software. Where you see this term used in the instructions that follow, substitute the path to your location.

Run Multiple MATLAB Parallel Server Versions

You can upgrade your MATLAB Job Scheduler clusters and continue to use the R2016a release onwards of Parallel Computing Toolbox on your MATLAB desktop client to connect to it. To take advantage of this backward compatibility feature:

  1. Install the latest version of MATLAB Parallel Server on your cluster. You must use this version to run MATLAB Job Scheduler on your cluster.

  2. Install MATLAB Parallel Server for each release that you want to support in the cluster. For example, to use R2016a and R2016b with your cluster, install both the R2016a and R2016b releases of MATLAB Parallel Server.

  3. Configure MATLAB Job Scheduler with the location of these installations. In the mjs_def configuration file, specify the location of each installation of MATLAB Parallel Server in the MJS_ADDITIONAL_MATLABROOTS variable. You can find this file in matlabroot/toolbox/parallel/bin for Linux (mjs_def.sh) and Windows (mjs_def.bat). For more information, see mjs.

With this configuration, the MATLAB Job Scheduler allows MATLAB clients from the installed releases to submit jobs to the cluster. The MATLAB Job Scheduler dynamically starts the right version of the MATLAB worker to run the job.

Set Up Windows Cluster Hosts

If this is the first installation of MATLAB Parallel Server on a cluster of Windows machines, you need to configure these hosts for job communications.

Note

If you do not have a Windows cluster, or if you have already installed a previous version of MATLAB Parallel Server on your Windows cluster, you can skip this step.

Configure Windows Firewalls on the Cluster Nodes

If you are using Windows® firewalls on your cluster nodes,

  1. Log in as a user with administrator privileges.

  2. Execute the following in a Windows command prompt.

    matlabroot\toolbox\parallel\bin\addMatlabToWindowsFirewall.bat
    

    This command adds MATLAB as an allowed program. If you are using other firewalls, you must configure them for similar accommodation.

Configure Windows User Access for mjs

The user that mjs runs as requires access to the cluster MATLAB installation location. By default, mjs runs as the user LocalSystem. If your network allows LocalSystem to access the install location, you can skip this step. (If you are not sure of your network configuration and the access provided for LocalSystem, contact the MathWorks install support team.)

Note

If LocalSystem cannot access the install location, you must run mjs as a different user.

You can set a different user with these steps:

  1. With any standard text editor (such as WordPad) open the mjs_def file found at:

    matlabroot\toolbox\parallel\bin\mjs_def.bat
  2. Find the line for setting the MJSUSER parameter, and provide a value in the form domain\username:

    set MJSUSER=mydomain\myusername
  3. Provide the user password by setting the MJSPASS parameter:

    set MJSPASS=password
  4. Save the file.

Open Required Ports on Server

The mjs service uses as many ports as required, starting with BASE_PORT. By default, BASE_PORT is 27350.

If you use a host that runs a total of nJ job managers and nW workers, the mjs service reserves a total of 7+2*nJ+4*nW consecutive ports for its own use. All job managers and workers, even those on different hosts, that are going to work together must use the same base port. Otherwise the job managers and workers will not be able to contact each other. In addition, MPI communication occurs on ports starting at BASE_PORT+1000 and use 2*nW consecutive ports.

For example, if you use a host with 1 job manager and 16 workers, then you need the following ranges of ports to be open:

  • 27350 – 27422 for the mjs service.

  • 28350 – 28382 for MPI communication.

To connect from MATLAB to a cluster with a non-default BASE_PORT, you must append the value of BASE_PORT to the 'Host' property in the MATLAB Job Scheduler cluster profile. You must do this in the form Hostname:BASE_PORT, for example myMJSHost:44001.

Stop mjs Services of Old Installation

If you have an older version of MATLAB Parallel Server running on your cluster nodes, you should stop the mjs services before starting the services of the new installation.

Stop mjs on Windows

  1. Open a Windows command window with administrator privileges.

  2. In the command window, navigate to the folder of the old installation that contains the control scripts.

    cd oldmatlabroot\toolbox\parallel\bin
    
  3. Stop and uninstall the old service and remove its associated files by typing the following command.

    mjs uninstall -clean
    

    In releases before R2019a, the service is called mdce. Type the following commands instead.

    cd oldmatlabroot\toolbox\distcomp\bin
    mdce uninstall -clean
    

    Note

    Using the -clean flag permanently removes all existing job data. Be sure this data is no longer needed before removing it.

  4. Repeat the instructions of this step on all worker nodes.

Stop mjs on UNIX

  1. Log in as root. If you cannot log in as root, you must alter the following parameters in the oldmatlabroot/toolbox/parallel/bin/mjs_def.sh file to point to a folder for which you have write privileges: CHECKPOINTBASE, LOGBASE, PIDBASE, and LOCKBASE if applicable. In releases before R2019a, this file is oldmatlabroot/toolbox/distcomp/bin/mdce_def.sh instead.

  2. On each cluster node, stop the mjs service and remove its associated files by typing the commands:

    cd oldmatlabroot/toolbox/parallel/bin
    ./mjs stop -clean

    In releases before R2019a, the service is called mdce. Type the following command instead.

    cd oldmatlabroot/toolbox/distcomp/bin
    ./mdce stop -clean

    Note

    Using the -clean flag permanently removes all existing job data. Be sure this data is no longer needed before removing it.

Set the MATLAB Job Scheduler Security Level

Before starting the mjs service on your cluster nodes, set a security level. For instructions, see Set Security Level. For additional security considerations, see Set MATLAB Job Scheduler Cluster Security.

Start mjs Service, MATLAB Job Scheduler, and Workers (Command-Line)

You can start MATLAB Job Scheduler using a graphical interface or the command line. For instructions on how to use the graphical interface, see Configure the MATLAB Job Scheduler. To use the graphical interface, Admin Center, you must run it on a computer that has direct network connectivity to all the nodes of your cluster. If you cannot run Admin Center on such a computer, you must use the command-line interface. For instructions on how to use the command-line interface, follow the next steps.

Use the Command-Line Interface (Windows)

  1. Start the mjs Service

    You must install the mjs service on all nodes (head node and worker nodes). Begin on the head node.

    1. Open a Windows command window with administrator privileges.

    2. In the Windows command window, navigate to the folder with the control scripts:

      cd matlabroot\toolbox\parallel\bin
      
    3. Install the mjs service by typing the command:

      mjs install
      
    4. Start the mjs service by typing the command:

      mjs start
      
    5. Repeat the instructions of this step on all worker nodes.

    As an alternative to items 3–5, you can install and start the mjs service on nodes remotely from one machine by typing:

    cd matlabroot\toolbox\parallel\bin
    ssh hostA mjs install
    ssh hostA mjs start

    where hostA refers to a remote host. For more information on your ssh utility, see the usage reminder by typing:

    ssh

    Once installed, the mjs service starts running each time the machine reboots. The mjs service continues to run until explicitly stopped or uninstalled, regardless of whether a MATLAB Job Scheduler or worker session is running.

  2. Start the MATLAB Job Scheduler

    To start the MATLAB Job Scheduler, enter the following commands in a Windows command prompt. You do not have to be at the machine on which the MATLAB Job Scheduler runs, as long as you have access to the MATLAB Parallel Server installation.

    1. In your Windows command prompt, navigate to the folder with the startup scripts:

      cd matlabroot\toolbox\parallel\bin
      
    2. Start the MATLAB Job Scheduler, using any unique text you want for the name <MyMJS>:

      startjobmanager -name <MyMJS> -remotehost <MATLAB Job Scheduler host name> -v
    3. Verify that the MATLAB Job Scheduler is running on the intended host.

      nodestatus -remotehost <MATLAB Job Scheduler host name>
      

      Note

      If you are executing startjobmanager on the host where the MATLAB Job Scheduler runs, you do not need to specify the -remotehost flag.

      If you have more than one MATLAB Job Scheduler on your cluster, each must have a unique name.

  3. Start the Workers

    Note

    Before you can start a worker on a machine, the mjs service must already be running on that machine. If you are using the network license manager, it must be running on the network.

    For each node used as a worker, enter the following commands in a Windows command prompt. You do not have to be at the machines where the MATLAB workers will run, as long as you have access to the MATLAB Parallel Server installation.

    1. Navigate to the folder with the startup scripts:

      cd matlabroot\toolbox\parallel\bin
      
    2. Start the workers on each node, using the text for <MyMJS> that identifies the name of the MATLAB Job Scheduler you want this worker registered with. Enter this text on a single line:

      startworker -jobmanagerhost <MATLAB Job Scheduler host name>
          -jobmanager <MyMJS> -remotehost <worker host name> -v
      

      To run more than one worker session on the same node, give each worker a unique name by including the -name option on the startworker command, and run it for each worker on that node:

      startworker ... -name <worker1 name>
      startworker ... -name <worker2 name>
      
    3. Verify that the workers are running.

      nodestatus -remotehost <worker host name>
      
    4. Repeat items 2–3 for all worker nodes.

    MATLAB Parallel Server supports MATLAB Job Scheduler clusters with up to 10,000 workers. (since R2023b)

    For more information about mjs, MATLAB Job Scheduler, and worker processes, such as how to shut them down or customize them, see MATLAB Job Scheduler Configuration and Management.

Use the Command-Line Interface (UNIX)

  1. Start the mjs Service

    On each cluster node, start the mjs service by typing the commands:

    cd matlabroot/toolbox/parallel/bin
    ./mjs start

    Alternatively, you can start the mjs service on nodes remotely from one machine by typing

    cd matlabroot/toolbox/parallel/bin
    ssh hostA matlabroot/toolbox/parallel/bin/mjs start
    ssh hostB matlabroot/toolbox/parallel/bin/mjs start
    ssh hostC matlabroot/toolbox/parallel/bin/mjs start
    

    where hostA, hostB, and hostC refers to your remote host names. For a long list of host names, you can start the mjs service on several nodes remotely from one machine by typing:

    for host in hostA hostB hostC;
     do ssh $host matlabroot/toolbox/parallel/bin/mjs start;
    done 

    For more information on your ssh utility, see the usage reminder by typing:

    ssh

    Alternatively, you can access the system reference manual by typing:

    man ssh

  2. Start the MATLAB Job Scheduler

    To start the MATLAB Job Scheduler, enter the following commands. You do not have to be at the machine on which the MATLAB Job Scheduler runs, as long as you have access to the MATLAB Parallel Server installation.

    1. Navigate to the folder with the startup scripts:

      cd matlabroot/toolbox/parallel/bin
      
    2. Start the MATLAB Job Scheduler, using any unique text you want for the name <MyMJS>. Enter this text on a single line.

      ./startjobmanager -name <MyMJS> -remotehost <MATLAB Job Scheduler host name> -v
      
    3. Verify that the MATLAB Job Scheduler is running on the intended host:

      ./nodestatus -remotehost <MATLAB Job Scheduler host name>
      

      Note

      If you have more than one MATLAB Job Scheduler on your cluster, each must have a unique name.

  3. Start the Workers

    Note

    Before you can start a worker on a machine, the mjs service must already be running on that machine. If you are using the network license manager, it must be running on the network.

    For each computer hosting a MATLAB worker, enter the following commands. You do not have to be at the machines where the MATLAB workers run, as long as you have access to the MATLAB Parallel Server installation.

    1. Navigate to the folder with the startup scripts:

      cd matlabroot/toolbox/parallel/bin
      
    2. Start the workers on each node, using the text for <MyMJS> that identifies the name of the MATLAB Job Scheduler you want this worker registered with. Enter this text on a single line:

      ./startworker -jobmanagerhost <MATLAB Job Scheduler host name>
         -jobmanager <MyMJS> -remotehost <worker host name> -v
      

      To run more than one worker session on the same machine, give each worker a unique name with the -name option:

      ./startworker ... -name <worker1>
      ./startworker ... -name <worker2>
      
    3. Verify that the workers are running. Repeat this command for each worker node:

      ./nodestatus -remotehost <worker host name>
      

    MATLAB Parallel Server supports MATLAB Job Scheduler clusters with up to 10,000 workers. (since R2023b)

    For more information about mjs, MATLAB Job Scheduler, and worker processes, such as how to shut them down or customize them, see MATLAB Job Scheduler Configuration and Management.

Configure mjs Service to Start Automatically at Boot Time (UNIX)

You can use the systemd system and service manager to start the mjs service at boot time. Although this step is not required, it is helpful in case of a system crash. When configured, the mjs service starts running each time the machine reboots and continues to run until explicitly stopped, regardless of whether a MATLAB Job Scheduler or worker session is running.

You must have root privileges to perform these steps.

Debian, Fedora, SUSE, and Red Hat (non-Fedora) Platforms

On each cluster node, create and configure a unit file to automatically start the mjs service at system boot time by following these steps:

  1. Create and edit a systemd unit file in the /etc/systemd/system folder called mjs.service:

    nano /etc/systemd/system/mjs.service
  2. Add these configuration options to the mjs.service file:

    [Unit]
    Description=MATLAB Job Scheduler
    
    [Service]
    Type=forking
    ExecStart=matlabroot/toolbox/parallel/bin/mjs start 
    
    [Install]
    WantedBy=multi-user.target
    

    You can also specify if systemd can stop or restart the mjs service. For more information, see the systemd documentation for your UNIX® platform.

    Save the unit file.

  3. For Red Hat (non-Fedora) platforms, set the unit file permissions:

    chmod 664 /etc/systemd/system/mjs.service
  4. Reload the systemd service files to update your changes:

    systemctl daemon-reload

  5. Enable the mjs systemd service to start automatically at boot time:

    systemctl enable mjs.service

    You can also start the mjs service to verify whether you have successfully configured the mjs systemd service:

    systemctl start mjs.service

    To check the status of the mjs systemd service, enter this command:

    sudo systemctl status mjs.service

Validate Installation with MATLAB Job Scheduler

To verify that your MATLAB Parallel Server products are installed and configured correctly, create a cluster profile and validate it. For instructions, see Connect MATLAB Client to MATLAB Parallel Server Cluster. You can specify the number of workers to use when validating your profile, to avoid occupying the whole cluster. If your validation does not pass, contact the MathWorks Install Support Team, or see Troubleshoot Common Problems.

After you create a cluster profile, you can make any modifications appropriate for your applications, such as NumWorkersRange, AttachedFiles, or AdditionalPaths. To save your profile for other users, in the Cluster Profile Manager, select the profile and click Export, then save your profile to a file in a convenient location. Later, when running the Cluster Profile Manager, other users can import your profile by clicking Import. For more information about cluster profiles, see Discover Clusters and Use Cluster Profiles (Parallel Computing Toolbox).

Related Examples

More About