Skip to content

Migration of MindSphere MongoDB to MongoDB on Alibaba Cloud

This documentation describes one of the procedures to migrate your MongoDB data hosted by MindSphere to an own account from Alibaba Cloud.

Note

If you would like to use your application connected to a MongoDB Backing Service after October 31st 2020, then you need to take action.

Get Backup from MindSphere CloudFoundry MongoDB

To get your backup from MindSphere CloudFoundry MongoDB, refer to Get Backup from MindSphere CloudFoundry MongoDB.

Create MongoDB instance and restore data on MongoDB on Alibaba Cloud

Create and Configure Instance

Note

Here is an example that describes the configuration of creating an MongoDB Replica Set instance with Pay-As-You-Go payment method. If you would like to choose different instance type and configurations, please refer to MongoDB Document of Alibaba Cloud for details.

  1. Sign in Alibaba Cloud with your Alibaba account. Create a new account if you do not have an Alibaba account.
  2. Open MongoDB Console of Alibaba Cloud.
  3. Create MongoDB instance with your preferred region and other configurations. Example configurations are listed below:

    • Database version: MongoDB 4.2
    • Master-slave nodes: Three Nodes
    • Readonly nodes: None
    • Network type: Classic Network
    • Specification: 1 CPU/2GB RAM
    • Storage: 10GB
    • Password: set password for root user.
    • Quatity: 1
  4. After the instance is created, click the Instance ID from MongoDB Console of Alibaba Cloud for instance configuration. alibaba-show-mongodb-cluster

  5. Add the below IP addresses into the instance whitelist group:

alibaba-mongodb-whitelist-all 6. Apply Public IP Connection for the instance. alibaba-connection-string 7. Copy and save the Primary, Secondary and ConnectionStringURL addresses from Public IP Connection for future reference.
8. Enable SSL connection for the instance. alibaba-mongodb-enable-ssl 9. Click the Download Certificate to download the certificate file and unzip it for future reference.

Restore Backup into Instance

  1. Follow Mongorestore documentation to install mongorestore.
  2. Run mongorestore command after replacing the placeholders:
    mongorestore --host <HOST> -u root --password <PASSWORD> --authenticationDatabase admin <BACKUP>

    • <HOST>: instance public primary address.
    • <PASSWORD>: instance password.
    • <BACKUP>: --gzip --archive=decrypted-backup.
  3. If ssl is enabled, add --ssl --sslCAFile ApsaraDB-CA-Chain.pem --sslAllowInvalidHostnames to the end of the command.
    Example:
    mongorestore --host dds-uf693c3673b567341130-pub.mongodb.rds.aliyuncs.com:3717 -u root --password <password> --authenticationDatabase admin --gzip --archive=decrypted-backup --ssl --sslCAFile ApsaraDB-CA-Chain.pem --sslAllowInvalidHostnames

  4. After successful restore, connect to the instance through Alibaba Cloud DMS to check whether the database is shown. For example, restored mod2188b8 is shown. alibaba-mongorestore-result
  5. Create a user <userName> with password <userPassword> for your database and save for future reference.
  6. Save the database name <userDatabase> for future reference.

Change connection to Alibaba Cloud MongoDB instance in MindSphere CloudFoundry

  1. Replace placeholders of saved ConnectionStringURL address.
    Example:
    mongodb://root:****@dds-uf693c3673b567341130-pub.mongodb.rds.aliyuncs.com:3717,dds-uf693c3673b567342415-pub.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-24461597

    • root:****: database user name and password <userName>:<userPassword>.
    • admin: database name <userDatabase>. The ConnectionStringURL address will be as shown below:
    1
      mongodb://<userName>:<userPassword>@dds-uf693c3673b567341130-pub.mongodb.rds.aliyuncs.com:3717,dds-uf693c3673b567342415-pub.mongodb.rds.aliyuncs.com:3717/<userDatabase>?replicaSet=mgset-24461597
    
  2. Create a User-Provided-Service via CF CLI.

    1
      cf cups <my-mongodb.com-cluster> -p "uri"
    

  3. When requested for uri, use the ConnectionStringURL address provided above.

  4. Unbind MindSphere CloudFoundry Backing Service from your app.

    1
      cf us <myapp> <my-old-mongodb>
    

  5. Bind User-Provided-Service to your app.

    1
      cf bs <myapp> <my-mongodb.com-cluster>
    

  6. Restage your app.

    1
      cf restage <myapp>
    

Hints

  • Remember to change the service instance name to the User-Provided-Service in your manifest.yml.
  • MongoDB TLS/SSL is standard.
  • Latency time may be higher than earlier.
  • Your application may need more outbound traffic.
  • Your database endpoint is now accessible over internet. Please consider the Security White Paper of Alibaba Cloud MongoDB and implement all additional security measures recommended by your organization.

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.