MongoDB is a document-oriented database that is second only to Oracle and MySQL. A MongoDB connection allows you to read data from and write data to MongoDB by using MongoDB Reader and Writer. You can configure sync nodes for MongoDB by using the code editor.

Note Workspaces in standard mode support the connection isolation feature. You can add connections for the development and production environments separately and isolate the connections to protect your data security.

Procedure

  1. Log on to the DataWorks console as a workspace administrator, find the target workspace, and then click Data Integration in the Actions column.
  2. In the left-side navigation pane, click Connection to go to the Workspace Manage > Data Source page.
  3. On the Data Source page that appears, click Add Connection in the upper-right corner.
  4. In the Add Connection dialog box that appears, click MongoDB in the NoSQL section.
  5. In the Add MongoDB Connection dialog box that appears, set the parameters.
    The MongoDB connection type can be set to ApsaraDB for RDS or JDBC Connection Mode.
    • ApsaraDB for RDS: Classic networks are generally used. Classic networks in the same region can be connected, while classic networks in different regions cannot be connected.
    • JDBC Connection Mode: The public network is generally used, which may cost you certain fees.

    The following table describes the parameters that appear after you set Connect To to ApsaraDB for RDS.

    Parameter Description
    Connect To The type of the connection. Here, set the value to ApsaraDB for RDS.
    Note If you have not assigned the default role to Data Integration, log on to the Resource Access Management (RAM) console with your Alibaba Cloud account and perform authorization. Then, refresh this configuration page.
    Connection Name The name of the connection. The name can contain letters, digits, and underscores (_) and must start with a letter.
    Description The description of the connection. The description cannot exceed 80 characters in length.
    Applicable Environment The environment in which the connection is used. Valid values: Development and Production.
    Note This parameter is available only when the workspace is in standard mode.
    Region The region of the MongoDB instance.
    Instance ID The ID of the ApsaraDB for MongoDB instance. You can view the ID in the ApsaraDB for MongoDB console.
    Database Name The name of the database you created in the ApsaraDB for MongoDB console. You can also specify the database username and password in the console.
    Username The username for logging on to the database.
    Password The password for logging on to the database.

    The following table describes the parameters that appear after you set Connect To to JDBC Connection Mode.

    Parameter Description
    Connect To The type of the connection. Here, set the value to JDBC Connection Mode.
    Connection Name The name of the connection. The name can contain letters, digits, and underscores (_) and must start with a letter.
    Description The description of the connection. The description cannot exceed 80 characters in length.
    Applicable Environment The environment in which the connection is used. Valid values: Development and Production.
    Note This parameter is available only when the workspace is in standard mode.
    Address The endpoint in the host:port format. To add an endpoint, click Add Address and specify the endpoint to add. To add more endpoints, repeat the preceding action.
    Note You must add either public endpoints or internal endpoints. Do not mix public endpoints with internal endpoints.
    Database Name The name of the database.
    Username The username for logging on to the database.
    Password The password for logging on to the database.
    Note To configure a MongoDB connection in connection mode, follow these steps:
    1. Set Connect To to JDBC Connection Mode.
    2. In the Add MongoDB Connection dialog box that appears, set the parameters. Note that you must specify an internal endpoint as the address.
    3. Click Complete without testing the connectivity.
    4. Add a custom resource group for running sync nodes. For more information, see Add a custom resource group.
  6. Click Test Connection.
  7. After the connectivity test is passed, click Complete.
    Note
    • If the data store is deployed in a Virtual Private Cloud (VPC), set Connect To to JDBC Connection Mode.
    • If the data store is deployed in a VPC, the connectivity test is not supported.

What to do next

Now you have learned how to configure a MongoDB connection. You can proceed with the next tutorial. In the next tutorial, you will learn how to configure MongoDB Reader and Writer.