In this post I will walk you trough the steps to migrate a database Oracle 12.1.0.2.0 running in Windows 7 to AWS EC2 running Linux CentOS release 6.9 using Oracle Data Guard 12c
The below diagram shows a Dataguard architecture of replication sending the redo streams trough a SSH Tunnel from the Primary Database (source db) to the Standby Database (target db) in AWS EC2.
Current Environment
SOURCE
TARGET
Operating System
Microsoft Windows 7 Enterprise Edition 64 bits
CentOS release 6.9 64 bits
Database
Oracle 12.1.0.2.0 (64 bits)
Oracle 12.1.0.2.0 (64 bits)
Database Name
SRCDB
SRCDB
DB_UNIQUE_NAME
SRCDB
SRCCL
Oracle Home
C:\app\oracle\product\12.1.0\dbhome_1
/u03/app/oracle/product/12.1.0/dbhome_1
Local IP Database server
192.168.2.199
171.0.24.109
Listener Port
1521
1521
Requirements
We are going to migrate Oracle database from Windows 7.0 to Linux CentOS release 6.9 .
Oracle Data Guard 12c supports Heterogeneous Primary and Physical Standby in same Data Guard configuration between some Operating Systems. We checked the documentation of Oracle and could confirm that Oracle Windows 7 (64 bits) and CentOS release 6.9 (64 bits) are compatible operating systems and is possible replicate Oracle databases using Data Guard 12c.
Steps to migrate on-premises Oracle database to AWS EC2
1. Configure a SSH Tunnel using Putty. 2. Install Oracle software in AWS EC2 instance. 3. Configure the Source Database. 4. Configure Oracle Net Services configuration files in the Source Database (Windows). 5. Configure Oracle Net Services configuration files in the Target Database (Linux). 6. Create a Oracle password file in the Source Database (Windows) and copy in the Target Database server (Linux). 7. Create the initialization parameter in the Target Database (Linux). 8. Duplicate the Source database to the Target Database. 9. Verify Data Guard is working correctly. 10. Switchover database converting the Target Database in the new Primary database. 11. Remove Oracle Data Guard configuration from the new primary database (Target Database).
a. Download Oracle Database 12c Release 1 (12.1.0.2.0) from Oracle Website
b. Copy the zip files linuxamd64_12c_database_1of2.zip and linuxamd64_12c_database_2of2.zip in a stage directory , unzip them and install Oracle 12c software.
3. Configure the Source Database.
a. Configure database in archivelog and force logging
shutdown immediate
startup mount
alter database archivelog;
alter database force logging;
alter database open;
SQL> select name, log_mode, force_logging from v$database;
NAME LOG_MODE FORCE_LOGGING
--------- ------------ ---------------------------------------
SRCDB ARCHIVELOG YES
b. Get how many redo log groups there are in the Source database and create the same amount plus one of standby redo log groups. In our lab we have 3 redo log groups and we are going to create four standby redo logs with the same size.
alter database add standby logfile 'C:\U01\APP\ORACLE\ORADATA\SRCDB\STBLOG1.LOG' size 100M;
alter database add standby logfile 'C:\U01\APP\ORACLE\ORADATA\SRCDB\STBLOG2.LOG' size 100M;
alter database add standby logfile 'C:\U01\APP\ORACLE\ORADATA\SRCDB\STBLOG3.LOG' size 100M;
alter database add standby logfile 'C:\U01\APP\ORACLE\ORADATA\SRCDB\STBLOG4.LOG' size 100M;
c. Set the initialization parameters related to Data Guard configuration.
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(SRCDB,SRCCL)' scope=both;
alter system set LOG_ARCHIVE_DEST_1= 'LOCATION=USE_db_recovery_file_dest VALID_FOR=(ALL_LOGFILES,ALL_ROLES)'
alter system set LOG_ARCHIVE_DEST_2= 'SERVICE=SRCCL ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SRCCL'
alter system set fal_client=SRCDB scope=both;
alter system set fal_server=SRCCL scope=both;
alter system set standby_file_management=auto scope=both;
4. Configure Oracle Net Services configuration files on the Source Database (Windows).
a. Configure listener.ora file on the Source Database Server.
C:\Windows\system32>set ORACLE_SID=SRCDB
C:\Windows\system32>lsnrctl start listener
LSNRCTL for 64-bit Windows: Version 12.1.0.2.0 - Production on 04-MAY-2020 10:17:47
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Starting tnslsnr: please wait...
TNSLSNR for 64-bit Windows: Version 12.1.0.2.0 - Production
System parameter file is c:\app\oracle\product\12.1.0\dbhome_1\network\admin\listener.ora
Log messages written to c:\app\oracle\diag\tnslsnr\DELL-PC\listener\alert\log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.199)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.199)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias listener
Version TNSLSNR for 64-bit Windows: Version 12.1.0.2.0 - Production
Start Date 04-MAY-2020 10:17:52
Uptime 0 days 0 hr. 0 min. 8 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File c:\app\oracle\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File c:\app\oracle\diag\tnslsnr\DELL-PC\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.199)(PORT=1521)))
Services Summary...
Service "SRCDB" has 1 instance(s).
Instance "SRCDB", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
c. Configure tnsnames.ora on the Source Database Server.
[oracle@parrot admin]$ lsnrctl start listener
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 04-MAY-2020 11:44:18
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Starting /u03/app/oracle/product/12.1.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.1.0.2.0 - Production
System parameter file is /u03/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Log messages written to /u03/app/oracle/diag/tnslsnr/parrot/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=171.0.24.109)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=171.0.24.109)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias listener
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 04-MAY-2020 11:44:18
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u03/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /u03/app/oracle/diag/tnslsnr/parrot/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=171.0.24.109)(PORT=1521)))
Services Summary...
Service "SRCCL" has 1 instance(s).
Instance "SRCCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
c. Configure tnsnames.ora on the Target Database Server .
b. Transfer the password file orapwSRCDB.ora to the Target Database server (Linux) , you can use Filezilla to transfer files to AWS EC2 using SFTP.
transfer the file C:\app\oracle\product\12.1.0\dbhome_1\database>orapwSRCDB.ora (Windows)
to the directory /u03/app/oracle/product/12.1.0/dbhome_1/dbs (Linux)
c. On the Target Database Server (Linux) rename the password file orapwSRCDB.ora to orapwSRCCL.ora
[oracle@parrot dbs]$ cd /u03/app/oracle/product/12.1.0/dbhome_1/dbs
[oracle@parrot dbs]$ mv orapwSRCDB.ora orapwSRCCL.ora
7. Create the initialization parameter in the Target Database (EC2 Linux).
[oracle@parrot dbs]$ cd /u03/app/oracle/product/12.1.0/dbhome_1/dbs
[oracle@parrot dbs]$ echo db_name=SRCDB>initSRCCL.ora
8. Duplicate the Source database to the Target Database Server (EC2 Linux)
a. Start the instance on the Target Database Server (Linux)
[oracle@parrot dbs]$ cd /u03/app/oracle/product/12.1.0/dbhome_1/dbs
[oracle@parrot dbs]$ export ORACLE_SID=SRCCL
[oracle@parrot dbs]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Mon May 4 12:44:37 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 402653184 bytes
Fixed Size 2924928 bytes
Variable Size 167775872 bytes
Database Buffers 226492416 bytes
Redo Buffers 5459968 bytes
SQL>
b. In the Source Database Server (Windows) connect to Rman to target database (SRCDB) and auxiliary instance (SRCCL) and duplicate the database from Windows to AWS EC2.
The database SRCDB is small database of 2 Gb and the duplication took approximately 17 minutes.
C:\app\oracle\product\12.1.0\dbhome_1\database>rman target sys/oracle@SRCDB auxiliary sys/oracle@SRCCL
Recovery Manager: Release 12.1.0.2.0 - Production on Sun May 3 04:16:00 2020
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: SRCDB (DBID=668223670)
connected to auxiliary database: SRCDB (not mounted)
RMAN> DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE
2> DORECOVER
3> SPFILE
4> set db_unique_name='SRCCL'
5> set diagnostic_dest='/u01/app/oracle'
6> set db_create_file_dest='/u02/app/oracle/oradata'
7> set db_recovery_file_dest_size='100G'
8> set audit_file_dest='/u01/app/oracle/admin/SRCCL/adump'
9> set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
10> set LOG_ARCHIVE_CONFIG='DG_CONFIG=(SRCDB,SRCCL)'
11> set log_archive_max_processes='5'
12> SET LOG_ARCHIVE_DEST_2='service=SRCDB ASYNC REGISTER VALID_FOR=(online_logfile,primary_role) db_unique_name=SRCD
B'
13> set control_files='/u01/app/oracle/oradata/SRCCL/control01.ctl', '/u01/app/oracle/fast_recovery_area/SRCCL/contr
ol02.ctl'
14> set STANDBY_FILE_MANAGEMENT='AUTO'
15> SET FAL_CLIENT='SRCCL'
16> SET FAL_SERVER='SRCDB'
17> nofilenamecheck;
Starting Duplicate Db at 03-MAY-20
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=23 device type=DISK
current log archived
contents of Memory Script:
{
backup as copy reuse
targetfile 'c:\app\oracle\product\12.1.0\dbhome_1\DATABASE\PWDsrcdb.ORA' auxiliary format
'/u03/app/oracle/product/12.1.0/dbhome_1/dbs/orapwSRCCL' ;
restore clone from service 'SRCDB' spfile to
'/u03/app/oracle/product/12.1.0/dbhome_1/dbs/spfileSRCCL.ora';
sql clone "alter system set spfile= ''/u03/app/oracle/product/12.1.0/dbhome_1/dbs/spfileSRCCL.ora''";
}
executing Memory Script
Starting backup at 03-MAY-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=407 device type=DISK
Finished backup at 03-MAY-20
Starting restore at 03-MAY-20
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: restoring SPFILE
output file name=/u03/app/oracle/product/12.1.0/dbhome_1/dbs/spfileSRCCL.ora
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 03-MAY-20
sql statement: alter system set spfile= ''/u03/app/oracle/product/12.1.0/dbhome_1/dbs/spfileSRCCL.ora''
contents of Memory Script:
{
sql clone "alter system set db_unique_name =
''SRCCL'' comment=
'''' scope=spfile";
sql clone "alter system set diagnostic_dest =
''/u01/app/oracle'' comment=
'''' scope=spfile";
sql clone "alter system set db_create_file_dest =
''/u02/app/oracle/oradata'' comment=
'''' scope=spfile";
sql clone "alter system set db_recovery_file_dest_size =
100G comment=
'''' scope=spfile";
sql clone "alter system set audit_file_dest =
''/u01/app/oracle/admin/SRCCL/adump'' comment=
'''' scope=spfile";
sql clone "alter system set db_recovery_file_dest =
''/u01/app/oracle/fast_recovery_area'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_ARCHIVE_CONFIG =
''DG_CONFIG=(SRCDB,SRCCL)'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_max_processes =
5 comment=
'''' scope=spfile";
sql clone "alter system set LOG_ARCHIVE_DEST_2 =
''service=SRCDB ASYNC REGISTER VALID_FOR=(online_logfile,primary_role) db_unique_name=SRCDB'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''/u01/app/oracle/oradata/SRCCL/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/SRCCL/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set STANDBY_FILE_MANAGEMENT =
''AUTO'' comment=
'''' scope=spfile";
sql clone "alter system set FAL_CLIENT =
''SRCCL'' comment=
'''' scope=spfile";
sql clone "alter system set FAL_SERVER =
''SRCDB'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_unique_name = ''SRCCL'' comment= '''' scope=spfile
sql statement: alter system set diagnostic_dest = ''/u01/app/oracle'' comment= '''' scope=spfile
sql statement: alter system set db_create_file_dest = ''/u02/app/oracle/oradata'' comment= '''' scope=spfile
sql statement: alter system set db_recovery_file_dest_size = 100G comment= '''' scope=spfile
sql statement: alter system set audit_file_dest = ''/u01/app/oracle/admin/SRCCL/adump'' comment= '''' scope=spfile
sql statement: alter system set db_recovery_file_dest = ''/u01/app/oracle/fast_recovery_area'' comment= '''' scope=spfile
sql statement: alter system set LOG_ARCHIVE_CONFIG = ''DG_CONFIG=(SRCDB,SRCCL)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_max_processes = 5 comment= '''' scope=spfile
sql statement: alter system set LOG_ARCHIVE_DEST_2 = ''service=SRCDB ASYNC REGISTER VALID_FOR=(online_logfile,primary_role) db_unique_name=SRCDB'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/u01/app/oracle/oradata/SRCCL/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/SRCCL/control02.ctl'' comment= '''' scope=spfile
sql statement: alter system set STANDBY_FILE_MANAGEMENT = ''AUTO'' comment= '''' scope=spfile
sql statement: alter system set FAL_CLIENT = ''SRCCL'' comment= '''' scope=spfile
sql statement: alter system set FAL_SERVER = ''SRCDB'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 402653184 bytes
Fixed Size 2924928 bytes
Variable Size 171970176 bytes
Database Buffers 222298112 bytes
Redo Buffers 5459968 bytes
contents of Memory Script:
{
restore clone from service 'SRCDB' standby controlfile;
}
executing Memory Script
Starting restore at 03-MAY-20
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=22 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:28
output file name=/u01/app/oracle/oradata/SRCCL/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/SRCCL/control02.ctl
Finished restore at 03-MAY-20
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script:
{
set newname for clone tempfile 1 to new;
switch clone tempfile all;
set newname for clone datafile 1 to new;
set newname for clone datafile 2 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 4 to new;
restore
from service 'SRCDB' clone database
;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u02/app/oracle/oradata/SRCCL/datafile/o1_mf_tempts1_%u_.tmp in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 03-MAY-20
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u02/app/oracle/oradata/SRCCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:06:33
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u02/app/oracle/oradata/SRCCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:07:34
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u02/app/oracle/oradata/SRCCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u02/app/oracle/oradata/SRCCL/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:47
Finished restore at 03-MAY-20
sql statement: alter system archive log current
current log archived
contents of Memory Script:
{
restore clone force from service 'SRCDB'
archivelog from scn 1403453;
switch clone datafile all;
}
executing Memory Script
Starting restore at 03-MAY-20
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=435
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:05
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service SRCDB
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=436
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 03-MAY-20
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=1039408449 file name=/u02/app/oracle/oradata/SRCCL/datafile/o1_mf_system_hbwzkd1s_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=1039408449 file name=/u02/app/oracle/oradata/SRCCL/datafile/o1_mf_sysaux_hbwzxp6s_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=1039408449 file name=/u02/app/oracle/oradata/SRCCL/datafile/o1_mf_undotbs1_hbx0cwys_.d
bf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=1039408449 file name=/u02/app/oracle/oradata/SRCCL/datafile/o1_mf_users_hbx0ddtg_.dbf
contents of Memory Script:
{
set until scn 1404246;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 03-MAY-20
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 435 is already on disk as file /u01/app/oracle/fast_recovery_area/SRCCL/archivel
og/2020_05_03/o1_mf_1_435_hbx0hv41_.arc
archived log for thread 1 with sequence 436 is already on disk as file /u01/app/oracle/fast_recovery_area/SRCCL/archivel
og/2020_05_03/o1_mf_1_436_hbx0hzg3_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/SRCCL/archivelog/2020_05_03/o1_mf_1_435_hbx0hv41_.arc thread=1
sequence=435
archived log file name=/u01/app/oracle/fast_recovery_area/SRCCL/archivelog/2020_05_03/o1_mf_1_436_hbx0hzg3_.arc thread=1
sequence=436
media recovery complete, elapsed time: 00:00:01
Finished recover at 03-MAY-20
Finished Duplicate Db at 03-MAY-20
RMAN>
9. Verify Data Guard is working correctly sending and applying archivelogs in the Target Database (EC2 Linux)
a. In the Source Database (Windows) issue the command switch log files several times to generates archivelogs and send them to Target Server to be applied.
SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> alter system switch logfile;
a. Run the below query in the Source and Target databases to verify the Standby Database (Target) in Linux is applying the archive log.
SQL> set lines 100 pages 1000
SQL> select * from
(select sequence#, applied, archived from v$archived_log
where resetlogs_time =
(select max(RESETLOGS_TIME) from v$archived_log) order by sequence# desc
)
where rownum < 11
order by 1;
10. Switchover database converting the Target Database in the new Primary database.
a. Verify the Source Database (Primary Database) can switch to Standby Database role.
Run the below query on the Database SRCDB (Windows) to make sure that return the value “TO STANDBY”
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO STANDBY
b. Execute a switchover in the Source Database (Windows), shutdown it and start it again in mount state.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
Database altered.
SQL> SHUTDOWN ABORT;
ORACLE instance shut down.
SQL> CONN / AS SYSDBA
Connected to an idle instance.
SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area 402653184 bytes
Fixed Size 3046176 bytes
Variable Size 171967712 bytes
Database Buffers 222298112 bytes
Redo Buffers 5341184 bytes
Database mounted.
c. Verify the Source Database (Windows) now has a Physical Standby role.
SQL> select name, db_unique_name,database_role from v$database;
NAME DB_UNIQUE_NAME DATABASE_ROLE
--------- ------------------------------ ----------------
SRCDB SRCDB PHYSICAL STANDBY
d. Verify the Target Database (Primary Database) can switch to Primary Database role.
Run the below query on the Database SRCCL (Linux) to make sure that return the value “TO PRIMARY”
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
e. Execute a switchover in the Target Database (EC2 Linux) and open it.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.
SQL> ALTER DATABASE OPEN;
Database altered.
f. Verify the Target Database (Linux) now has a Primary role.
SQL> select name, db_unique_name,database_role from v$database;
NAME DB_UNIQUE_NAME DATABASE_ROLE
--------- ------------------------------ ----------------
SRCDB SRCCL PRIMARY
11. Remove Oracle Data Guard configuration from the new primary database (Target Database)running in AWS EC2 LINUX
a. Remove below parameters from spfile of Target Database (New Primary Database)
SQL> alter system reset LOG_ARCHIVE_CONFIG scope=spfile;
SQL> alter system reset STANDBY_FILE_MANAGEMENT scope=spfile;
SQL> alter system reset FAL_SERVER scope=spfile;
SQL> alter system reset FAL_CLIENT scope=spfile;
SQL> alter system reset LOG_ARCHIVE_DEST_2 scope=spfile;
b. Drop all standby log files from Target Database (New Primary Database)
alter database drop standby logfile group 4;
alter database drop standby logfile group 5;
alter database drop standby logfile group 6;
alter database drop standby logfile group 7;
c. Restart the Target Database (New Primary Database)
May 2 2020
Migrate on-premises Oracle 12c running in Windows to AWS EC2 Linux using Oracle Data Guard and SSH tunel
In this post I will walk you trough the steps to migrate a database Oracle 12.1.0.2.0 running in Windows 7 to AWS EC2 running Linux CentOS release 6.9 using Oracle Data Guard 12c
The below diagram shows a Dataguard architecture of replication sending the redo streams trough a SSH Tunnel from the Primary Database (source db) to the Standby Database (target db) in AWS EC2.
Current Environment
Requirements
We are going to migrate Oracle database from Windows 7.0 to Linux CentOS release 6.9 .
Oracle Data Guard 12c supports Heterogeneous Primary and Physical Standby in same Data Guard configuration between some Operating Systems.
We checked the documentation of Oracle and could confirm that Oracle Windows 7 (64 bits) and CentOS release 6.9 (64 bits) are compatible operating systems and is possible replicate Oracle databases using Data Guard 12c.
Steps to migrate on-premises Oracle database to AWS EC2
2. Install Oracle software in AWS EC2 instance.
3. Configure the Source Database.
4. Configure Oracle Net Services configuration files in the Source Database (Windows).
5. Configure Oracle Net Services configuration files in the Target Database (Linux).
6. Create a Oracle password file in the Source Database (Windows) and copy in the Target Database server (Linux).
7. Create the initialization parameter in the Target Database (Linux).
8. Duplicate the Source database to the Target Database.
9. Verify Data Guard is working correctly.
10. Switchover database converting the Target Database in the new Primary database.
11. Remove Oracle Data Guard configuration from the new primary database (Target Database).
1. Configure a SSH Tunnel using Putty.
Configure a SSH Tunnel using Putty to connect to a AWS EC2 instance.
2. Install Oracle software in AWS EC2 instance.
a. Download Oracle Database 12c Release 1 (12.1.0.2.0) from Oracle Website
b. Copy the zip files linuxamd64_12c_database_1of2.zip and linuxamd64_12c_database_2of2.zip in a stage directory , unzip them and install Oracle 12c software.
3. Configure the Source Database.
a. Configure database in archivelog and force logging
b. Get how many redo log groups there are in the Source database and create the same amount plus one of standby redo log groups. In our lab we have 3 redo log groups and we are going to create four standby redo logs with the same size.
c. Set the initialization parameters related to Data Guard configuration.
4. Configure Oracle Net Services configuration files on the Source Database (Windows).
a. Configure listener.ora file on the Source Database Server.
b. Start the listener.
c. Configure tnsnames.ora on the Source Database Server.
5. Configure Oracle Net Services configuration files in the Target Database (EC2 Linux).
a. Configure listener.ora file on the Target Database Server
b. Start the listener.
c. Configure tnsnames.ora on the Target Database Server .
6. Create a Oracle password file in the Source Database (Windows) and copy it to the Target Database server (EC2 Linux).
a. Create oracle password file orapwSRCDB.ora in the Source Database server (Windows)
b. Transfer the password file orapwSRCDB.ora to the Target Database server (Linux) , you can use Filezilla to transfer files to AWS EC2 using SFTP.
c. On the Target Database Server (Linux) rename the password file orapwSRCDB.ora to orapwSRCCL.ora
7. Create the initialization parameter in the Target Database (EC2 Linux).
8. Duplicate the Source database to the Target Database Server (EC2 Linux)
a. Start the instance on the Target Database Server (Linux)
b. In the Source Database Server (Windows) connect to Rman to target database (SRCDB) and auxiliary instance (SRCCL) and duplicate the database from Windows to AWS EC2.
The database SRCDB is small database of 2 Gb and the duplication took approximately 17 minutes.
9. Verify Data Guard is working correctly sending and applying archivelogs in the Target Database (EC2 Linux)
a. In the Source Database (Windows) issue the command switch log files several times to generates archivelogs and send them to Target Server to be applied.
a. Run the below query in the Source and Target databases to verify the Standby Database (Target) in Linux is applying the archive log.
10. Switchover database converting the Target Database in the new Primary database.
a. Verify the Source Database (Primary Database) can switch to Standby Database role.
Run the below query on the Database SRCDB (Windows) to make sure that return the value “TO STANDBY”
b. Execute a switchover in the Source Database (Windows), shutdown it and start it again in mount state.
c. Verify the Source Database (Windows) now has a Physical Standby role.
d. Verify the Target Database (Primary Database) can switch to Primary Database role.
Run the below query on the Database SRCCL (Linux) to make sure that return the value “TO PRIMARY”
e. Execute a switchover in the Target Database (EC2 Linux) and open it.
f. Verify the Target Database (Linux) now has a Primary role.
11. Remove Oracle Data Guard configuration from the new primary database (Target Database) running in AWS EC2 LINUX
a. Remove below parameters from spfile of Target Database (New Primary Database)
b. Drop all standby log files from Target Database (New Primary Database)
c. Restart the Target Database (New Primary Database)
By DBA_JAF • Amazon Web Services (AWS), Cloud, Data Guard, Databases, Migration, Oracle, Replication • 0