Apply for node tags

更新时间:
复制 MD 格式

If the secondary nodes of an ApsaraDB for MongoDB instance do not have node tags, the readPreferenceTags parameter that routes read operations to secondary nodes does not take effect. You can apply for node tags to resolve this issue.

Background information

The readPreferenceTags parameter in a connection string URI routes read requests to nodes that match specific tags. This parameter takes effect only after node tags are configured for the instance. By default, secondary nodes on existing ApsaraDB for MongoDB instances do not have node tags, so read requests are not routed to secondary nodes as intended when you use a connection string URI. You can resolve this issue by applying for node tags.

You can follow this procedure to check whether your instance already has node tags. If tags have been applied, the relevant button is grayed out.

After you apply for node tags, add the following tags to your connection string URI to configure read routing:

  • readPreferenceTags=role:electable: Prioritizes read operations on secondary nodes.

  • readPreferenceTags=role:readonly: Prioritizes read operations on read-only nodes.

For more information, see Connect to a replica set instance and Connect to a sharded cluster instance.

Prerequisites

The instance is a replica set instance or a sharded cluster instance that uses cloud disks.

Procedure

  1. Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select a resource group and a region, and then click the ID of the target instance.

  2. In the navigation pane on the left of the instance details page, click Database Connections.

  3. Click Apply for Node Tag.

  4. The next steps vary based on the instance type:

    • For a replica set instance

      In the Apply for Node Tag dialog box, click Confirm.

    • For a sharded cluster instance

      In the Apply for Node Tag panel, select the nodes to tag, and then click Confirm.

Note

When you apply for node tags, the instance status changes to switching parameter configurations. This does not affect read or write operations. When the instance status returns to Running, the node tags are applied.