Migrate from Oracle NoSQL Database to OCI Object Storage Using Session Token Authentication

This example shows how to use Oracle NoSQL Database Migrator with session token authentication to copy data from Oracle NoSQL Database table to a JSON file in an OCI Object Storage bucket.

Use case

As a developer, you are exploring an option to back up Oracle NoSQL Database table data to OCI Object Storage (OCI OS). You want to use session token-based authentication.

In this demonstration, you will use the OCI Command Line Interface commands (CLI) to create a session token. You will manually create a Migrator configuration file and perform data migration.

Prerequisites

Note: Ensure that you have the privileges to write objects in the OCI OS bucket. For more details on setting the policies, see Write to Object Storage.

Procedure

To migrate from Oracle NoSQL Database table to a JSON file in the OCI OS bucket:

  1. Prepare the configuration file (in JSON format) with Oracle NoSQL Database source and JSON file in the OCI OS bucket sink. For templates, see Source Configuration Templates and Sink Configuration Templates.

    To use the session token authentication to access OCI OS bucket, set the useSessionToken parameter to true in the sink configuration template. Correspondingly, specify the config path in the credentials parameter and the profile name in the credentialsProfile parameter.

    {
      "source" : {
        "type" : "nosqldb",
        "storeName" : "kvstore",
        "helperHosts" : ["<hostname>:<port>"],
        "table" : "users",
        "includeTTL" : true,
        "requestTimeoutMs" : 5000
      },
      "sink" : {
        "type" : "object_storage_oci",
        "format" : "json",
        "endpoint" : "us-ashburn-1",
        "namespace" : "idhkv1iewjzj",
        "bucket" : "Migrate_oci",
        "prefix" : "userSession",
        "chunkSize" : 32,
        "compression" : "",
        "useSessionToken" : true,
        "credentials" : "$/home/.oci/config",
        "credentialsProfile" : "SESSIONPROFILE"
      },
      "abortOnError" : true,
      "migratorVersion" : "1.8.0"
    }
  2. Open the command prompt and navigate to the directory where you extracted the NoSQL Database Migrator utility.

  3. Run the runMigrator command by passing configuration file option. Use the --config or -c option to pass the configuration file as follows:

    ./runMigrator --config ./migrator-config.json
  4. The Migrator utility proceeds with data migration. A sample output is shown below.

    With useSessionToken parameter to true, the Migrator utility automatically authenticates using the session token. The Migrator utility copies your data from users table to a JSON file in the OCI OS bucket named Migrate_oci. Check the logs for successful data backup.

    [INFO] creating source from given configuration:
    [INFO] source creation completed
    [INFO] creating sink from given configuration:
    [INFO] sink creation completed
    [INFO] creating migrator pipeline
    [INFO] [OCI OS sink] : writing table schema to userSession/Schema/schema.ddl
    [INFO] migration started
    [INFO] Migration success for source users_6_10. read=2,written=2,failed=0
    
    [INFO] Migration success for source users_1_5. read=3,written=3,failed=0
    
    [INFO] Migration is successful for all the sources.
    [INFO] migration completed.
    Records provided by source=5, Records written to sink=5, Records failed=0,Records skipped=0.
    Elapsed time: 0min 0sec 982ms
    Migration completed.

    Note:

    Depending on the chunkSize parameter in the sink configuration template, the Migrator utility splits the source data into several JSON files in the same directory. In this example, the Migrator utility copies data to users_1_5_0.json and users_6_10_0.json files in Migrate_oci/userSession/Data directory.

    The source table schema is copied to schema.ddl file in Migrate_oci/userSession/Schema directory.

Verification

To verify your data backup, log in to the Oracle NoSQL Database Cloud Service console. Navigate through the menus, Storage > Object Storage & Archive Storage > Buckets. Access the files from the userSession directory in the Migrate_oci bucket. For the procedure to access the console, see Accessing the Service from the Infrastructure Console