How to install Mongo BI Connector in Ubuntu 18.04

Eder Chamalé
4 min readOct 16, 2019

As part of an innovation project, I had to develop an analytics dashboard for a data storage in MongoDb. I found an interesting component to achieve my goal and this is Mongo BI Connector.

According to documentation there is no release for Ubuntu 18.04 😢, so we are gonna try to install another version compiled for Ubuntu 16.04. First of all we need to create a folder in which we are going to store Mongo BI Connector binaries, let’s start:

root@mongo-master:~/bin# mkdir ~/bin&&cd ~/bin

Then we are going to download Mongo BI Connector binaries

root@mongo-master:~/bin# wget https://info-mongodb-com.s3.amazonaws.com/mongodb-bi/v2/mongodb-bi-linux-x86_64-ubuntu1604-v2.12.0.tgz

And then we are going to unpack this file:

root@mongo-master:~/bin# tar -xvzf mongodb-bi-linux-x86_64-ubuntu1604-v2.12.0.tgz

We need to install Mongo BI Connector in a folder that must be in $PATH environment, so we are going to check which folder is available:

root@mongo-master:~/bin# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

As we can see, /user/local/bin is a valid path, so let’s use this location to install the connector:

root@mongo-master:~/bin# cd mongodb-bi-linux-x86_64-ubuntu1604-v2.12.0/
root@mongo-master:~/bin/mongodb-bi-linux-x86_64-ubuntu1604-v2.12.0# install -m755 bin/mongo* /usr/local/bin/

Let’s test if connector was successfully installed by running mongosqld command, the output must be:

root@mongo-master:~/bin/mongodb-bi-linux-x86_64-ubuntu1604-v2.12.0# mongosqld
2019-10-16T15:56:42.723-0600 I CONTROL [initandlisten] mongosqld starting: version=v2.12.0 pid=15246 host=mongo-master
2019-10-16T15:56:42.723-0600 I CONTROL [initandlisten] git version: 60455768a9057952689b6a02b344aeac55a72091
2019-10-16T15:56:42.723-0600 I CONTROL [initandlisten] OpenSSL version OpenSSL 1.0.2n 7 Dec 2017 (built with OpenSSL 1.0.2g 1 Mar 2016)
2019-10-16T15:56:42.723-0600 I CONTROL [initandlisten] options: {}
2019-10-16T15:56:42.723-0600 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for mongosqld.
2019-10-16T15:56:42.723-0600 I CONTROL [initandlisten]
2019-10-16T15:56:42.727-0600 I NETWORK [initandlisten] waiting for connections at 127.0.0.1:3307
2019-10-16T15:56:42.727-0600 I NETWORK [initandlisten] waiting for connections at /tmp/mysql.sock

TIP AND TRICKS 🚀🤔

Connection refused

If you got a message like this:

2019-10-16T15:57:12.728-0600 E NETWORK    [initandlisten] unable to load MongoDB information: failed to create admin session for loading server cluster information: unable to execute command: server selection error: server selection timeout
current topology: Type: Unknown
Servers:
Addr: localhost:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : dial tcp 127.0.0.1:27017: connect: connection refused

Don’t worry, it is because you have a binding IP that is not 127.0.0.1 and we can solve this by using a configuration file like this:

systemLog:
path: '/logs/mongosqld.log'
mongodb:
net:
uri: "mongo.example.com:27017"

Here we need to specify a path for system logs and our binding IP but, how do we know which IP is mongo using? If you follow default Mongo Db instructions there must be a file named /etc/mongod.conf and here we can get Mongo binding IP, running the following command:

root@mongo-master:~/bin/mongodb-bi-linux-x86_64-ubuntu1604-v2.12.0# cat /etc/mongod.conf#... CONFIGURATION INFO....# network interfaces
net:
port: 27017
bindIp: 192.136.9.125
#... MORE CONFIGURATION INFO....

And then we are going to create our Mongo BI Connector configuration file (be careful where you are going to create this file):

root@mongo-master:~/bin/mongodb-bi-linux-x86_64-ubuntu1604-v2.12.0# mkdir ~/conf&&cd ~/conf
root@mongo-master:~/conf# touch mongosqld.conf

And then let’s use nano or your preferred editor to add our configuration content:

#-------- ~/conf/mongosqld.conf ---------systemLog:
path: '/logs/mongosqld.log'
mongodb:
net:
uri: "192.136.9.125:27017"

🛑 WARNING: path for systemLog must exists, if not create it by executing mkdir /logs

Now let’s test our installation by passing config parameter to mongosqld :

mongosqld --config=~/conf/mongosqld.conf

To verify if everything is running successfully, let’s check our logs:

root@mongo-arbiter:~/conf# cat /logs/mongosqld.log
log output directed to /logs/mongosqld.log
2019-10-16T17:04:47.166-0600 I CONTROL [initandlisten] mongosqld starting: version=v2.12.0 pid=20261 host=mongo-arbiter
2019-10-16T17:04:47.166-0600 I CONTROL [initandlisten] git version: 60455768a9057952689b6a02b344aeac55a72091
2019-10-16T17:04:47.166-0600 I CONTROL [initandlisten] OpenSSL version OpenSSL 1.0.2n 7 Dec 2017 (built with OpenSSL 1.0.2g 1 Mar 2016)
2019-10-16T17:04:47.166-0600 I CONTROL [initandlisten] options: {config: "/root/conf/mongosqld.conf", systemLog: {path: "/logs/mongosqld.log"}, mongodb: {net: {uri: "192.136.9.125:27017", auth: {source: "admin"}}}}
2019-10-16T17:04:47.166-0600 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for mongosqld.
2019-10-16T17:04:47.166-0600 I CONTROL [initandlisten]
2019-10-16T17:04:47.168-0600 I NETWORK [initandlisten] waiting for connections at 127.0.0.1:3307
2019-10-16T17:04:47.168-0600 I NETWORK [initandlisten] waiting for connections at /tmp/mysql.sock
2019-10-16T17:04:47.172-0600 I SCHEMA [sampler] sampling MongoDB for schema...
2019-10-16T17:04:57.892-0600 I SCHEMA [sampler] mapped schema for 83 namespaces:
....

Installing as a service 🐱‍👤

If you want to install Mongo BI Connector as a service just run the following commands (💡 if you do not have a configuration file, just ignore config parameter)

root@mongo-arbiter:~/conf# mongosqld install --config ~/conf/mongosqld.conf

And finally to start the service and running at startup let’s execute:

root@mongo-arbiter:~/conf# systemctl start mongosql.serviceroot@mongo-arbiter:~/conf# systemctl enable mongosql.service

Connecting to a replica set

You could use a configuration file like this:

systemLog:
path: '/logs/mongosqld.log'
mongodb:
net:
uri: "mongodb://192.136.9.125:27017,192.136.9.126:27017/?replicaSet=MEDIUM_COM"

🤠 Final notes

I don’t speak English natively, sorry for any mistakes. Suggestions are welcome!

--

--