Cluster mode means that we set up several application servers and one control unit that distributes the load (load balancer). Cluster mode is used for large number of computers.

Required components:

Component

Prerequisites

ID used in the instruction

Load balancer

Windows or Linux system with Docker installed

IP_LOAD_BALANCER

A number of Application Servers (clusters).

Windows computers with java
One of the clusters is "main-server",
the others are "ordinary-server".

Main Application Server - IP_APP_SERVER_MAIN, APP_SERVER_NAME
Ordinary Application Server - IP_APP_SERVER_ORDINARY

MySQL server

Windows or Linux computer. It should be configured according to JCM requirements described in JCM documentaion:

  • database 'jcm_global_database'
  • user 'root' with password 'root' and with full rights

IP_MY_SQL

Redis cache server

Windows or Linux computer with Redis installed

IP_REDIS

HornetQ

Windows or Linux computer with Docker installed

IP_HORNETQ

Administrator may set up these items in various combinations. Because java takes a lot of system resources, it is not recommended to set up MySQL and Redis on Application Servers.

Steps to configure JCM Server to work in cluster mode:

  1. Load Balancer.
    • create a file with the name 'Dockerfile' with the content:

      FROM haproxy:1.7
      COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
    • in the same folder, create a file with the name 'haproxy.cfg' with the content:

      frontend localnodes
      bind *:8443
      mode tcp
      default_backend nodes
      timeout client 300s
      backend nodes
      mode tcp
      balance roundrobin
      server web01 IP_APP_SERVER_MAIN:8443
      server web02 IP_APP_SERVER_ORDINARY:8443
      timeout connect 300s
      timeout server 300s
    • open Command Prompt and go to the folder where these files were created
      • create docker container:
        $ docker build -t my-haproxy .
      • run docker container:
        $ docker run -d -p 8443:8443 --name my-running-haproxy my-haproxy


If the server was restarted, you need to start the existing container:
$ docker start my-running-haproxy

If you need to clean the container and start from scratch:

$ docker stop my-running-haproxy
$ docker rm my-running-haproxy
$ docker images --> see the image for "my-haproxy".
$ docker rmi "my-haproxy image"

  1. HornetQ.
    • download hornet.zip and extract the archive to a folder
    • open command prompt and go to the folder
    • run two commands included in the file 'docker.txt'
  2. Redis server.
    • Open Redis configuration file redis.windows-service.conf
    • Find the string "bind" and set the IP:
      bind IP_REDIS
    • Restart Redis service.
  3. Main Application Server.
    • Install JCM Server, during installation enter the following values:
      • Step 1: Key generation: IP_LOAD_BALANCER
      • Step 2: MySQL: IP_MYSQL
      • Step 3: Redis: IP_REDIS

DO NOT START JCM SERVER AT THIS STEP.

    • edit application.properties file in JCM home folder:

      jcm.cluster.mode=main-server

      Uncomment and edit these lines:
      spring.hornetq.mode=native
      spring.hornetq.host=IP_HORNETQ
      spring.hornetq.port=5445

      Comment these lines:
      #spring.hornetq.mode=embedded
      #spring.hornetq.embedded.enabled=true
    • Share 'JCM Server' folder in network:
      • set permissions for the share: full access for everyone
      • in 'Security' tab for the folder, set full access for 'Users' group
      • it is recommended to create a special user for accessing the share, because password of the user will be written in configuration file in opened form
  1. Ordinary Application Server
    • Install JCM Server, during installation enter the following values:
      • Step 1: Key generation: IP_LOAD_BALANCER
      • Step 2: MySQL: IP_MYSQL
      • Step 3: Redis: IP_REDIS

DO NOT START JCM SERVER AT THIS STEP.

    • access 'JCM Server' share and copy three files from the shared folder to the local 'JCM Server' folder:
      • application.properties
      • cacert.jks
      • key.jks
    • edit application.properties file in JCM home folder:

      jcm.cluster.mode=ordinary-server
      jcm.cluster.mode.files.path: Z:\\
      jcm.cluster.mode.cmd=net use Z: \\\\APP_SERVER_NAME\\SHARE_NAME /user:APP_SERVER_NAME\\username password
  1. Start all JCM Servers and try to access JCM Console from any computer, using the URL:

    https://IP_LOAD_BALANCER:8443