Migration of MongoDB collections To Oracle Json(ATP) — Part 2
Migration Mongo Collection to Json Autonomous Database
With continuation of migration part 1, let us see another method of migrating mongo db collections to autonomous database using “Oracle Database API for MongoDB”
Introduction:
Oracle Autonomous Json Database
Oracle Autonomous JSON Database is a cloud document database service that makes it simple to develop JSON-centric applications. It features NoSQL-style document APIs (Oracle SODA and Oracle Database API for MongoDB), serverless scaling, high performance ACID transactions, comprehensive security, and low pay-per-use pricing.
Advantages of Json In J-ATP
- Autonomous
- Full SQL support
- ACID transactions
- Advanced security
- APEX low-code development
- One-click instant expansion to ATP
- Enable SQL and Oracle ecosystem for JSON collections
- More and faster analytical capabilities, machine learning
- Query JSON alongside other data models: relational, XML, spatial, etc. using SQL
- Expose relational data, reports, query results as MongoDB collections
In simple statement , Json @ ATP
- A managed cloud service for JSON storage
- More than a simple document store
Oracle Database API for MongoDB
- Direct connections from MongoDB drivers to Oracle Database
- Developers can keep their skills and continue to use MongoDB’s tools, drivers, etc
- Easy migrations of MongoDB workloads to Oracle
- Often minimal code changes required (exception aggregation pipeline)
Assuming, we have few list of MongoDB collections in Oracle object storage Bucket
Use case:
- Let us migrate these collections to Oracle Autonomous database
Step:1/ Create Oracle Autonomous Database workload type as JSON with deployment type as “Shared Infrastructure”
Choose network access access type as “Secure Access from allowed IPs and VCN Only”
further, follow the steps as ATP deployment wizard
For additional reference please refer the link
after provisioning, autonomous database console looks like below
Step:2/ Deploy MongoDB tools @ client m/c or in cloud shell
In this lab, let us, use compute vm as client m/c @ OCI
2.1/ Download mongodb tools
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel70-x86_64-100.5.2.tgz
2.2/ untar it
3/ @ ATP console, Copy Oracle Database API for MongoDB
Go to DB Actions -> Related Services -> Click Copy Oracle Database API for MongoDB endpoint
Go to “Related Services” section
Copy the “Oracle database API” endpoint
Save the URL in your text editor. Close the pop-up windows when done
4/ Set environment variables
4.1/ Export Path for MongoDB binary
Example:
4.2/ Export “Oracle database API” endpoint in variable
Edit and provide appropriate ATP database username with password in the copied endpoint in text editor which we copied.
Example:
mongodb://[xxxxx:xxxxxx]@DIWQIPLGHKB2X0O-ATPJSONDB.adb.ap-mumbai-1.oraclecloudapps.com:27017/[xxxxx]?authMechanism=PLAIN&authSource=$external&ssl=true&retryWrites=false&loadBalanced=true’
Edited as below:
[opc@cvm-postgres-ol7 ~]$
export URI=’mongodb://admin:yourpassword@DIWQIPLGHKB2X0O-ATPJSONDB.adb.ap-mumbai-1.oraclecloudapps.com:27017/admin?authMechanism=PLAIN&authSource=$external&ssl=true&retryWrites=false&loadBalanced=true’
IMPORTANT NOTE: if your password contains any special characters in the set / : ? # [ ] @, you will need to escape them as follows:
Example, if your password is We1com3#123 you would encode it as We1come3%23123.
5/ Import MongoDB collections to Oracle Autonomous Database
Since, mongodb collections are available in object store , copy the object link from Object store as below.
Simply, we will use curl command to read the data from that object and do mongoimport to ATP using endpoint
Example:
curl -s https://objectstorage.ap-mumbai-1.oraclecloud.com/n/sehubjapacprod/b/mongoCollection/o/movies.json mongoimport — collection movies — uri $URI
6/ Check the table/collections in ATP
Note:
If mongdb collections exist in file system, then, we can use ‘cat’ command and do import to ATP
Example:
The significate takeaway from this method is, using Oracle database mongodb API endpoint , we can easily migrate MongoDB collections to Oracle Database.
Additionally, we connect mongodb shell and access the collections which are in ATP, as we do in mongodb cluster
Steps:
1/ Download and untar the mongodb shell at client m/c
[opc@cvm-postgres-ol7 ~]$ wget https://downloads.mongodb.com/compass/mongosh-1.3.1-linux-x64.tgz
2/ Set path and URI ( ATP endpoint) as environment variables
export PATH=”`pwd`/mongosh-1.3.1-linux-x64/bin/:$PATH”
3/ Login to Autonomous database via mongo shell
mongosh $URI
List the collections from mongo shell
Advantage:
if mongodb developers not familiar with oracle Sql, then they can work using mongodb commands with oracle Json collections in mongodb shell.
Conclusion:
Developers can easily migrate mongodb collections to oracle json in ATP and they can retain the convenience of both SQL and mongosh CRUD operations
I acknowledge and thank to Roger Ford and Beda Hammerschmidt , who provided insights of this method.
In next article, let we discuss how SODA API can be used and automated as another method for migration.
Point of Reference:
For further information, please refer link of Roger Blob and video content in my youtube channel
Thanks for your time.