Migrate from MongoDB JSON file to an Oracle NoSQL Database Cloud Service
This example shows how to use the Oracle NoSQL Database Migrator to copy Mongo-DB Formatted Data to the Oracle NoSQL Database (NDCS).
Use Case
After evaluating multiple options, an organization finalizes Oracle NoSQL Database as its NoSQL Database platform. As its NoSQL tables and data are in MongoDB, they are looking for a way to migrate those tables and data to Oracle NDCS.
Example
For the demonstration, let us look at how to migrate a MongoDB-formatted JSON file to NDCS. We will use a manually created configuration JSON file for this example.- Identify the source and sink for the migration.
- Source: MongoDB-Formatted JSON File
- Sink: Oracle NoSQL Database
- Extract the data from Mongo DB using the mongoexport utility. See mongoexport for more information.
- Create a NoSQL table in the sink with a table
schema that matches the data in the Mongo-DB-formatted JSON
file. As an alternative, you can instruct the NoSQL Database Migratorto create a table with the
default schema structure by setting the
defaultSchema
attribute to true.Note:
For a MongoDB-Formatted JSON source, the default schema for the table will be as:CREATE TABLE IF NOT EXISTS <tablename>(ID STRING, DOCUMENT JSON,PRIMARY KEY(SHARD(ID))
Where:tablename
= value of the table config.ID
=_id
value from the mongoDB exported JSON source file.DOCUMENT
= The entire contents of the mongoDB exported JSON source file is aggregated into theDOCUMENT
column excluding the_id
field.
- Identify your OCI cloud credentials and capture them
in the OCI config file. Save the config file in
/home/.oci/config
. See Acquiring Credentials in Using Oracle NoSQL Database Cloud Service.[DEFAULT] tenancy=ocid1.tenancy.oc1.... user=ocid1.user.oc1.... fingerprint= 43:d1:.... key_file=</fully/qualified/path/to/the/private/key/> pass_phrase=<passphrase>
- Identify the region endpoint and compartment name
for your Oracle NoSQL Database.
- endpoint:
us-phoenix-1
- compartment:
developers
- endpoint:
To migrate the MongoDB-formatted JSON data to the Oracle NoSQL Database:
To validate the migration, you
can login to your NDCS console and verify that
myTable
is created with the source
data.