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.
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.
- Identify the source and sink for the migration.
- Source:
users
table in Oracle NoSQL Database. - Sink: JSON file in the OCI OS bucket
Identify the region endpoint, namespace, bucket, and prefix for OCI OS. For the list of OCI OS service endpoints, see Object Storage Endpoints.
- endpoint:
us-ashburn-1
- bucket:
Migrate_oci
- prefix:
userSession
- namespace:
idhkv1iewjzj
The namespace name for a bucket is the same as it's tenancy's namespace and is autogenerated when your tenancy is created. You can get the namespace name as follows:- From the Oracle NoSQL Database Cloud Service console, navigate to Storage > Buckets.
- Select you Compartment from the List Scope and select the bucket. The Bucket Details page displays the name in Namespace parameter.
If you do not provide an OCI OS namespace name, the Migrator utility uses the default namespace of the tenancy.
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. - endpoint:
- Source:
- Generate a session token by following these steps:
- Install and configure OCI CLI. See Quickstart.
- Use one of the following OCI CLI commands to generate a session token. For more details on the available options, see Token-based Authentication for the CLI.
#Create a session token using OCI CLI from a web browser: oci session authenticate --region <region_name> --profile-name <profile_name>
#Example: oci session authenticate --region us-ashburn-1 --profile-name SESSIONPROFILE
or
#Create a session token using OCI CLI without a web browser: oci session authenticate --no-browser --region <region_name> --profile-name <profile_name>
#Example: oci session authenticate --no-browser --region us-ashburn-1 --profile-name SESSIONPROFILE
In the command above,
region_name
: Specifies the region endpoint for your OCI OS. For a list of data regions supported in Oracle NoSQL Database Cloud Service, see Data Regions and Associated Service URLs.profile_name
: Specifies the profile, which the OCI CLI command uses to generate a session token.The OCI CLI command creates an entry in the OCI config file at$HOME/.oci/config
path as shown in the following sample:[SESSIONPROFILE] fingerprint=f1:e9:b7:e6:25:ff:fe:05:71:be:e8:aa:cc:3d:0d:23 key_file=$HOME/.oci/sessions/SESSIONPROFILE/oci_api_key.pem tenancy=ocid1.tenancy.oc1..aaaaa ... d6zjq region=us-ashburn-1 security_token_file=$HOME/.oci/sessions/SESSIONPROFILE/token
The
security_token_file
points to the path of the session token that you generated using the OCI CLI command above.Note:
- If the profile already exists in the OCI config file, the OCI CLI command overwrites the profile with session-token related configuration while generating the session token.
- Specify the following in your sink configuration template:
- The path to the OCI config file in the credentials parameter.
- The profile used while generating the session token in the credentialsProfile parameter.
"credentials" : "$HOME/.oci/config" "credentialsProfile" : "SESSIONPROFILE"
The Migrator utility automatically fetches the details of the session token generated using the parameters above. If you don't specify the credentials parameter, the Migrator utility looks for the credentials file in the path
$HOME/.oci
. If you don't specify the credentialsProfile parameter, the Migrator utility uses the default profile name (DEFAULT) from the OCI config file. - The session token is valid for 60 minutes. To extend the session duration, you can refresh the session. For details, see Refreshing a Token.
To migrate from Oracle NoSQL Database table to a JSON file in the OCI OS bucket:
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