ApsaraDB for MongoDB allows you to create read-only data images in a replica set instance or a sharded cluster instance. A data image in a replica set instance can store up to 3 TB of data and that in a sharded cluster instance can store up to 96 TB of data.

How data images work

After you create data images for an instance in which a large amount of data is being updated, all read requests from applications are redirected to read data from the data images. The applications do not read data from the instance until data is completely updated in the instance. The applications read data from the data images as if they were reading data from the instance, without any compromise to the read performance.
Note After data is updated in the instance, you can synchronize the updated data to the data images so that the applications can read the latest data from the data images later. You can use the commands provided by Alibaba Cloud to enable automatic data synchronization within seconds. Data synchronization does not affect normal read operations.

Create data images in a replica set instance

  1. Use the mongo shell to connect to the primary node or a secondary node where you want to create a data image. For more information, see Connect to a replica set instance by using the mongo shell.
  2. Run the following command to create a data image:
    db.runCommand({checkpoint:"create"})
  3. Run the following command to delete the data image when you no longer need it:
    db.runCommand({checkpoint:"drop"})

Create data images in a sharded cluster instance

  1. Use the mongo shell to connect to any mongos node in the sharded cluster instance where you want to create data images. For more information, see Connect to a sharded cluster instance by using the mongo shell.
  2. Create data images.
    • To create a data image on the primary node of each shard, run the following command:
      db.runCommand({runCommandOnShard: "all", "command": {checkpoint:"create"}})
    • To create a data image on a secondary node of each shard, run the following command:
      db.runCommand({runCommandOnShard: "all", "command": {checkpoint:"create"}, $queryOptions: {$readPreference: {mode: 'secondary'}}})
  3. Delete the data images when you no longer need them.
    • To delete the data image on the primary node of each shard, run the following command:
      db.runCommand({runCommandOnShard: "all", "command": {checkpoint:"drop"}})
    • To delete the data image on a secondary node of each shard, run the following command:
      db.runCommand({runCommandOnShard: "all", "command": {checkpoint:"drop"}, $queryOptions: {$readPreference: {mode: 'secondary'}}})