Self-managed data source: MongoDB

更新时间:
复制 MD 格式

Add a MongoDB data source to connect Quick BI to your MongoDB database. Once connected, you can analyze and visualize data in Quick BI. Quick BI supports connecting to MongoDB over a public network or an Alibaba Cloud VPC. This topic describes how to add a self-managed MongoDB data source.

  • Before you begin, ensure that your network is connected:

    • If you connect Quick BI to your MongoDB database over a public network, add the IP addresses of Quick BI to the database allowlist. For more information, see Use security groups.

    • If you connect Quick BI to your MongoDB database over an internal network, use one of the following methods to connect the data source to Quick BI:

      • If your MongoDB database is deployed on an Alibaba Cloud ECS instance, you can connect over an Alibaba Cloud VPC.

      • You can also deploy a bastion host and access the database through an SSH tunnel.

  • Ensure you have the username and password for your self-managed MongoDB database.

Limitations

  • You must have the Workspace Admin or Organization Admin role to create data sources.

  • MongoDB 5.0 is supported.

Step 1: Install MongoDB BI Connector

The following example shows how to install MongoDB Connector for BI on a Linux operating system.

  1. Download the MongoDB Connector for BI.

    Select a Platform that matches your operating system.下载连接器

  2. Extract the downloaded package.

    解压_4.2.2

  3. Start the mongosqld service.

    Note

    You must add the IP address of the ECS instance that runs the mongosqld service to the MongoDB database allowlist.

    ./mongosqld --mongo-uri <Mongo_address> --auth -u <Username> -p <Password>  --schemaRefreshIntervalSecs <Schema_refresh> --addr <Binding_address>

    Parameter

    Description

    Mongo_address

    The MongoDB connection address.

    Username

    A username with root privileges.

    Password

    The password for the specified user.

    Schema_refresh

    The interval at which database and collection metadata in MongoDB is synchronized to memory.

    • Unit: seconds.

    • Recommended value: 86400 (1 day).

    Binding_address

    The address and port to bind, typically the internal or public address of the machine.

    Example: 0.0.0.0:3307

    Note

    To connect one machine to multiple instances, start multiple processes using different port numbers.

    • Example for a standard instance:

      ./mongosqld --mongo-uri mongodb://xxxx1.mongodb.rds.aliyuncs.com:3717  --addr 0.0.0.0:3307 -u root -p xxxx --auth --schemaRefreshIntervalSecs 86400
    • Example for a replica set instance:

      ./mongosqld --mongo-uri mongodb://xxxx1.mongodb.rds.aliyuncs.com:3717,xxxx2.mongodb.rds.aliyuncs.com:3717/?replicaSet=mgset-xxxx  --addr 0.0.0.0:3307 -u root -p xxxx --auth --schemaRefreshIntervalSecs 86400

If you see the error ./mongodrdl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory, this indicates that libssl is not installed. Run the following commands to install the library.

# Download from the official website
wget https://www.openssl.org/source/openssl-1.1.1e.tar.gz
# Compile and install
tar -xvf openssl-1.1.1e.tar.gz
cd openssl-1.1.1e
./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
make && make install
# Configure
echo "/usr/local/lib64/" >> /etc/ld.so.conf
ldconfig
# Verify
openssl version

Step 2: Add a MongoDB data source

  1. Log on to the Quick BI console.

  2. To add the data source:

    1. Go to the Create a data source page.

    2. On the Self-managed Data Sources tab, select MongoDB.image

  3. In the Configure Connection dialog box, configure the following parameters.image

    Parameter

    Description

    Display Name

    The name of the data source as it appears in the data source list.

    Use a descriptive name without special characters or leading/trailing spaces.

    Database Address

    The address (IP address or domain name) of the host where the MongoDB Connector for BI service is deployed.

    You must install the MongoDB Connector for BI before connecting.

    Port

    The port number of the database.

    Database

    The name of the database that you specified when you deployed your MongoDB database.

    Username and Password

    The username and password for the database.

    The user must have CREATE, INSERT, UPDATE, and DELETE permissions on the tables in the database.

    VPC Data Source

    If the connector is deployed on an Alibaba Cloud ECS instance in a VPC, select VPC Data Source and configure the following parameters:

    • Payer's AccessKey ID: The AccessKey ID of the account that owns the instance.

      For more information, see Create an AccessKey pair.

      Note

      Ensure that the AccessKey ID has read permissions on the target instance. If the key also has write permissions for the corresponding security group, the system automatically adds the IP address to the allowlist. Otherwise, you must add the IP address manually. For more information, see Create a custom policy.

    • Payer's AccessKey Secret: The AccessKey Secret of the account that owns the instance.

      For more information, see Create an AccessKey pair.

    • Instance ID: The ID of the ECS instance. Log on to the ECS console and find the instance ID on the Instances page.

      For more information, see View instance information.

    • Region: The region where the ECS instance is located.

      For more information, see View instance information.

    SSH

    If you select SSH, you must configure the following parameters:

    You can access the database through an SSH tunnel via a bastion host. Obtain the bastion host information from your O&M engineer or system administrator.

    • SSH Host: Enter the IP address of the bastion host.

    • SSH Username: The username for logging on to the bastion host.

    • SSH Password: The password for the specified username.

    • SSH Port: The port of the bastion host. The default is 22.

    For more information, see Connect to a Linux instance by using a password or key.

  4. Click Test Connection to verify the connection.

    image

  5. After the test succeeds, click OK to create the data source.

Next steps

After you create the data source, you can create a dataset and analyze data.

FAQ

Why isn't data from my MongoDB data source synchronizing to Quick BI in real time?

Cause

MongoDB data sources have a default synchronization delay of one day.

Solution

The data synchronizes automatically after one day.