1 Introduction
This document contains all information related to the migration of database Oracle Database Enterprise Edition to Oracle Database Standard Edition.
This document describes:
- The database migration from the current environment EE to SE (using Oracle Data Pump)
1.1 Migration Method
The primary method used for the migration will be by Oracle Data Pump for the following reasons:
- Avoid the necessity of upgrade of the database features from EE to SE.
- This technique also benefits from reorganizing the data inside of datafiles (shrink), releasing unused space (empty blocks), and rejecting the old statistics based on the old environment.
2 Preparation
The following steps should be executed for each source database and its respective target database to allow EXPDP/IMPDP operation.
2.1 On source
Create a user with a DBA role to export the schemas.
create user duts identified by duts; grant dba to duts;
Create a directory used for Datapump.
create directory data_pump_dir_migration as ‘<PATH_ON_SOURCE>’;
For each database, retrieve information for:
- Size of database
- Character set
- NLS Character set
- Applications users to export
- Roles to create
- Profile to create
- Tablespaces to create
- Privileges assigned to roles or applications users
- Special objects like types
- Number of invalid objects group by owner and object type
To retrieve information like tablespaces, particular object creation, we can use the dbms_metadata package and the function get_ddl.
SQL> set long 1000000 longc 16384 lin 3000 trims on hea off pages 0 newp none emb on tab off feed off echo off SQL> exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true) SQL> select dbms_metadata.get_ddl('TABLESPACE','USERS') from dual; CREATE TABLESPACE "USERS" DATAFILE SIZE 5242880 AUTOEXTEND ON NEXT 1310720 MAXSIZE 32767M LOGGING ONLINE PERMANENT BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO; -- GET USER DDL EXEC DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY',TRUE); EXEC DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE); undefine User_in_Uppercase; set linesize 1000 set long 2000000000 select (case when ((select count(*) from dba_users where username = '&&User_in_Uppercase' and profile <> 'DEFAULT') > 0) then chr(10)||' -- Note: Profile'||(select dbms_metadata.get_ddl('PROFILE', u.profile) AS ddl from dba_users u where u.username = '&User_in_Uppercase') else to_clob (chr(10)||' -- Note: Default profile, no need to create!') end ) from dual UNION ALL select (case when ((select count(*) from dba_users where username = '&User_in_Uppercase') > 0) then ' -- Note: Create user statement'||dbms_metadata.get_ddl ('USER', '&User_in_Uppercase') else to_clob (chr(10)||' -- Note: User not found!') end ) Extracted_DDL from dual UNION ALL select (case when ((select count(*) from dba_ts_quotas where username = '&User_in_Uppercase') > 0) then ' -- Note: TBS quota'||dbms_metadata.get_granted_ddl( 'TABLESPACE_QUOTA', '&User_in_Uppercase') else to_clob (chr(10)||' -- Note: No TS Quotas found!') end ) from dual UNION ALL select (case when ((select count(*) from dba_role_privs where grantee = '&User_in_Uppercase') > 0) then ' -- Note: Roles'||dbms_metadata.get_granted_ddl ('ROLE_GRANT', '&User_in_Uppercase') else to_clob (chr(10)||' -- Note: No granted Roles found!') end ) from dual UNION ALL select (case when ((select count(*) from V$PWFILE_USERS where username = '&User_in_Uppercase' and SYSDBA='TRUE') > 0) then ' -- Note: sysdba'||chr(10)||to_clob (' GRANT SYSDBA TO '||'"'||'&User_in_Uppercase'||'"'||';') else to_clob (chr(10)||' -- Note: No sysdba administrative Privilege found!') end ) from dual UNION ALL select (case when ((select count(*) from dba_sys_privs where grantee = '&User_in_Uppercase') > 0) then ' -- Note: System Privileges'||dbms_metadata.get_granted_ddl ('SYSTEM_GRANT', '&User_in_Uppercase') else to_clob (chr(10)||' -- Note: No System Privileges found!') end ) from dual UNION ALL select (case when ((select count(*) from dba_tab_privs where grantee = '&User_in_Uppercase') > 0) then ' -- Note: Object Privileges'||dbms_metadata.get_granted_ddl ('OBJECT_GRANT', '&User_in_Uppercase') else to_clob (chr(10)||' -- Note: No Object Privileges found!') end ) from dual /
With this, it is possible to extract all the objects that the application needs.
2.2 On target
On target, once all information has been extracted for every database to be migrated, we can proceed with the creation of database on SE.
The procedure is as follows
2.2.1 Creation of Listener
Create the listener to support the migration on Grid Infrastructure.
LISTENER_MIG = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = DutsDB)(PORT = 1889)) ) )
2.2.2 Creation of response file
Create the response file to use in dbca silent mode.
############################################################################## ## ## ## DBCA response file ## ## ------------------ ## ## Copyright(c) Oracle Corporation 1998,2017. All rights reserved. ## ## ## ## Specify values for the variables listed below to customize ## ## your installation. ## ## ## ## Each variable is associated with a comment. The comment ## ## can help to populate the variables with the appropriate ## ## values. ## ## ## ## IMPORTANT NOTE: This file contains plain text passwords and ## ## should be secured to have read permission only by oracle user ## ## or db administrator who owns this installation. ## ############################################################################## #------------------------------------------------------------------------------- # Do not change the following system generated value. #------------------------------------------------------------------------------- responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0 #----------------------------------------------------------------------------- # Name : gdbName # Datatype : String # Description : Global database name of the database # Valid values : <db_name>.<db_domain> - when database domain isn't NULL # <db_name> - when database domain is NULL # Default value : None # Mandatory : Yes #----------------------------------------------------------------------------- gdbName=DutsSE #----------------------------------------------------------------------------- # Name : sid # Datatype : String # Description : System identifier (SID) of the database # Valid values : Check Oracle12c Administrator's Guide # Default value : <db_name> specified in GDBNAME # Mandatory : No #----------------------------------------------------------------------------- sid=DutsSE #----------------------------------------------------------------------------- # Name : databaseConfigType # Datatype : String # Description : database conf type as Single Instance, Real Application Cluster or Real Application Cluster One Nodes database # Valid values : SI\RAC\RACONENODE # Default value : SI # Mandatory : No #----------------------------------------------------------------------------- databaseConfigType=SI #----------------------------------------------------------------------------- # Name : RACOneNodeServiceName # Datatype : String # Description : Service is required by application to connect to RAC One # Node Database # Valid values : Service Name # Default value : None # Mandatory : No [required in case DATABASECONFTYPE is set to RACONENODE ] #----------------------------------------------------------------------------- RACOneNodeServiceName= #----------------------------------------------------------------------------- # Name : policyManaged # Datatype : Boolean # Description : Set to true if Database is policy managed and # set to false if Database is admin managed # Valid values : TRUE\FALSE # Default value : FALSE # Mandatory : No #----------------------------------------------------------------------------- policyManaged= #----------------------------------------------------------------------------- # Name : createServerPool # Datatype : Boolean # Description : Set to true if new server pool need to be created for database # if this option is specified then the newly created database # will use this newly created serverpool. # Multiple serverpoolname can not be specified for database # Valid values : TRUE\FALSE # Default value : FALSE # Mandatory : No #----------------------------------------------------------------------------- createServerPool= #----------------------------------------------------------------------------- # Name : serverPoolName # Datatype : String # Description : Only one serverpool name need to be specified # if Create Server Pool option is specified. # Comma-separated list of Serverpool names if db need to use # multiple Server pool # Valid values : ServerPool name # Default value : None # Mandatory : No [required in case of RAC service centric database] #----------------------------------------------------------------------------- serverPoolName= #----------------------------------------------------------------------------- # Name : cardinality # Datatype : Number # Description : Specify Cardinality for create server pool operation # Valid values : any positive Integer value # Default value : Number of qualified nodes on cluster # Mandatory : No [Required when a new serverpool need to be created] #----------------------------------------------------------------------------- cardinality= #----------------------------------------------------------------------------- # Name : force # Datatype : Boolean # Description : Set to true if new server pool need to be created by force # if this option is specified then the newly created serverpool # will be assigned server even if no free servers are available. # This may affect already running database. # This flag can be specified for Admin managed as well as policy managed db. # Valid values : TRUE\FALSE # Default value : FALSE # Mandatory : No #----------------------------------------------------------------------------- force= #----------------------------------------------------------------------------- # Name : pqPoolName # Datatype : String # Description : Only one serverpool name needs to be specified # if create server pool option is specified. # Comma-separated list of serverpool names if use # server pool. This is required to # create Parallel Query (PQ) database. Applicable to Big Cluster # Valid values : Parallel Query (PQ) pool name # Default value : None # Mandatory : No [required in case of RAC service centric database] #----------------------------------------------------------------------------- pqPoolName= #----------------------------------------------------------------------------- # Name : pqCardinality # Datatype : Number # Description : Specify Cardinality for create server pool operation. # Applicable to Big Cluster # Valid values : any positive Integer value # Default value : Number of qualified nodes on cluster # Mandatory : No [Required when a new serverpool need to be created] #----------------------------------------------------------------------------- pqCardinality= #----------------------------------------------------------------------------- # Name : createAsContainerDatabase # Datatype : boolean # Description : flag to create database as container database # Valid values : Check Oracle12c Administrator's Guide # Default value : false # Mandatory : No #----------------------------------------------------------------------------- createAsContainerDatabase=True #----------------------------------------------------------------------------- # Name : numberOfPDBs # Datatype : Number # Description : Specify the number of pdb to be created # Valid values : 0 to 4094 # Default value : 0 # Mandatory : No #----------------------------------------------------------------------------- numberOfPDBs=1 #----------------------------------------------------------------------------- # Name : pdbName # Datatype : String # Description : Specify the pdbname/pdbanme prefix if one or more pdb need to be created # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : No #----------------------------------------------------------------------------- pdbName=DutsSEP #----------------------------------------------------------------------------- # Name : useLocalUndoForPDBs # Datatype : boolean # Description : Flag to create local undo tablespace for all PDB's. # Valid values : TRUE\FALSE # Default value : TRUE # Mandatory : No #----------------------------------------------------------------------------- useLocalUndoForPDBs= #----------------------------------------------------------------------------- # Name : pdbAdminPassword # Datatype : String # Description : PDB Administrator user password # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : No #----------------------------------------------------------------------------- pdbAdminPassword= #----------------------------------------------------------------------------- # Name : nodelist # Datatype : String # Description : Comma-separated list of cluster nodes # Valid values : Cluster node names # Default value : None # Mandatory : No (Yes for RAC database-centric database ) #----------------------------------------------------------------------------- nodelist= #----------------------------------------------------------------------------- # Name : templateName # Datatype : String # Description : Name of the template # Valid values : Template file name # Default value : None # Mandatory : Yes #----------------------------------------------------------------------------- templateName=General_Purpose.dbc #----------------------------------------------------------------------------- # Name : sysPassword # Datatype : String # Description : Password for SYS user # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : Yes #----------------------------------------------------------------------------- sysPassword= #----------------------------------------------------------------------------- # Name : systemPassword # Datatype : String # Description : Password for SYSTEM user # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : Yes #----------------------------------------------------------------------------- systemPassword= #----------------------------------------------------------------------------- # Name : oracleHomeUserPassword # Datatype : String # Description : Password for Windows Service user # Default value : None # Mandatory : If Oracle home is installed with windows service user #----------------------------------------------------------------------------- oracleHomeUserPassword= #----------------------------------------------------------------------------- # Name : emConfiguration # Datatype : String # Description : Enterprise Manager Configuration Type # Valid values : CENTRAL|DBEXPRESS|BOTH|NONE # Default value : NONE # Mandatory : No #----------------------------------------------------------------------------- emConfiguration= #----------------------------------------------------------------------------- # Name : emExpressPort # Datatype : Number # Description : Enterprise Manager Configuration Type # Valid values : Check Oracle12c Administrator's Guide # Default value : NONE # Mandatory : No, will be picked up from DBEXPRESS_HTTPS_PORT env variable # or auto generates a free port between 5500 and 5599 #----------------------------------------------------------------------------- emExpressPort=5500 #----------------------------------------------------------------------------- # Name : runCVUChecks # Datatype : Boolean # Description : Specify whether to run Cluster Verification Utility checks # periodically in Cluster environment # Valid values : TRUE\FALSE # Default value : FALSE # Mandatory : No #----------------------------------------------------------------------------- runCVUChecks= #----------------------------------------------------------------------------- # Name : dbsnmpPassword # Datatype : String # Description : Password for DBSNMP user # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : Yes, if emConfiguration is specified or # the value of runCVUChecks is TRUE #----------------------------------------------------------------------------- dbsnmpPassword= #----------------------------------------------------------------------------- # Name : omsHost # Datatype : String # Description : EM management server host name # Default value : None # Mandatory : Yes, if CENTRAL is specified for emConfiguration #----------------------------------------------------------------------------- omsHost= #----------------------------------------------------------------------------- # Name : omsPort # Datatype : Number # Description : EM management server port number # Default value : None # Mandatory : Yes, if CENTRAL is specified for emConfiguration #----------------------------------------------------------------------------- omsPort= #----------------------------------------------------------------------------- # Name : emUser # Datatype : String # Description : EM Admin username to add or modify targets # Default value : None # Mandatory : Yes, if CENTRAL is specified for emConfiguration #----------------------------------------------------------------------------- emUser= #----------------------------------------------------------------------------- # Name : emPassword # Datatype : String # Description : EM Admin user password # Default value : None # Mandatory : Yes, if CENTRAL is specified for emConfiguration #----------------------------------------------------------------------------- emPassword= #----------------------------------------------------------------------------- # Name : dvConfiguration # Datatype : Boolean # Description : Specify "True" to configure and enable Oracle Database vault # Valid values : True/False # Default value : False # Mandatory : No #----------------------------------------------------------------------------- dvConfiguration= #----------------------------------------------------------------------------- # Name : dvUserName # Datatype : String # Description : DataVault Owner # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : Yes, if DataVault option is chosen #----------------------------------------------------------------------------- dvUserName= #----------------------------------------------------------------------------- # Name : dvUserPassword # Datatype : String # Description : Password for DataVault Owner # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : Yes, if DataVault option is chosen #----------------------------------------------------------------------------- dvUserPassword= #----------------------------------------------------------------------------- # Name : dvAccountManagerName # Datatype : String # Description : DataVault Account Manager # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : No #----------------------------------------------------------------------------- dvAccountManagerName= #----------------------------------------------------------------------------- # Name : dvAccountManagerPassword # Datatype : String # Description : Password for DataVault Account Manager # Valid values : Check Oracle12c Administrator's Guide # Default value : None # Mandatory : No #----------------------------------------------------------------------------- dvAccountManagerPassword= #----------------------------------------------------------------------------- # Name : olsConfiguration # Datatype : Boolean # Description : Specify "True" to configure and enable Oracle Label Security # Valid values : True/False # Default value : False # Mandatory : No #----------------------------------------------------------------------------- olsConfiguration= #----------------------------------------------------------------------------- # Name : datafileJarLocation # Datatype : String # Description : Location of the data file jar # Valid values : Directory containing compressed datafile jar # Default value : None # Mandatory : No #----------------------------------------------------------------------------- datafileJarLocation= #----------------------------------------------------------------------------- # Name : datafileDestination # Datatype : String # Description : Location of the data file's # Valid values : Directory for all the database files # Default value : $ORACLE_BASE/oradata # Mandatory : No #----------------------------------------------------------------------------- datafileDestination=+DATA_DG #----------------------------------------------------------------------------- # Name : recoveryAreaDestination # Datatype : String # Description : Location of the data file's # Valid values : Recovery Area location # Default value : $ORACLE_BASE/flash_recovery_area # Mandatory : No #----------------------------------------------------------------------------- recoveryAreaDestination=+FRA_DG #----------------------------------------------------------------------------- # Name : storageType # Datatype : String # Description : Specifies the storage on which the database is to be created # Valid values : FS (CFS for RAC), ASM # Default value : FS # Mandatory : No #----------------------------------------------------------------------------- storageType=ASM #----------------------------------------------------------------------------- # Name : diskGroupName # Datatype : String # Description : Specifies the disk group name for the storage # Default value : DATA # Mandatory : No #----------------------------------------------------------------------------- diskGroupName=+DATA_DG #----------------------------------------------------------------------------- # Name : asmsnmpPassword # Datatype : String # Description : Password for ASM Monitoring # Default value : None # Mandatory : No #----------------------------------------------------------------------------- asmsnmpPassword= #----------------------------------------------------------------------------- # Name : recoveryGroupName # Datatype : String # Description : Specifies the disk group name for the recovery area # Default value : RECOVERY # Mandatory : No #----------------------------------------------------------------------------- recoveryGroupName=+FRA_DG #----------------------------------------------------------------------------- # Name : characterSet # Datatype : String # Description : Character set of the database # Valid values : Check Oracle12c National Language Support Guide # Default value : "US7ASCII" # Mandatory : NO #----------------------------------------------------------------------------- characterSet=AL32UTF8 #----------------------------------------------------------------------------- # Name : nationalCharacterSet # Datatype : String # Description : National Character set of the database # Valid values : "UTF8" or "AL16UTF16". For details, check Oracle12c National Language Support Guide # Default value : "AL16UTF16" # Mandatory : No #----------------------------------------------------------------------------- nationalCharacterSet=AL16UTF16 #----------------------------------------------------------------------------- # Name : registerWithDirService # Datatype : Boolean # Description : Specifies whether to register with Directory Service. # Valid values : TRUE \ FALSE # Default value : FALSE # Mandatory : No #----------------------------------------------------------------------------- registerWithDirService= #----------------------------------------------------------------------------- # Name : dirServiceUserName # Datatype : String # Description : Specifies the name of the directory service user # Mandatory : YES, if the value of registerWithDirService is TRUE #----------------------------------------------------------------------------- dirServiceUserName= #----------------------------------------------------------------------------- # Name : dirServicePassword # Datatype : String # Description : The password of the directory service user. # You can also specify the password at the command prompt instead of here. # Mandatory : YES, if the value of registerWithDirService is TRUE #----------------------------------------------------------------------------- dirServicePassword= #----------------------------------------------------------------------------- # Name : walletPassword # Datatype : String # Description : The password for wallet to created or modified. # You can also specify the password at the command prompt instead of here. # Mandatory : YES, if the value of registerWithDirService is TRUE #----------------------------------------------------------------------------- walletPassword= #----------------------------------------------------------------------------- # Name : listeners # Datatype : String # Description : Specifies list of listeners to register the database with. # By default the database is configured for all the listeners specified in the # $ORACLE_HOME/network/admin/listener.ora # Valid values : The list should be comma separated like "listener1,listener2". # Mandatory : NO #----------------------------------------------------------------------------- listeners=LISTENER_MIG #----------------------------------------------------------------------------- # Name : variablesFile # Datatype : String # Description : Location of the file containing variable value pair # Valid values : A valid file-system file. The variable value pair format in this file # is <variable>=<value>. Each pair should be in a new line. # Default value : None # Mandatory : NO #----------------------------------------------------------------------------- variablesFile= #----------------------------------------------------------------------------- # Name : variables # Datatype : String # Description : comma separated list of name=value pairs. Overrides variables defined in variablefile and templates # Default value : None # Mandatory : NO #----------------------------------------------------------------------------- variables= #----------------------------------------------------------------------------- # Name : initParams # Datatype : String # Description : comma separated list of name=value pairs. Overrides initialization parameters defined in templates # Default value : None # Mandatory : NO #----------------------------------------------------------------------------- initParams= #----------------------------------------------------------------------------- # Name : sampleSchema # Datatype : Boolean # Description : Specifies whether or not to add the Sample Schemas to your database # Valid values : TRUE \ FALSE # Default value : FASLE # Mandatory : No #----------------------------------------------------------------------------- sampleSchema= #----------------------------------------------------------------------------- # Name : memoryPercentage # Datatype : String # Description : percentage of physical memory for Oracle # Default value : None # Mandatory : NO #----------------------------------------------------------------------------- memoryPercentage= #----------------------------------------------------------------------------- # Name : databaseType # Datatype : String # Description : used for memory distribution when memoryPercentage specified # Valid values : MULTIPURPOSE|DATA_WAREHOUSING|OLTP # Default value : MULTIPURPOSE # Mandatory : NO #----------------------------------------------------------------------------- databaseType=MULTIPURPOSE #----------------------------------------------------------------------------- # Name : automaticMemoryManagement # Datatype : Boolean # Description : flag to indicate Automatic Memory Management is used # Valid values : TRUE/FALSE # Default value : TRUE # Mandatory : NO #----------------------------------------------------------------------------- automaticMemoryManagement= #----------------------------------------------------------------------------- # Name : totalMemory # Datatype : String # Description : total memory in MB to allocate to Oracle # Valid values : # Default value : # Mandatory : NO #----------------------------------------------------------------------------- totalMemory=4096
2.2.3 Creation of database using DBCA in silent mode.
DutsSE
oracle@DutsDB:/u01/app/oracle/product/19.3.0/db_1/assistants/dbca $ export ORACLE_SID=DutsSE oracle@DutsDB:/u01/app/oracle/product/19.3.0/db_1/assistants/dbca $ dbca -silent -createDatabase -responseFile DutsSE.rsp
3 Migration
After finishing the preparation, we can start the migration using Data Pump tools
3.1 On source
The application should be stopped to be sure that there isn’t any modification during the export phase.
Purge the recyclebin from all PDB’s
PURGE RECYCLEBIN; Export is done with: expdp c##duts@DutsEE directory=EXPORT_DATA_PUMP dumpfile=DutsEE.dmp schemas=PILOTO,PILOTO_DATA exclude=statistics logfile=DutsEE_dump.log
3.2 On target
Once the dumpfile is transferred, the import phase can start.
Create the users and tablespaces using the information in chapter 2.1
Create the directory in all PDB’s.
create directory EXPORT_DATA_PUMP as ‘/backup/oracle/dpdump’;
Create the user in all CDB$ROOT database.
CREATE USER c##duts IDENTIFIED BY duts QUOTA UNLIMITED ON users; GRANT dba TO c##duts CONTAINER=ALL; Import is done with:
impdp c##duts@DutsSE directory=EXPORT_DATA_PUMP dumpfile=DutsSE.dmp schemas=PILOTO,PILOTO_DATA logfile=DutsSE_imp.log
Then we can check the invalid objects on the new target and compare them with the objects on the source.
select count(0),object_type,owner from dba_objects where status=’INVALID’ group by object_type,owner;
If the result is >0, then we have to recompile sqlplus /nolog connect / as sysdba @?/rdbms/admin/utlrp.sql After this step, we should have no more invalid objects on target (or the same number as on source).
We can recompute statistics for each schema imported.
sqlplus /nolog connect / as sysdba exec dbms_stats.gather_schema_stats(ownname=>’<USER1>’,estimate_percent=>dbms_stats.auto_sample_size,cascade=>true,method_opt=>’for all columns size auto’);
In case you need to redo the import, the procedure to be followed are:
- Drop user
Example: drop user PILOTO cascade
- Execute the steps in chapter 3.2
Hope this helps you!!!
Disclaimer: “The postings on this site are my own and don’t necessarily represent may actual employer positions, strategies or opinions. The information here was edited to be useful for general purpose, specific data and identifications was removed to allow reach generic audience and to be useful