Introduction
In Oracle Exadata Cloud Service (ExaCS), using dbaascli, one can convert a Non-Container database to a Pluggable Database. Once the database is converted from Non-CDB to PDB, it is plugged into a fresh Container Database created in the same Oracle Home or there is an option to plug the PDB into an existing Container Database.
To illustrate this with an example, let’s first create a Non-CDB database in ExaCS. By default the database created in ExaCS using Oracle Cloud Console is a Container Database.So, to create a Non-CDB database we have to use either dbaasapi or dbaascli.
Create a Non-CDB database using dbaasapi
1. Login to ExaCS Compute VM as opc and sudo as root user.
Create a json file(createdb.json) with following contents, which will be passed to dbaasapi :
{
“object”: “db”,
“action”: “start”,
“operation”: “createdb”,
“params”: {
“nodelist”: “”,
“dbname”: “exadb”,
“db_unique_name”: “exadb”,
“edition”: “EE_EP”,
“version”: “19.0.0.0”,
“ohome_name”: “exadboh”,
“adminPassword”: “<password>”,
“cdb”: “no”,
“charset”: “AL32UTF8”,
“ncharset”: “AL16UTF16”,
“backupDestination”: “NONE”
},
“outputfile”: “/home/oracle/createdb.log”,
“FLAGS”: “”
}
2. Execute dbaasapi and specify the input file, to create the desired Non-CDB database :
# dbaasapi -i /home/oracle/createdb.json
3. Check the logfile that was generated and note the ID :
[root@exa oracle]# cat /home/oracle/createdb.log
{
“object” : “db”,
“recovery” : “”,
“status” : “Starting”,
“workflow_id” : “”,
“dbname” : “”,
“outputfile” : “/home/oracle/createdb.log”,
“workflow_enabled” : “0”,
“pid” : “”,
“id” : “3d89df31-d91f-4fa1-b9c8-c4ddfac41641”, <<– Note this ID
“operation” : “createdb”,
“logfile” : “/var/opt/oracle/log/exadb/dbaasapi/db/createdb/3d89df31-d91f-4fa1-b9c8-c4ddfac41641.log”,
“msg” : “For security please remove your input file.”,
“exceptionErrorCodes” : “”,
“ts” : “20220511 23:33:34”,
“progress” : “0”,
“errmsg” : “”,
“infofile_content” : “”,
“perl_proxy_pid” : “”,
“dgObserverResponseDetails” : “”,
“host” : “”,
“jobSpecificDetailsJson” : “”,
“resourceId” : “”,
“action” : “start”,
“creation” : “”,
“start” : “”
}
4. Create another JSON file to check the database creation status. Replace the ID and the dbname with the values from the previous steps :
[root@exa oracle]# cat /home/oracle/createdbstatus.json
{
“object”: “db”,
“action”: “status”,
“operation”: “createdb”,
“id”: “3d89df31-d91f-4fa1-b9c8-c4ddfac41641”,
“params”: {
“dbname”: “exadb”
},
“outputfile”: “/home/oracle/createdbstatus.log”,
“FLAGS”: “”
}
5. Run the utility with the status file as input and then check the utility output.
[root@exa oracle]# dbaasapi -i /home/oracle/createdbstatus.json
[root@exa oracle]# cat /home/oracle/createdb.out
{
“object” : “db”,
“recovery” : “”,
“status” : “InProgress”,
“workflow_id” : “”,
“dbname” : “exadb”,
“outputfile” : “/home/oracle/createdbstatus.log”,
“workflow_enabled” : “0”,
“pid” : “362827”,
“id” : “3d89df31-d91f-4fa1-b9c8-c4ddfac41641”,
“operation” : “createdb”,
“logfile” : “/var/opt/oracle/log/exadb/dbaasapi/db/createdb/dbaasapi_2022-05-11_11:50:00.119966_359387.log”,
“msg” : “”,
“exceptionErrorCodes” : “”,
“progress” : “0”,
“ts” : “20220511 11:50:02”,
“errmsg” : “”,
“infofile_content” : “”,
“perl_proxy_pid” : “”,
“dgObserverResponseDetails” : “”,
“host” : “exaash-ianaz1”,
“jobSpecificDetailsJson” : “”,
“resourceId” : “”,
“action” : “start”,
“creation” : “1652284202”,
“start” : “”
}
Rerun the status action regularly until the response indicates that the operation succeeded or failed.
6. After the above operation has completed, connect to the Non-Container Database and verify :
SQL> select name,cdb from v$database;
NAME CDB
——— —
EXADB NO
SQL>
Convert Non-CDB database to PDB using dbaascli
Next is to convert this Non-CDB database to a Pluggable Database. We will use dbaascli to convert Non-CDB to PDB/CDB architecture.
To start with let’s check the command line reference :
[root@exa ~]# dbaascli database convertToPDB –help
DBAAS CLI version 22.2.1.0.1
Executing command database convertToPDB –help
database convertToPDB – to convert given non-CDB database to PDB.
Usage: dbaascli database convertToPDB –dbname <value> [–cdbName <value>] [–executePrereqs]
{
[–copyDatafiles [–keepSourceDB]]
| [–backupPrepared]
}
[–targetPDBName <value>] [–waitForCompletion <value>] [–resume [–sessionID <value>]]
Where:
–dbname – Oracle database name.
[–cdbName – to specify the name of the target CDB in which the PDB will be created. If the CDB does not exist, then it will be created in the same Oracle home as the source non CDB. ]
[–executePrereqs – to execute the Pre-Conversion checks only. ]
[–copyDatafiles | –backupPrepared]
[–copyDatafiles – to create a new copy of the datafiles instead of using the ones from the source database.]
[–keepSourceDB – to preserve the source database after completing the operation.]
[–backupPrepared – flag to acknowledge that a proper database backup is in place for the non CDB prior to performing the conversion to PDB.]
[–targetPDBName – to specify the name of the PDB that will be created as part of the operation. ]
[–waitForCompletion – Specify false to run the operation in background. Valid values : true|false.]
[–resume – To resume the previous execution]
[–sessionID – to resume a specific session id.]
[root@exa ~]#
Few important options to consider here are :
–dbname : Non-CDB database name which we intend to convert to PDB.
–cdbName : This will be the name of the target CDB database in which the PDB will be plugged. If the target CDB does not exist, a fresh CDB will be created in the same Oracle Home.
–copyDatafiles : Use this if you want to create a new copy of datafiles instead of using the ones from the source.
–keepSourceDB : Use this to preserve the source database.
1. First execute the command to run Pre-Conversion checks and validate that the database is ready for conversion :
dbaascli database convertToPDB –dbname exadb –copyDatafiles –keepSourceDB –cdbName CONDB –executePrereqs
[root@exa ~]# dbaascli database convertToPDB –dbname exadb –copyDatafiles –keepSourceDB –cdbName CONDB –executePrereqs
DBAAS CLI version 22.2.1.0.1
Executing command database convertToPDB –copyDatafiles –keepSourceDB –cdbName CONDB –executePrereqs
Job id: d3b5297f-8d71-4a1a-9cd3-d4fbe697fa60
Loading PILOT…
Session ID of the current execution is: 153
Log file location: /var/opt/oracle/log/exadb/database/convertToPDB/pilot_2022-05-12_05-50-47-AM
—————–
Running Plugin_initialization job
Completed Plugin_initialization job
—————–
Running Validate_source_db_open_state job
Completed Validate_source_db_open_state job
—————–
Running Validate_source_db_database_type job
Completed Validate_source_db_database_type job
—————–
Running Validate_source_db_version job
Completed Validate_source_db_version job
—————–
Running Validate_rdbms_conversion_packages job
Completed Validate_rdbms_conversion_packages job
—————–
Running Validate_source_db_database_role job
Completed Validate_source_db_database_role job
—————–
Running Validate_source_db_tde_configuration job
Completed Validate_source_db_tde_configuration job
—————–
Running Validate_source_db_credentials job
Completed Validate_source_db_credentials job
—————–
Running Validate_target_pdb_name job
Completed Validate_target_pdb_name job
—————–
Running Validate_dataguard_configuration job
Completed Validate_dataguard_configuration job
—————–
Running Validate_backup_confirmation job
Completed Validate_backup_confirmation job
—————–
Running Validate_new_cdb_creation job
Completed Validate_new_cdb_creation job
dbaascli execution completed
[root@exa ~]#
2. After verifying that all the checks have passed successfully, execute the command to convert the database :
dbaascli database convertToPDB –dbname exadb –copyDatafiles –keepSourceDB –cdbName CONDB
[root@exa ~]# dbaascli database convertToPDB –dbname exadb –copyDatafiles –keepSourceDB –cdbName CONDB
DBAAS CLI version 22.2.1.0.1
Executing command database convertToPDB –copyDatafiles –keepSourceDB –cdbName CONDB
Job id: 1e03332a-7216-4f56-b7b4-9bbe564e0c68
Loading PILOT…
Session ID of the current execution is: 155
Log file location: /var/opt/oracle/log/exadb/database/convertToPDB/pilot_2022-05-12_05-55-17-AM
—————–
Running Plugin_initialization job
Completed Plugin_initialization job
—————–
Running Validate_source_db_open_state job
Completed Validate_source_db_open_state job
—————–
Running Validate_source_db_database_type job
Completed Validate_source_db_database_type job
—————–
Running Validate_source_db_version job
Completed Validate_source_db_version job
—————–
Running Validate_rdbms_conversion_packages job
Completed Validate_rdbms_conversion_packages job
—————–
Running Validate_source_db_database_role job
Completed Validate_source_db_database_role job
—————–
Running Validate_source_db_tde_configuration job
Completed Validate_source_db_tde_configuration job
—————–
Running Validate_source_db_credentials job
Completed Validate_source_db_credentials job
—————–
Running Validate_target_pdb_name job
Completed Validate_target_pdb_name job
—————–
Running Validate_dataguard_configuration job
Completed Validate_dataguard_configuration job
—————–
Running Validate_backup_confirmation job
Completed Validate_backup_confirmation job
—————–
Running Validate_new_cdb_creation job
Completed Validate_new_cdb_creation job
—————–
Running Acquire_source_db_lock job
Completed Acquire_source_db_lock job
—————–
Running Drop_dbaas_profile job
Completed Drop_dbaas_profile job
—————–
Running Create_new_cdb job
Completed Create_new_cdb job
—————–
Running Verify_storage_space_availability job
Completed Verify_storage_space_availability job
—————–
Running Export_source_db_tde_keys job
Completed Export_source_db_tde_keys job
—————–
Running Import_tde_keys_into_target_cdb job
Completed Import_tde_keys_into_target_cdb job
—————–
Running Acquire_target_cdb_lock job
Completed Acquire_target_cdb_lock job
—————–
Running Purge_source_db_recycle_bin job
Completed Purge_source_db_recycle_bin job
—————–
Running Start_source_db_in_read_only job
Completed Start_source_db_in_read_only job
—————–
Running Generate_source_db_metadata_file job
Completed Generate_source_db_metadata_file job
—————–
Running Verify_source_db_plug_compatibility job
Completed Verify_source_db_plug_compatibility job
—————–
Running Shutdown_source_db job
Completed Shutdown_source_db job
—————–
Running Create_new_pdb job
Completed Create_new_pdb job
—————–
Running Execute_source_db_conversion_script job
Completed Execute_source_db_conversion_script job
—————–
Running Open_pdb job
Completed Open_pdb job
—————–
Running Verify_pdb_plug_in_violations job
Completed Verify_pdb_plug_in_violations job
—————–
Running Import_tde_keys_into_new_pdb job
Completed Import_tde_keys_into_new_pdb job
—————–
Running Bounce_pdb job
Completed Bounce_pdb job
—————–
Running Activate_tde_configuration_in_pdb job
Completed Activate_tde_configuration_in_pdb job
—————–
Running Verify_pdb_violations_post_tde_activation job
Completed Verify_pdb_violations_post_tde_activation job
—————–
Running Bounce_pdb_post_tde_activation job
Completed Bounce_pdb_post_tde_activation job
—————–
Running Release_target_cdb_lock job
Completed Release_target_cdb_lock job
—————–
Running Release_source_db_lock job
Completed Release_source_db_lock job
—————–
Running Configure_pdb_open_state job
Completed Configure_pdb_open_state job
—————–
Running Configure_pdb_service job
Completed Configure_pdb_service job
—————–
Running Configure_tnsnames_for_pdb job
Completed Configure_tnsnames_for_pdb job
—————–
Running Update_cloud_registry_for_pdb job
Completed Update_cloud_registry_for_pdb job
—————–
Running Generate_dbsystem_details job
Completed Generate_dbsystem_details job
dbaascli execution completed
[root@exa ~]#
3. Connect to the target CDB and verify the database was converted to PDB :
SQL> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
———- —————————— ———- ———-
2 PDB$SEED READ ONLY NO
3 EXADB READ WRITE NO
