Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More

Install MongoDB on an external Linux server for Qlik Alerting

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Richard_Byard
Former Employee
Former Employee

Install MongoDB on an external Linux server for Qlik Alerting

Last Update:

Apr 2, 2021 7:43:55 AM

Updated By:

Sue_Macaluso

Created date:

Jul 10, 2020 10:36:34 AM

This document is intended as an example to show how to setup MongoDB on an external Linux server for use with Qlik Alerting. This is intended as an alternative to installing MongoDB on the same machine as Qlik Alerting. 

The reasons you may choose to do this are:

  • For maintenance of versions that fit with your corporate policies
  • to be able to setup a more resilient architecture (more documents to follow with September 2020 release)

This document is based on:

  • an install of Qlik Alerting June 2020
  • a separate linux server running Ubuntu 18.04

If you already have an existing MongoDB cluster that you wish to use with Qlik Alerting then follow the later steps which cover the changes to the configuration in Qlik Alerting.

 

Step 1 - Provision a linux server and install MongoDB

  • Once you have provisioned your linux server you will need to access through SSH. Using a command line tool (Command line, Powershell, Terminal etc) you can open an SSH connection.
    • In the command line enter
      ssh username@servername
      (you may need to use the IP of FQDN in place of servername) 
       
    • you will be prompted to type in the password for this user, enter the password and press enter.

    • You should see that the prompt has updated and should show username@servername:~$

 

  • Install MongoDB on this server
    • Import public key for packet management system. In this example we are using the latest version of MongoDB 4.2
      wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -

    • Create list file for Mongo
      echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list​

    • update the listing before installing
      sudo apt-get update​

    • Call the install
      sudo apt-get install -y mongodb-org​

    • Start the MongoDB service
      sudo systemctl start mongod​

    • Check the status of the service to validate that it is running correctly
      sudo systemctl status mongod​

    • Update systemctl settings to ensure that the MongoDB service starts on reboot
      sudo systemctl enable mongod​

    • Restart the MongoDB service
      sudo systemctl restart mongod​

    • Bring up the Mongo shell functionality to validate the local connection to Mongo
      mongo

 

Step 2 - Configure MongoDB to allow access from your Qlik Alerting server (only)

  • To update the settings you will need to edit the mongod.conf configuration file 
    
sudo nano /etc/mongod.conf
    The contents of the configuration file will be presented.

  • Scroll to the # network interfaces section and update the bindIp value
    For example (where multiple IPs are comma separated with no spaces): 
    • bindIp: 127.0.0.1 (localhost only)
    • bindIp: 127.0.0.1,10.20.123.456 (localhost and server IP 10.20.123.456 only)

  • Do NOT change the #security setting until you have added users on MongoDB.

  • Click ctrl+x and follow the prompts to save the file with the same name

  • Restart the MongoDB service
    sudo systemctl restart mongod​

  • Check the status of the service to validate that it is running correctly following these changes
    sudo systemctl status mongod​

  • Confirm that MongoDB is listening to the new server IPs entered 
    sudo netstat -lnp | grep mongod

  • Allow external access through the firewall to machine from a subnet (in this example public)

    sudo ufw allow proto tcp from 192.168.121.0/24 to any port 27017 
    (or make more secure as you need to)

  • Test connection from an external machine
 
    • Mac/Linux
      sudo nc -vznu <server ip or fqdn> 27017

    • Windows, use telnet (will need to be installed as a feature on machine)
      telnet <server ip or fqdn> 27017

 

Step 3 - Setup a user in MongoDB for Qlik Alerting to use to securely access the Qlik Alerting database only.

  • from your SSH connection, connect to mongo shell
    mongo

  • Create an admin user for MongoDB if this is a new install. One who has access to manage MongoDB access to all databases in the future.
    NOTE: this is an important step before configuring authorization in the mongod.conf file.

    • change database to use the admin database
      use admin

    • create an admin user and password

      db.createUser({ user: "mongo-root", pwd: "yourPassword", roles: [ { role: "root", db: "admin" } ] } )

  • Create a Qlik Alerting database user with access to only that database.
    • Change database to use the qlikalerting database
      use qlikalerting

    • Create the qlik user with readwrite access to the qlikalerting database
      db.createUser({ user: "qlik", pwd: "yourPassword", roles: [ { role: “readWrite”, db: "qlikalerting" } ] } )

    • Exit mongo shell
      Exit

  • From your SSH prompt you can now enable security by changing the mongod.conf file.
    • Open the mongod.conf file
      sudo nano /etc/mongod.conf
      The contents of the configuration file will be presented.

    • Scroll to the #security section and ensure it shows as follows
      security:
         authorization: enabled

  • Click ctrl+x and follow the prompts to save the file with the same name

  • Restart the MongoDB service
    sudo systemctl restart mongod​

  • Check the status of the service to validate that it is running correctly following these changes
    sudo systemctl status mongod​

 

Step 4 - Configure Qlik Alerting to use the external MongoDB database

NOTE: you can install Qlik Alerting without having the Mongo or Redis databases locally installed. You should not try the registration steps before resetting the connection to the external databases.

  • You will need a remote session on the Qlik Alerting server.

  • Navigate to the C:\Program Files\Qlik Alerting\repository\config folder

  • Open the default.json file using a text editor (preferably one that formats nicely)

  • Edit the repository > uses > mongodb details:

    • the database 'qlikalerting' is the name of the database in MongoDB where all the data for Qlik Alerting will be stored. It defaults as qlikalerting but can be changed if required. e.g. "database" : "qlikalerting"

    • update the ip key with server (IP or FQDN) of your external MongoDB server, e.g. "ip": "10.20.123.456"

    • update the port if you have changed the standard port for MongoDB, e.g. "port": 27017

    • Assuming you have enabled authentication, update the auth key to "auth": true

    • Identify the authentication database in MongoDB (you may have setup your user authentication on a different database). In the example able the authentication is directly on the qlikalerting database. e.g. "authDatabase": "qlikalerting"

    • enter the username of the MongoDB user created above, e.g. "user": "qlik"

    • enter the password for this user as created in MongoDB, e.g. "password": "yourPassword"

    • [advanced] The final connectionString option is null by default. This provides the option of connecting with a pre-constructed string rather than entering all of the details above. Your MongoDB admin can support you with this option.

  • Save the default.json file

  • Restart the Qlik Alerting Repository service

You should now be able to register (new install) or login (existing install) using this new external database.

 

Additional guides for information

Tags (1)
Labels (2)
Contributors
Version history
Last update:
‎2021-04-02 07:43 AM
Updated by: