Sunteți pe pagina 1din 82

<Insert Picture Here>

8 ways to move your database to Oracle Cloud


Kamran Aghayev A.
Oracle Certified Master, ACE Director
My country – Azerbaijan
About me

• Database Team Manager at AzerCell Telecom


• Oracle Certified Master
• Oracle ACE Director
• Author of the “OCM 11g Study Guide”
• Author of the “RMAN Backup and Recovery”
• Blogger at http://www.kamranagayev.com
• President of Azerbaijan Oracle User Group (AzerOUG)
OracleVideoTutorials.com
“A picture is worth a thousand words...and a video is worth a
thousand pictures!” - Ankala V Subbarao
The Requisite Room Survey

How many of you already migrated On-Premises


database to Oracle Cloud?

What was the size of the migrated databases?

How much downtime did you have? Few hours?


Minutes? Seconds or no downtime?
Moving On-Premises database to Oracle Cloud

1. Using Data Pump (Schema, Full, Tablespace)

2. Transportable Tablespace migration

3. Transportable tablespace with incremental backup

4. Duplicate database

5. Create a standby database and perform failover

6. ASM to ACFS migration

7. Zero downtime migration with Golden Gate

8. Single instance to RAC


Create database service
Create database service
Create database service
Create database service
Create database service
1. Migrating the database with Data Pump
Migrating the database with Data Pump

Use Data Pump to migrate the database, if:

- the database size is small

- you can easily have a downtime

- you need to move only specific schemas


12c New Feature – Full Transportable Export/Import

Oracle 10g

expdp a/a directory=U01DMP dumpfile=test.dat transportable=always full=y


LRM-00101: unknown parameter name 'transportable'

Oracle 11g

expdp a directory=TRANS_DIR dumpfile=test.dat transportable=always full=y


ORA-39005: inconsistent arguments
ORA-39032: function TRANSPORTABLE is not supported in FULL jobs

Oracle 12c

expdp a/a directory=TRANS_DIR dumpfile=test.dat transportable=always full=y


Dump file set for A.SYS_EXPORT_FULL_01 is:
/u01/app/oracle/product/12.2.0/dbhome_1/test.dat
*****************************************************************************
*
Datafiles required for transportable tablespace USERS:
+DATA/TESTDB/DATAFILE/users.339.958815813
12c New Feature – Full Transportable Export/Import

Create 3 tablespaces :
APP_DATA
HR_DATA
REPORTING_DATA

Create a table for each tablespace


TBL_APP_DATA
TBL_HR_DATA
TBL_REPORTING_DATA

Put all tablespaces to READ ONLY mode, or you will get the following error during export:

ORA-39123: Data Pump transportable tablespace job aborted


ORA-39185: The transportable tablespace failure list is

ORA-29335: tablespace 'APP_DATA' is not read only


ORA-29335: tablespace 'HR_DATA' is not read only
ORA-29335: tablespace 'REPORTING_DATA' is not read only
ORA-29335: tablespace 'USERS' is not read only
12c New Feature – Full Transportable Export/Import

expdp system/oracle directory=ORACLE_BASE dumpfile=exp.dmp


transportable=always
full=y
metrics=y
exclude=statistics

Dump file set for SYSTEM.SYS_EXPORT_FULL_01 is:


/u01/app/oracle/exp.dmp
*****************************************************************
*************
Datafiles required for transportable tablespace APP_DATA:
/u01/app/oracle/oradata/prod/app_data01.dbf
Datafiles required for transportable tablespace HR_DATA:
/u01/app/oracle/oradata/prod/hr_data01.dbf
Datafiles required for transportable tablespace REPORTING_DATA:
/u01/app/oracle/oradata/prod/reporting_data01.dbf
Datafiles required for transportable tablespace USERS:
/u01/app/oracle/oradata/prod/users01.dbf
12c New Feature – Full Transportable Export/Import

expdp system/oracle directory=ORACLE_BASE dumpfile=exp.dmp


transportable=always
full=y
metrics=y
exclude=statistics

Dump file set for SYSTEM.SYS_EXPORT_FULL_01 is:


/u01/app/oracle/exp.dmp
*****************************************************************
*************
Datafiles required for transportable tablespace APP_DATA:
/u01/app/oracle/oradata/prod/app_data01.dbf
Datafiles required for transportable tablespace HR_DATA:
/u01/app/oracle/oradata/prod/hr_data01.dbf
Datafiles required for transportable tablespace REPORTING_DATA:
/u01/app/oracle/oradata/prod/reporting_data01.dbf
Datafiles required for transportable tablespace USERS:
/u01/app/oracle/oradata/prod/users01.dbf
12c New Feature – Full Transportable Export/Import

ORA-39123: Data Pump transportable tablespace job aborted


ORA-29349: tablespace 'USERS' already exists

impdp system/oracle directory=oracle_base dumpfile=exp.dmp


transport_datafiles=
'/u01/app/oracle/oradata/prodnew/datafiles/app_data01.dbf',
'/u01/app/oracle/oradata/prodnew/datafiles/reporting_data01.dbf,
'/u01/app/oracle/oradata/prodnew/datafiles/hr_data01.dbf'
exclude=tablespace:\"in\(\'USERS\'\)\"

ORA-39002: invalid operation


ORA-39352: Wrong number of TRANSPORT_DATAFILES specified:
expected 4, received 3
12c New Feature – Full Transportable Export/Import

expdp system/oracle directory=ORACLE_BASE dumpfile=exp.dmp


transportable=always
full=y
metrics=y
exclude=statistics
exclude=tablespace:\"in\(\'USERS\'\)\“

impdp system/oracle directory=oracle_base dumpfile=exp.dmp


transport_datafiles=
'/u01/app/oracle/oradata/prodnew/datafiles/app_data01.dbf',
'/u01/app/oracle/oradata/prodnew/datafiles/reporting_data01.dbf',
'/u01/app/oracle/oradata/prodnew/datafiles/hr_data01.dbf'
12c New Feature – Full Transportable Export/Import

SQL> select segment_name, bytes, tablespace_name from


dba_segments where segment_name like '%DATA';

SEGMENT_NAME BYTES TABLESPACE_NAME


------------------- ---------- ------------------------------
TBL_APP_DATA 12582912 APP_DATA
TBL_HR_DATA 12582912 HR_DATA
TBL_REPORTING_DATA 12582912 REPORTING_DATA
2. Transportable databases, tablespaces
Transportable tablespaces

Check Platform Endian Format

SQL> select d.name,d.PLATFORM_NAME,tp.ENDIAN_FORMAT


2 FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d
3 WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME;

NAME PLATFORM_NAME ENDIAN_FORMAT


--------- --------------------------------------------- --------------
ORLBCP01 Linux x86 64-bit Little

Tablespace self-contained check

SQL> exec dbms_tts.transport_set_check('APPDATA',TRUE);


PL/SQL procedure successfully completed.

SQL> select * from transport_set_violations;


no rows selected

SQL>
Transportable tablespaces

Keep Source Tablespace in READ-ONLY mode


SQL> alter tablespace APPDATA READ ONLY;

Generate Metadata export of Transportable Tablespace

[oracle@mybcp ~]$ expdp directory=DATA_PUMP_DIR dumpfile=tbs_appdata_meta.dmp


logfile=tbs_appdata_meta.log TRANSPORT_TABLESPACES=APPDATA TRANSPORT_FULL_CHECK=Y

Copy Datafiles and Export Dump File to Cloud host

Take out Source Tablespace from READ-ONLY mode

SQL> alter tablespace APPDATA READ WRITE;


Transportable tablespaces

Convert datafile on Target server


RMAN> CONVERT DATAFILE '[datafile_name_1]','[datafile_name_2]',...[datafile_name_n]
TO PLATFORM="Target_Platform" FROM PLATFORM="Source_Platform"

Import Transportable Tablespace metadata on Target Database

impdp directory=DATA_PUMP_DIR dumpfile=tbs_appdata_meta.dmp


logfile=imptbs_appdata_meta.log TRANSPORT_DATAFILES='/data/orlsol/orlsol/appdata01'
Transportable tablespaces – Best Practices

Perform the datafile conversion on the system with better I/O

Run datafile conversions in parallel. Use all nodes in RAC environment

Perform the datafile transfer and datafile conversion simultaneously

Set network parameters for optimal transfer capacity

Resize datafiles to HWM before the transfer

Compress datafiles transfered


Cross Platform Database Conversion

Cross-platform transportable database can only be performed between


platforms that have the same endian format

Put the database in READ ONLY mode:


ALTER DATABASE OPEN READ ONLY;

Execute the DBMS_TDB.CHECK_DB function:

DECLARE
db_ready BOOLEAN;
BEGIN
db_ready :=
DBMS_TDB.CHECK_DB('Microsoft Windows IA (32-bit)',
DBMS_TDB.SKIP_READONLY);
END;
/
Cross Platform Database Conversion

RMAN> CONVERT DATABASE


NEW DATABASE ‘PRODDB’
TRANSPORT SCRIPT '/home/oracle/trans.sql'
TO PLATFORM 'Microsoft Windows IA (32-bit)'
DB_FILE_NAME_CONVERT ‘/home/oracle/oradata' '/home/proddb';

Move converted datafiles to the Cloud host

Run transport script to create a new database based on the converted files:
SQL> @trans.sql
3. Cross Platform Transportable tablespace
with incremental backups
Transportable tablespace with incremental backup

Oracle Cloud Machine


HP-UX IA (64-bit)
OEL 7.4
Full Incremental level 0 backup
SYSTEM
SYSAUX
Transfer it to cloud machine and /home/oracle/
UNDO restore using RMAN tbs_migration01.dbf
TEMP
TBS_MIGRATION

Incremental level 1 backup

Transfer it to cloud machine and


recover using RMAN
Transportable tablespace with incremental backup

Oracle Cloud Machine


HP-UX IA (64-bit)
Put the tablespace into READ ONLY OEL 7.4
mode
SYSTEM
SYSAUX Take last Incremental level 1 backup
/home/oracle/
UNDO tbs_migration01.dbf
TEMP Export metadata of tablespace using
Data Pump
TBS_MIGRATION

Transfer backup and dump file to the cloud


machine, recover the backup and import
the dump file

11G - Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 1389592.1)
12C - Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 2005729.1)
Transportable tablespace with incremental backup

CREATE TABLESPACE tbs_migrate DATAFILE


'/home/oracle/app/oradata/PRODDB/tbs_migrate01.dbf' SIZE 30M;

CREATE TABLE mytable01 TABLESPACE tbs_migrate AS SELECT *


FROM dba_objects WHERE ROWNUM < 100;

BACKUP incremental LEVEL 0 format


'/home/oracle/backup/TBS_INC0_%U.bkp' TABLESPACE tbs_migrate;

INSERT INTO mytable01 SELECT * FROM mytable01;

BACKUP incremental LEVEL 1 format


'/home/oracle/backup/TBS_INC1_%U.bkp' TABLESPACE tbs_migrate;

Move backups to the cloud machine


Transportable tablespace with incremental backup

RESTORE FROM platform 'HP-UX IA (64-bit)' FOREIGN DATAFILE 5 format


'/home/oracle/backup/datafile05.dbf' FROM backupset
'/home/oracle/backup/TBS_INC0_0jsj4i97_1_1.bkp'

RECOVER from platform 'HP-UX IA (64-bit)' foreign datafilecopy


'/home/oracle/backup/datafile05.dbf'
FROM backupset '/home/oracle/backup/TBS_INC1_0lsj4ias_1_1.bkp';

ALTER TABLESPACE tbs_migrate READ ONLY; (source DB)


BACKUP incremental LEVEL 1 format
'/home/oracle/backup/TBS_INC1_2_%U.bkp' TABLESPACE tbs_migrate;
expdp \"/ as sysdba\" DIRECTORY=ORACLE_BASE DUMPFILE=exp.dmp
LOGFILE=EXP.LOG TRANSPORT_TABLESPACES=tbs_migrate

Move last incremental backup and dump file to the cloud machine
Transportable tablespace with incremental backup

ALTER TABLESPACE tbs_migrate READ WRITE;


RECOVER from platform 'HP-UX IA (64-bit)' foreign datafilecopy
'/home/oracle/backup/datafile05.dbf'
FROM backupset '/home/oracle/backup/TBS_INC1_2_0nsj4ieq_1_1.bkp';

impdp \"/ as sysdba\" DIRECTORY=ORACLE_BASE DUMPFILE=exp.dmp


TRANSPORT_DATAFILES='/home/oracle/backup/datafile05.dbf'

SQL> select tablespace_name, status from dba_tablespaces where


tablespace_name='TBS_MIGRATE';

TABLESPACE_NAME STATUS
-------------------- ---------
TBS_MIGRATE ONLINE
Transportable tablespace with incremental backup

rman_xttconvert_v3.zip

Phase 1 - Initial Setup phase


Phase 2 - Prepare phase
Phase 3 - Roll Forward phase
Phase 4 - Final Incremental Backup
Phase 5 - Transport Phase: Import Metadata
Phase 6 - Validate the Transported Data
Phase 7 - Cleanup

12C - Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup
(Doc ID 2005729.1)
Transportable tablespace with incremental backup

[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl –backup

[oracle@source]$ scp /backupformat/* oracle@dest:/stageondest

[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl –restore

[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl –bkpinc

[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl –recover

system@source/prod SQL> alter tablespace TS1 read only;

[oracle@source]$ scp /backupformat/* oracle@dest:/stageondest

[oracle@source]$ scp /backupformat/* oracle@dest:/stageondest

[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --resincrdmp

Edit and run xttplugin.txt to import the metadata of tablespaces


Perform Cross-Platform Database Transport to different Endian Platform
with RMAN Backup Sets (Oracle 12c new feature)
Perform Cross-Platform Database Transport to different Endian
Platform with RMAN Backup Sets (Oracle 12c new feature)

A cross-platform backup is an RMAN backup that can be restored on a destination platform


that is different from the source platform

Solaris[tm] OE (64-bit) Put the tablespace to READ ONLY mode Linux IA (64-bit)
Big endian Little endian

SYSTEM Take tablespace backup and metadata


SYSAUX dump file with single command
/home/oracle/
UNDO tbs_migration01.dbf
TEMP Transfer backupsets to the destination
TBS_MIGRATION server

Restore RMAN and Data Pump backupsets using


single command
Perform Cross-Platform Database Transport to different Endian
Platform with RMAN Backup Sets (Oracle 12c new feature)

RMAN> ALTER TABLESPACE test1 READ ONLY;

RMAN> BACKUP
TO PLATFORM 'Linux x86 64-bit'
FORMAT '/tmp/xplat_backups/trans_ts.bck'
DATAPUMP FORMAT '/tmp/xplat_backups/trans_ts_dmp.bck'
TABLESPACE test1;

RMAN> RESTORE
FOREIGN TABLESPACE TEST1 to NEW
FROM BACKUPSET '/u01/app/oracle/oradata/test/trans_ts.bck'
DUMP FILE FROM BACKUPSET
'/u01/app/oracle/oradata/test/trans_ts_dmp.bck';
Perform Cross-Platform Database Transport to different Endian
Platform with RMAN Backup Sets (Oracle 12c new feature)

ALLOW INCONSISTENT

The first inconsistent backup is a level 0 incremental backup. Subsequently, you can create
multiple cross-platform level 1 incremental backups. The final cross-platform incremental backup
must be a consistent backup that is created when the tablespaces are read-only. When you
create this final incremental backup, use the DUMP FILE clause in the BACKUP command to
create the dump file containing the tablespace metadata.
Perform Cross-Platform Database Transport to different Endian
Platform with RMAN Backup Sets (Oracle 12c new feature)

RMAN> BACKUP FOR TRANSPORT ALLOW INCONSISTENT INCREMENTAL LEVEL 0 TABLESPACE


mytbsnew FORMAT '/home/oracle/backup/FULL_backup_%U.bkp';

Move to the Cloud Machine and restore

RMAN> RESTORE FOREIGN DATAFILE 5 FORMAT '/home/oracle/backup/datafile05.dbf'


FROM BACKUPSET '/home/oracle/backup/FULL_backup_0jsk94cs_1_1.bkp';

RMAN> BACKUP FOR TRANSPORT ALLOW INCONSISTENT INCREMENTAL LEVEL 1 TABLESPACE


mytbsnew FORMAT '/home/oracle/backup/INC1_backup_%U.bkp';

Move to the Cloud Machine and restore

RMAN> RECOVER FOREIGN DATAFILECOPY '/home/oracle/backup/datafile05.dbf' FROM


BACKUPSET '/home/oracle/backup/INC1_0ksk94g6_1_1.bkp';
Perform Cross-Platform Database Transport to different Endian
Platform with RMAN Backup Sets (Oracle 12c new feature)

SQL> ALTER TABLESPACE mytbsnew READ ONLY;

BACKUP FOR TRANSPORT INCREMENTAL LEVEL 1 TABLESPACE mytbsnew FORMAT


'/home/oracle/backup/INC2_%U.bkp'
DATAPUMP FORMAT '/home/oracle/backup/DP.dp'
DESTINATION '/home/oracle/backup';

Move incremental backup and dump file to the Cloud Machine and restore

RMAN> RESTORE FOREIGN DATAFILE 5 FORMAT '/home/oracle/backup/datafile05.dbf'


FROM BACKUPSET '/home/oracle/backup/FULL_backup_0jsk94cs_1_1.bkp';

RMAN> RESTORE DUMP FILE 'new.dp' DATAPUMP DESTINATION '/home/oracle/backup'


FROM BACKUPSET '/home/oracle/backup/DP.dp';

[oracle@oratest03 ~]$ impdp \"/ as sysdba\" DIRECTORY=mydir DUMPFILE=new.dp


TRANSPORT_DATAFILES='/home/oracle/backup/datafile05.dbf' NOLOGFILE=Y
4. Duplicate On-Premise database to Cloud
Duplicate On-Premise database to Cloud

Perform a disaster recovery of On-Premise database to Oracle Cloud

- Using backups transferred to the cloud machine


- Using backups stored in Oracle Public Cloud Storage

Perform Active Database Duplication of On-Premise database to Oracle Cloud


Perform a disaster recovery of On-Premise database to Oracle Cloud

- Backup the On-Premise database

BACKUP FORMAT ‘/backup/PROD_%U.bkp’ DATABASE


PLUS ARCHIVELOG FORMAT ‘/backup/ARCH_%U.bkp’;

- Copy backups to the Oracle Cloud server

- Configure network parameter files in both On-Premise and


Cloud hosts and start listeners
Perform a disaster recovery of On-Premise database to Oracle Cloud

- Create init.ora file in Oracle Cloud server and start instance


in NOMOUNT mode

- db_name
- db_block_size
- Instance_name
- control_files
- db_file_name_convert
- log_file_name_convert
- undo_management
- undo_tablespace

SQL> STARTUP NOMOUNT


Perform a disaster recovery of On-Premise database to Oracle Cloud

From Cloud database connect to the both instances and duplicate the database:

[oracle@clouddb ~] rman target sys/pass@PROD auxiliary /

RMAN> DUPLICATE TARGET DATABASE TO newprod;


Perform a disaster recovery of On-Premise database to Oracle
Cloud using backups stored in Oracle Public Cloud Storage

- Download and install Oracle Database Cloud Backup Module from the
following link:

http://www.oracle.com/technetwork/database/availability/oracle-cloud-
backup-2162729.html
Perform a disaster recovery of On-Premise database to Oracle
Cloud using backups stored in Oracle Public Cloud Storage

Create folder to store wallets and lib file, extract the zip file and install it:

[oracle@ocm11g ~]$ mkdir wallet lib


[oracle@ocm11g tmp]$ java -jar opc_install.jar -serviceName Storage
-identityDomain yourIdentityDomain -opcID YourOpcId -opcPass
YourOpcPassword -walletDir /home/oracle/wallet -libDir
/home/oracle/lib

Oracle Database Cloud Backup Module Install Tool, build 2016-10-07


Oracle Database Cloud Backup Module credentials are valid.
Oracle Database Cloud Backup Module wallet created in directory
/home/oracle/wallet.
Oracle Database Cloud Backup Module initialization file
/u03/oracle/product/11.2.4/db_1/dbs/opcPROD.ora created.

Download complete.
[oracle@ocm11g tmp]$
Perform a disaster recovery of On-Premise database to Oracle
Cloud using backups stored in Oracle Public Cloud Storage

Configure the channel to use SBT library which enable to store backups to
the cloud

RMAN> CONFIGURE CHANNEL DEVICE TYPE ‘SBT_TAPE’


PARMS ‘SBT_LIBRARY=/home/oracle/lib/libopc.so
ENV=(OPC_PFILE=/u03/oracle/product/11.2.4/db_1/dbs/opcPROD.ora)’;

RMAN> CONFIGURE COMPRESSION ALGORITHM ‘HIGH’;


RMAN> CONFIGURE DEFAULT DEVICE TYPE TO ‘SBT_TAPE’;
RMAN> SET ENCRYPTION ON IDENTIFIED BY “mypass” ONLY;

RMAN> BACKUP DATABASE PLUS ARCHIVELOG;


piece handle=18rs8bk6_1_1 tag=TAG20170210T175726 comment=API Version
2.0,MMS Version 3.16.9.21

RMAN>
Perform a disaster recovery of On-Premise database to Oracle
Cloud using backups stored in Oracle Public Cloud Storage

Create a new cloud instance, drop the database, configure SSH, download and
install Cloud Backup Module and clone the database

RMAN> STARTUP NOMOUNT;


RMAN> SET DECRYPTION IDENTIFIED BY “mypass”;

RMAN> run
{
ALLOCATE CHANNEL t1 TYPE ‘SBT_TAPE’
PARMS ‘SBT_LIBRARY=/home/oracle/lib/libopc.so
ENV=(OPC_PFILE=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/opcPROD.ora)’;
SET DBID=345613202;
RESTORE SPFILE TO PFILE ‘/tmp/pfile.ora’ FROM AUTOBACKUP;
STARTUP NOMOUNT FORCE;
RESTORE CONTROLFILE FROM AUTOBACKUP;
SET NEWNAME FOR DATABASE TO ‘/u04/app/oracle/oradata/datafile_%t.dbf’;
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
}
Perform Active Database Duplication of On-Premise database to
Oracle Cloud

Create parameter file in the Cloud host, start instance in NOMOUNT mode

Configure network parameters and password file in both On-Premise and Cloud host

Connect to target and auxiliary instances:

rman target / auxiliary sys/pass@AUX

DUPLICATE TARGET DATABASE


TO 'TEST'
FROM ACTIVE DATABASE
DB_FILE_NAME_CONVERT ‘/u01/oradata/PROD',‘/u03/PROD';
5. Create a standby database and perform failover
Migrate On-Premise database to Oracle Cloud using
Standby database

- Create a service to run RMAN on allocated instances in the cluster:

srvctl add service –db PRODDB-service srv_rman -preferred


PRODDB1,PRODDB2

srvctl start service -db PRODDB -service srv_rman

- When running RMAN, use the service name in the connect string for the “target”
parameter.

rman target sys/<password>@<prim_scan>/srv_rman


Migrate On-Premise database to Oracle Cloud using
Standby database

- Create standby redo logs on the primary database

SQL> alter database add standby logfile thread 1


group 7 ('+REDO') size 512M,
group 8 ('+REDO') size 512M,
group 9 ('+REDO') size 512M,
group 10 ('+REDO')size 512M;

SQL> alter database add standby logfile thread 2


group 11 ('+REDO') size 512M,
group 12 ('+REDO') size 512M,
group 13 ('+REDO') size 512M,
group 14 ('+REDO') size 512M;

- Enable force logging

SQL> alter database force logging;


Migrate On-Premise database to Oracle Cloud using
Standby database

- Create network files in both side

- Create password file and parameter file in the Standby side and start the instance in
NOMOUNT mode

- If the cluster_interconnects parameter is set on the primary it will be necessary to


temporarily unset it in the SPFILE only

SQL> show parameter cluster_interconnects

SQL> alter system reset cluster_interconnects scope=spfile sid=‘PRODDB1';


SQL> alter system reset cluster_interconnects scope=spfile sid=‘PRODDB2;
Migrate On-Premise database to Oracle Cloud using
Standby database

RMAN> connect target sys/<password>@<prim_scan>/srv_rman;


RMAN> connect auxiliary sys/<password>@dup;
RMAN> run {
duplicate target database for standby from active database
spfile
parameter_value_convert ‘PRODDB',‘NEWPROD'
set db_unique_name=‘NEWPROD'
SET CLUSTER_DATABASE='FALSE'
set control_files='+DATA/NEWPROD/standby.ctl'
set local_listener=’NEWPROD_LOCAL_LISTENER’
set remote_listener=’stby-scan:1521’
set audit_file_dest='/u01/app/oracle/admin/newprod/adump'
}

Reset CLUSTER_INTERCONNECTS to original value


Migrate On-Premise database to Oracle Cloud using
Standby database

If the standby database is at Version 12.1 or higher copy the password file to ASM.
For Example:

$asmcmd -p
ASMCMD [+] > cd +DATA
AMSCMD [+DATA] >mkdir NEWPROD/PASSWORD
ASMCMD [+DATA] >pwcopy
/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/orapwnewprod1
+DATA/NEWPROD/PASSWORD/pwnewprod
ASMCMD [+DATA] > exit
Migrate On-Premise database to Oracle Cloud using
Standby database

- Create the standby spfile in ASM.

SQL> create pfile='/tmp/pfile.ora' from spfile;


SQL> create spfile='+DATA/NEWPROD/spfilenweprod.ora' from
pfile='/tmp/pfile.ora'

On standby host create an initnewprod1.ora file that points to the spfile created in the
above step and start the instance in MOUNT mode

$cat initnewprod1.ora
spfile='+DATA/NEWPROD/spfilenewprod

SQL> shut immediate;


SQL> startup mount;
Migrate On-Premise database to Oracle Cloud using
Standby database

srvctl add database -db NEWPROD -oraclehome


/u01/app/oracle/product/12.2.0.1/dbhome_1 -node newprod1 –

srvctl add instance -db NEWPROD -instance newprod1 -node


newprodhost1

srvctl add instance -db NEWPROD -instance newprod2 -node


newprodhost2

srvctl modify database -db NEWPROD -role physical_standby -spfile


'+DATA/NEWPROD/spfilenewprod.ora' -pwfile
'+DATA/NEWPROD/PASSWORD/pwnewprod‘

srvctl start database -d NEWPROD -o mount


Migrate On-Premise database to Oracle Cloud using
Standby database

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION


SHUTDOWN;

SQL> ALTER DATABASE OPEN;


6. ASM to Non-ASM conversion
ASM to Non-ASM conversion

To create an Oracle RAC database in Database Cloud Service, make the following choices in
the Create Service wizard

Cluster size – Oracle RAC database in DBaaS is limited to a 2 node cluster

Cloud Tooling – raccli utility for backup, recovery, patch apply and administrative tasks

Network access – all ports except 22 are disabled. Port 22 is open for paswordless, key-based SSH
access by opc user

Database file storage – storage for database files, controlfiles and redo log files is created and
managed using ASM and ACFS
ASM to Non-ASM conversion
Cloud Machine

RMAN Backup
+DATA/system01.dbf
+DATA/users01.dbf
+DATA/redo01.log

Generate rename script from On-Premise database


set newname for datafile 1 to /u02/oradata/system01.dbf';
sql "alter database rename file '‘+DATA/redo1_1.log'' to ''/u02/oradata/redo1_1.log'' ";
ASM to Non-ASM conversion
Cloud Machine

RMAN Backup
/u02/system01.dbf
/u02/users01.dbf
/u02/redo01.log

Generate rename script from On-Premise database


SELECT SUBSTR(name, INSTR(name,'/', 1, 5)+1) from v$datafile;

set newname for datafile 1 to /u02/oradata/system01.dbf';


sql "alter database rename file '‘+DATA/redo1_1.log'' to ''/u02/oradata/redo1_1.log'' ";

Restore RMAN backup to the Cloud Machine


Switch datafile all
Recover database;
ALTER DATABASE OPEN RESETLOGS;
7. Migrate database using Golden Gate replication
Migrate database using GoldenGate replication

Golden Gate is used to extract and replicate data from on database to another

Unidirectional Bidirectional
Migrate database using GoldenGate replication

Peer-to-Peer Broadcast
Migrate database using GoldenGate replication

Consolidation Cascading
Migrate database using GoldenGate replication

Download and extract the zip file

Set GGHOME and LD_LIBRARY_PATH environment variables

Execute ggsci script and create subdirectories

cd $GGHOME
./ggsci
GGSCI> create subdirs

Connect to the source database and disable recycle bin. Make sure the database is running in
archivelog mode.

SQL> alter system set recyclebin=off scope=spfile;


SQL> startup force;
Migrate database using GoldenGate replication

Create a user, new tablespace and grant necessary privileges

CREATE TABLESPACE myggs datafile ‘/u01/oradata/myggs01.dbf’ size 100m;


CREATE USER ggadmin identified by ggadmin default tablespace myggs;
GRANT DBA TO ggadmin;

Increase the value of UNDO_RETENTION parameter

SQL> alter database add supplemental log data;

Execute the following scripts to create required objects for the golden gate
SQL> @marker_setup.sql
SQL> @ddl_setup.sql
SQL> @role_setup.sql
SQL> GRANT ggs_ggsuser_role to ggadmin;
SQL> @ddl_enable.sql
SQL> @ddl_pin.sql
Migrate database using GoldenGate replication

./ggsci
GGSCI> dblogin userid ggadmin password ggadmin
GGSCI> add trandata hr.mytable01;

Create a manager parameter file and add the default port number
PORT 7809

GGSCI> start mgr

GGSCI> add extract ext01,tranlog,begin now

GGSCI> add extractrail /u01/goldengate/dirdat/lo,extract ext01

GGSCI> add extract dpump,exttrailsource /u01/goldengate/dirdat/lt

GGSCI> add rmttrail /u01/goldengate/dirdat/rt

GGSCI> edit param ext1


EXTRACT EXT1
userid ggadmin, password ggadmin
exttrail
Migrate database using GoldenGate replication

GGSCI> edit param dpump

EXTRACT DPUMP
Userid ggadmin,password ggadmin
RMTHOST target01.test.com,mgrport 7809
rmttrail /u01/goldengate/dirdat/rt
TABLE hr.mytable01;

GGSCI> add checkpointtable ggadmin.chkpttbl


GGSCI> add replicat rep1,exttrail
/u01/goldengate/dirdat/rt,checkpointtable ggadmin.chkpttbl
GGSCI> edit param rep1

REPLICAT REP1
userid ggadmin,password ggadmin
ASSUMETARGETDEFS
MAP hr.mytable01, TARGET hr.mytable01;

GGSCI> start rep1


8. Migrating single instance On-Premises database
to 2 node RAC in Oracle Cloud
Converting single instance On-Premises to RAC in Cloud
Converting single instance On-Premises to RAC in Cloud

Estimate size of production db

- Create an empty RAC db in the cloud with pre-defined storage size


or
- Add necessary storage to the compute node afterwards

Create a password file using orapwd


Create init.ora file with default parameters:

- db_name
- db_block_size
- Instance_name
- control_files
- db_file_name_convert
- log_file_name_convert
- undo_management
- undo_tablespace
Converting single instance On-Premises to RAC in Cloud

Configure network parameters in both machines and start the instance in the cloud
host in NOMOUNT mode

Take backup of On-Premises database using RMAN and move them to Cloud machine

RMAN> BACKUP DATABASE ‘/backup/full_backup%d_t%t_s%s_p%p.rmn’ plus


archivleog all delete input format ‘/backup/arch_%d_t%t_s%s_p%p.rmn’;

Connect to auxiliary instance (first node of the cloud machine)

RMAN> RUN {
SET NEWNAME FOR DATAFILE 1 TO ‘/u01/oradata/user01.dbf’;
DUPLICATE TARGET DATABASE TO proddb
pfile=‘/tmp/pfile.ora’ logfile
group 1 (‘/u01/oradata/redo/redo01.log’) size 50m reuse,
group 1 (‘/u01/oradata/redo/redo02.log’) size 50m reuse
}
Converting single instance On-Premises to RAC in Cloud

SQL> alter system set instance_number=2 scope=spfile sid=’orcl2′;

SQL> alter system set thread=2 scope=spfile sid=’orcl2′;

SQL> create undo tablespace UNDOTBS2 datafile ‘/u01/oradata/undotbs02.dbf


size 500M;

SQL> alter database add logfile thread 2 group 3 ‘/u01/oradata/redo03.log


size 50m reuse;

SQL> alter database add logfile thread 2 group 4 ‘/u01/oradata/redo04.log


size 50m reuse;

SQL> alter database enable thread 2;

SQL> alter system set cluster_database_instances=2 scope=spfile;


SQL> alter system set cluster_database=true scope=spfile;
SQL> alter system set undo_tablespace=’UNDOTBS2′ scope=spfile sid=’orcl2′;
Register the RAC instances with CRS

srvctl add database -d PRODDB –o /u01/oracle/product/12.2/db_home


srvctl add instance -d PRODDB -i PRODDB1 -n oranode1
srvctl add instance -d PRODDB -i PRODDB2 –n oranode2

srvctl status database -d ONSUBS


Instance PRODDB1 is running on node oranode1
Instance PRODDB2 is running on node oranode2
Final approach to On-Premise migration to
Oracle Cloud
Final Approach to the Cloud migration

Data Pump Export/Import


- Platform, version independence - Requires downtime
- No extra managing skills - Good for small databases
- No downtime required for upgrade

Transportable tablespace
- Faster than Data Pump - Requires partly downtime
- Platform, version must be same
- Extra conversion required for Cross
Platform migration

Transportable tablespace with incrementally updated backup


- Minimal downtime - Requires extra administration skills
- Only required tablespaces might be - Downtime required for upgrade
migrated, instead of whole database - Extra conversion required for Cross
Platform migration
Final Approach to the Cloud migration

Duplicate database, Data Guard


- Minimal downtime (ACTIVE DUPLICATION) Platform, version must be same
- Better than TTS when the whole database Extra conversion required for Cross Platform
migration is required migration
Endian format must be same

Golden Gate Replication


- Near Zero downtime - Requires extra administration skills
- Platform, version independence
Questions?

Thank you!
http://www.kamranagayev.com
http://www.ocmguide.com
http://www.oraclevideotutorials.com

S-ar putea să vă placă și