User Tools

Site Tools


on-premise_guide_for_docker_environment

On-premise Guide for Message Broker Service Installation

Perspectium Message Broker Service (MBS) is typically deployed on-premise in a Docker environment as containerized micro-services. This approach and environment was chosen to offer the most consistent and portable way to compose and deliver the multiple services required.

Alternatively, you can refer to the following non container approach for an on-premise installation: On-Premise Guide For HA Environment Setup.

The alternative approach is deprecated and recommended only as documentation for the contents of the services.

Pre-requisites

Download and install the Docker platform into a server or virtual machine with the following minimal specification.

Server or VM System Requirements
Memory 32 GB minimum
Processor Cores 4 minimum
Physical Storage 100 GB minimum

Perspectium Containers

The MBS service requires the running of these container services:

  • RabbitMQ service
  • MySQL service
  • MBS Java service

RabbitMQ Container

MySQL Container

MBS Container

The MBS container is built using a Perspectium published RPM image with the following Dockerfile and entrypoint.sh. To download the RPM, use the following command:

wget http://[userid]:[password]@buildhost.perspectium.org/repo-prod/perspectium-mbs-X.XX.X.noarch.rpm

Get the correct [userid], [password] and [X.XX.X] release version from support@perspectium.com

DockerFile

See https://docs.docker.com/engine/reference/builder/ for usage of this file.

FROM centos:centos6
MAINTAINER Perspectium <support@perspectium.com>
ADD perspectium-mbs*.rpm /tmp/
ADD perspectium.repo /etc/yum.repos.d/
ADD mbs-entrypoint.sh /opt/perspectium/mbs/bin/

RUN yum update -y
RUN yum install -y \
  curl \
  java \
  mysql \
  /tmp/perspectium-mbs*.rpm
LABEL name="Perspectium MBS Docker Image" \
      vendor="Perspectium" \
      license="Proprietary/Commercial" 
EXPOSE 8080
ENTRYPOINT /opt/perspectium/mbs/bin/mbs-entrypoint.sh
HEALTHCHECK --interval=5s --timeout=5s --retries=3 \
  CMD curl -f http://localhost:8080/ui/flist.htm || exit 1

mbs-entrypoint.sh

#!/bin/sh
# $Id: mbs-entrypoint.sh,v 1.5 2016/11/15 22:58:14 ivanb Exp $

trap "echo TRAPed signal; service perspectium-mbs stop ; service perspectium-headless-mbs stop" HUP INT QUIT TERM

CONF=/etc/opt/perspectium/mbs/conf/mbs.xml
# start service in background here
echo "Creating MBS configuration file in ${CONF}"
/opt/perspectium/mbs/bin/create-mbs-config
if [ "$1" == "debug" ]; then
  echo "Configuration file: ${CONF}"
  cat /etc/opt/perspectium/mbs/conf/mbs.xml
fi

HOST="${MYSQL_HOST}"
PORT="${MYSQL_PORT:-3306}"
USER="${MYSQL_USER:-root}"
PASS="${MYSQL_PASS:-xxxx}"
DB="${MYSQL_DB:-psp_db}"

for i in `seq 0 180`; do
  echo "MySQL: CREATE DATABASE IF NOT EXISTS ${DB} as ${USER}@${HOST}:${PORT} attempt ${i}"
  echo "CREATE DATABASE IF NOT EXISTS ${DB};" | mysql --host=${HOST} --port=${PORT} --user=${USER} --password=${PASS}
  if [ "$?" == "0" ]; then 
    break
  fi
  sleep 4
done

if [ "$i" == "180" ]; then
  echo "MySQL Error: MBS Cannot create ${USER}@${HOST}:${PORT}/psp_db"
  exit 1
fi

# release lock
echo "Releasing MySQL lock psp_db.upgraded"
echo "SELECT RELEASE_LOCK('psp_db.upgraded');" | mysql --host=${HOST} --port=${PORT} --user=${USER} --password=${PASS}
if [ "$?" != "0" ]; then
  echo "MySQL Error: Cannot release lock psp_db.upgraded on ${USER}@${HOST}:${PORT}/psp_db"
  exit 1
fi

if [ ! -d /var/opt/perspectium/mbs/logs ]; then
  mkdir -p /var/opt/perspectium/mbs/logs
  chown mbs:mbs /var/opt/perspectium/mbs/logs
fi
echo "starting Perspectium MBS"
echo "Starting MBS in Docker Container $( date )" > /var/opt/perspectium/mbs/logs/container-startup.log
chown mbs:mbs /var/opt/perspectium/mbs/logs/container-startup.log
service perspectium-mbs start && service perspectium-headless-mbs start 
sleep 2

tail -f /var/opt/perspectium/mbs/logs/*.log
#if [ "$1" == "debug" ]; then
#  tail -f /var/opt/perspectium/mbs/logs/*.log
#else
#  echo "[hit enter key to exit] or run 'docker stop <container>'"
#  read
#fi

# stop service and clean up here
echo "stopping Perspectium MBS"
service perspectium-mbs stop && service perspectium-headless-mbs stop

echo "exited $0"

Tying it All Together

The following steps document how to automate the download and execution of the cluster using docker compose commands.

STEP 1: create and download necessary files

  • login to the server or VM provisioned (see pre-requisites section, Docker Engine installed)
  • cd or change directory to the folder for composing the Perspectium containers, e.g. /opt/perspectium/containers (you may have to pre-create this directory)
  • download the Perspectium MBS RPM image using the following command. You can also paste the URL into a browser to download and then copy to the correct folder location:
wget http://[userid]:[password]@buildhost.perspectium.org/repo-prod/perspectium-mbs-X.XX.X.noarch.rpm

Get the correct [userid], [password] and [X.XX.X] release version from support@perspectium.com

  • create the docker-compose.yml file in the same folder using the following content (you can copy and paste this into the file):
services:
  perspectium-mbs-db:
    env_file: ./docker-mbs.env
    image: mysql/mysql-server:latest
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_P}
      - MYSQL_DATABASE=psp_db
      - MYSQL_USER=psp
      - MYSQL_PASSWORD=${MYSQL_P}
    ports:
      - "3306"
  perspectium-mbs-rabbit:
    env_file: ./docker-mbs.env
    image: rabbitmq:3-management
    hostname: perspectium-mbs-rabbit
    environment:
      - RABBITMQ_DEFAULT_USER=admin 
      - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_P}
    ports:
      - "5671"
      - "5672"
      - "15672"
  perspectium-mbs:
    env_file: ./docker-mbs.env
    build:
      context: .
      dockerfile: Dockerfile
    image: perspectium-mbs
    environment:
      - RABBIT_USER=admin
      - RABBIT_PASS=${RABBITMQ_DEFAULT_P}
      - MYSQL_HOST=perspectium-mbs-db
      - MYSQL_PASS=${MYSQL_P}
      - MYSQL_USER=psp
      - RABBIT_URL=amqp://perspectium-mbs-rabbit
    links:
       - perspectium-mbs-db
       - perspectium-mbs-rabbit
    ports:
      - "8080"
    depends_on:
      - perspectium-mbs-db
      - perspectium-mbs-rabbit

Get the correct variables for the values specified in the ${..} placeholders from support@perspectium.com

STEP 2: run "docker-compose build"

This step normally takes several minutes to complete.

STEP 3: run "docker-compose run -d -p 8080 perspectium-mbs"

The following services will now be available and used.

Service Port
HTTP (UI) 8080
AMQP 5672
AMQPS 5671
Rabbit Management Console 15672
MySQL 3306

The “-p” parameter exposes port 8080 only, by default. See https://docs.docker.com/engine/reference/commandline/run/ for more parameters.

on-premise_guide_for_docker_environment.txt · Last modified: 2016/11/17 23:17 by dloo