MongoDB is a document-oriented database that is second only to Oracle and MySQL. DataWorks provides MongoDB Reader and MongoDB Writer for you to read data from and write data to MongoDB data sources. You can use the codeless user interface (UI) or code editor to configure synchronization nodes for MongoDB data sources.

Background information

Workspaces in standard mode support the data source isolation feature. You can add data sources for the development and production environments separately and isolate the data sources to protect your data security. For more information, see Isolate connections between the development and production environments.

Procedure

  1. Go to the Data Source page.
    1. Log on to the DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. After you select the region where the required workspace resides, find the workspace and click Data Integration.
    4. In the left-side navigation pane, choose Data Source > Data Sources.
  2. On the Data Source page, click New data source in the upper-right corner.
  3. In the Add data source dialog box, click MongoDB in the NoSQL section.
  4. In the Add MongoDB data source dialog box, configure the parameters.
    You can use one of the following modes to add a MongoDB data source: Alibaba Cloud instance mode and Connection string mode.
    • Alibaba Cloud instance mode: In most cases, the classic network is used to access MongoDB data sources that are added in this mode. If DataWorks and the MongoDB data source reside in the same region, the MongoDB data source can be connected to Dataworks over the classic network. If DataWorks and the MongoDB data source reside in different regions, the connectivity over the classic network between the MongoDB data source and DataWorks cannot be ensured. MongDB
      Parameter Description
      Data source type The type of the data source. Set this parameter to Alibaba Cloud instance mode.
      Note If you have not assigned the default role to Data Integration, log on to the Resource Access Management (RAM) console by using your Alibaba Cloud account and perform authorization. Then, refresh the configuration page.
      Data Source Name The name of the data source. The name can contain letters, digits, and underscores (_) and must start with a letter.
      Data source description The description of the data source. The description can be a maximum of 80 characters in length.
      Environment The environment in which the data source is used. Valid values: Development and Production.
      Note This parameter is displayed only when the workspace is in standard mode.
      Region The region where your ApsaraDB for MongoDB instance resides.
      Instance ID The ID of your ApsaraDB for MongoDB instance. You can view the ID in the ApsaraDB for MongoDB console.
      Database name The name of the database that you created in the ApsaraDB for MongoDB console. You can create a database and specify a username and a password for the database in this console.
      User name The username that you use to connect to the database.
      Password The password that you use to connect to the database.
    • Connection string mode: In most cases, the Internet is used to access MongoDB data sources that are added in this mode. Access over the Internet may generate fees. MongoDB
      Parameter Description
      Data source type The type of the data source. Set this parameter to Connection string mode.
      Data Source Name The name of the data source. The name can contain letters, digits, and underscores (_) and must start with a letter.
      Data source description The description of the data source. The description can be a maximum of 80 characters in length.
      Environment The environment in which the data source is used. Valid values: Development and Production.
      Note This parameter is displayed only when the workspace is in standard mode.
      Access address The address of the MongoDB data source, in the IP address of the host:Port number format. You can click Add access address to specify multiple addresses.
      Note If you specify multiple addresses, you must make sure that all the host IP addresses specified in the addresses are either public or private IP addresses.
      Database name The name of the MongoDB database.
      User name The username that you use to connect to the database.
      Password The password that you use to connect to the database.
      To add a MongoDB data source in connection string mode, perform the following steps:
      1. Set Data source type to Connection string mode.
      2. In the Add MongoDB data source dialog box, configure the parameters. You must set the IP address of the host in the address specified by the Access address parameter to the private IP address of the data source.
      3. Click Complete without testing the connectivity of the data source.
      4. Create a custom resource group for running synchronization nodes. For more information, see Create a custom resource group for Data Integration.
      Notice
      • You can test the connectivity of an ApsaraDB for MongoDB data source only if it resides on the classic network.
      • If the data source is deployed in a virtual private cloud (VPC), set Data source type to Connection string mode.
      • If the data source is deployed in a VPC, you cannot test the connectivity of the data source.
  5. After the connection passes the connectivity test, click Complete.

What to do next

You have learned how to add a MongoDB data source. You can proceed to subsequent tutorials. In subsequent tutorials, you will learn how to configure MongoDB Reader and MongoDB Writer. For more information, see MongoDB Reader and MongoDB Writer.