Configure Mongo DB for Log Agent - EcoSys - Installation & Upgrade - Hexagon PPM

EcoSys Connect Installation and Configuration

Language
English
Product
EcoSys
Search by Category
Installation & Upgrade
EcoSys Version
1.0.01

The Log Agent requires MongoDB for its operations. This section explains the steps to create the necessary MongoDB databases that will be used while deploying the Log Agent Swarm service.

The initial setup of MongoDB requires a few credentials to be established as listed in the table below.

Label

Purpose

Value

_ROOT_PASS_

The MongoDB setup process creates a superuser called ‘root’ in the ‘admin’ database. This is the password for the ‘root’ user.

_DB1_

The MongoDB database name that the Log Agent requires for normal operations. The default value for this database is ‘connectLogs’.

connectLogs

_DB1_USER_

The user name for the database DB1. The default value for the username is ‘ecuser’

ecuser

_DB1_PASS_

The password for the user _DB1_USER_

_BACKUP_USER_

A user who can backup databases in MongoDB

backup

_BACKUP_PASS_

The password for the user _BACKUP_USER_

To configure MongoDB,

  1. Edit the file $CONNECT/components/logAgent/swarm/rootPassword.txt. Replace its contents with the value chosen for _ROOT_PASS_

  2. Edit the file $CONNECT/components/logAgent/swarm/config/setup/userSetup.js. Change the values of _DB1_, _DB1_USER_ and _DB1_PASS_ as necessary.

  3. Open a shell and change the directory to $CONNECT/components/logAgent/swarm.

  4. In the shell, issue the host command below,

    docker secret create mongo-root ./rootPassword.txt

  5. To create a Docker volume for managing data persistence, issue the host shell command below,

    docker volume create mongo-data

  6. To initialize data in this volume, issue the host shell command below,

    docker run --rm -ti -v mongo-data:/tmp/mongo alpine /bin/sh -c "chown -R 999:999 /tmp/mongo; chmod -R 755 /tmp/mongo"

  7. To create a Docker volume for managing log persistence, issue the host shell command below,

    docker volume create mongo-log

  8. To initialize data in this volume, issue the host shell command below,

    docker run --rm -ti -v mongo-log:/tmp/mongo alpine /bin/sh -c "chown -R 999:999 /tmp/mongo; chmod -R 755 /tmp/mongo"

  9. Create a temporary Docker volume for creating MongoDB configuration by issuing the host shell ,

    docker volume create mongo-config

  10. To initialize data in this volume, issue the host shell command

    docker run --rm -ti -v mongo-config:/tmp/mongo-config -v $CONNECT/components/logAgent/swarm/config/setup:/tmp/src alpine /bin/sh -c "cp /tmp/src/*.js /tmp/mongo-config; chown -R 999:999 /tmp/mongo-config; chmod -R 777 /tmp/mongo-config"

  11. If Docker Swarm is not active, enable it by using the host shell command below:

    docker swarm init

  12. To set up MongoDB, deploy a temporary stack using the host shell command:

    docker stack deploy -c mongo-setup-stack.yaml --with-registry-auth mongo-setup

  13. To verify that the service is provisioned, issue the host shell command below:

    docker service ls

    When the service has provisioned correctly, the count under ‘REPLICAS’ should read 1/1.

    This can take several seconds.

  14. Execute the host shell commands below:

    • On Linux, execute the command below,

      docker exec -it $(docker ps -q -f name=mongo) mongo --authenticationDatabase "admin" -u "root" -p " _ROOT_PASS_" /tmp/mongo-config/userSetup.js

    • On Windows, you must execute the commands as two separate commands as follows,

      docker ps -q -f name=mongo

      docker exec -it <container ID> mongo --authenticationDatabase "admin" -u "root" -p "_ROOT_PASS_" /tmp/mongo-config/userSetup.js

      This will generate the following output:

Cleanup files

Follow the steps below to complete Mongo DB setup,

  1. To stop the temporary stack, issue the host shell command:

    docker stack rm mongo-setup

  2. Wait a few seconds and delete the Docker volume that was used to help with user provisioning by issuing the host shell command:

    docker volume rm mongo-config

  3. To delete the Docker secret created for the root user, issue the host shell command:

    docker secret rm mongo-root

  4. Delete $CONNECT/components/logAgent/swarm/rootPassword.txt

  5. Delete $CONNECT/components/logAgent/swarm/config/setup/userSetup.js

    This completes the MongoDB setup.