Monday 30 July 2018

Step by Step Physical Standby database configuration in 12C.


This document describes how to configure Physical Standby database in 12C

Assumptions:


  • Two servers (Physical or VMs)
  • One Server(Primary) having oracle software and database installed and is running
  • Second server(Standby) having only oracle binaries (software) installed.

Primary database setup:

Step 1: Check database is running in archivelog mode. If not enable it. Please click Here to find how to change database mode from noarchivelog to Archivelog.


SQL> select log_mode from v$database;

LOG_MODE
------------
ARCHIVELOG
SQL> archive log list
Database log mode        Archive Mode
Automatic archival        Enabled
Archive destination        USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     11
Next log sequence to archive   13
Current log sequence        13

Step 2: Enable force logging by issuing below command.

SQL> select name,force_logging from v$database;

NAME           FORCE_LOGGING
---------            ---------------------------------------
PRIMARY        NO

SQL> alter database force logging;

Database altered.

SQL> select name,force_logging from v$database;

NAME         FORCE_LOGGING
---------           ---------------------------------------
PRIMARY      YES

Step 3: Verify the parameters db_name and db_unique_name in primary database. In my case both db_name and db_unique_name are same. I.e., PRIMARY

SQL> show parameter db_name

NAME              TYPE      VALUE
------------------------------------   -----------    ------------------------------
db_name             string       PRIMARY

SQL> show parameter db_unique_name

NAME             TYPE      VALUE
------------------------------------   -----------    ------------------------------
db_unique_name      string        PRIMARY

Step 4: Configure log_archive_config parameter in primary database.

SQL> alter system set log_archive_config='DG_CONFIG=(PRIMARY,STANDBY)';

System altered.

SQL> show parameter log_archive_config

NAME            TYPE          VALUE
------------------------------------ -----------        ------------------------------
log_archive_config          string           DG_CONFIG=(PRIMARY,STANDBY)

Step 5: Configure log_archive_dest_2 parameter in primary database. This refers to standby database archive location. In my case it is at flash recovery area in standby database.

SQL> alter system set log_archive_dest_2='service=STANDBY noaffirm async valid_for=(online_logfiles,primary_role) db_unique_name=STANDBY';

System altered.

SQL> show parameter LOG_ARCHIVE_DEST_2

NAME           TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2            string service=STANDBY noaffirm async
                 valid_for=(online_logfiles,pr
                 imary_role) db_unique_name=STA
                 NDBY


Step 6: Set below parameters in primary database to configure physical standby.

SQL> alter system set log_archive_format='%t_%s_%r.arc' scope=spfile;

System altered.

SQL> show parameter log_archive_format

NAME           TYPE    VALUE
------------------------------------ -----------   ------------------------------
log_archive_format      string    %t_%s_%r.dbf

SQL> alter system set log_archive_max_processes=30;

System altered.

SQL> show parameter log_archive_max_processes

NAME               TYPE VALUE
------------------------------------      -----------    ------------------------------
log_archive_max_processes       integer 30


SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;

System altered.

SQL> show parameter remote_login_passwordfile

NAME             TYPE      VALUE
------------------------------------   -----------   ------------------------------
remote_login_passwordfile      string      EXCLUSIVE

SQL> alter system set fal_server=STANDBY;

System altered.

SQL> show parameter fal_server

NAME                TYPE       VALUE
------------------------------------     ----------- ------------------------------
fal_server              string       STANDBY

SQL> alter system set fal_client=PRIMARY;

System altered.

SQL> show parameter fal_client;

NAME             TYPE       VALUE
------------------------------------    -----------   ------------------------------
fal_client                      string       PRIMARY

SQL> alter system set standby_file_management=auto;

System altered.

SQL> show parameter standby_file_management

NAME             TYPE       VALUE
------------------------------------    -----------    ------------------------------
standby_file_management      string        AUTO

Step 7: Bounce the database.

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 1560281088 bytes
Fixed Size     2924784 bytes
Variable Size   939527952 bytes
Database Buffers   603979776 bytes
Redo Buffers    13848576 bytes
Database mounted.
Database opened.

Step 8: Add standby database tns details in tnsnames.ora file of Primary database and make sure that tnsping is happening fine.

TNS entry in Primary database:

tnsnames.ora file location: $ORACLE_HOME/network/admin

[oracle@primary admin]$ cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

PRIMARY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = primary.apps.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PRIMARY.apps.com)
    )
  )

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = standby.apps.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = STANDBY.apps.com)
    )
  )

[oracle@primary admin]$ tnsping primary

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 30-JUL-2018 09:45:27

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = primary.apps.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PRIMARY.apps.com)))
OK (0 msec)

[oracle@primary admin]$ tnsping standby

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 30-JUL-2018 09:45:31

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = standby.apps.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = STANDBY.apps.com)))
OK (0 msec)

Step 9: Create standby control file in Primary database.

SQL> alter database create standby controlfile as '/u02/backup/stndycntrl01.ctl';

Database altered.

Step 10: Create pfile from spfile.

SQL> create pfile='/u02/backup/initPRIMARY' from spfile;

File created.

Step 11: Modify the above created pfile and copy it to standby database.

*.db_unique_name='STANDBY'
*.fal_server='PRIMARY'
*.log_archive_dest_2='service=PRIMARY noaffirm async valid_for=(online_logfiles,primary_role) db_unique_name=PRIMARY'

[oracle@primary backup]$ scp initPRIMARY.ora oracle@standby.apps.com:/u01/app/oracle/product/12.1.0/dbhome_1/dbs
The authenticity of host 'standby.apps.com (192.168.1.160)' can't be established.
RSA key fingerprint is 15:9d:9e:42:c1:97:45:2b:82:53:b1:45:84:27:6c:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'standby.apps.com,192.168.1.160' (RSA) to the list of known hosts.
oracle@standby.apps.com's password: 
initPRIMARY.ora                                                                                           

Step 12: Create  directory structure in standby location as per pfile(init.STANDBY.ora).

[oracle@standby dbs]$ mkdir -p /u01/app/oracle/admin/PRIMARY/adump
[oracle@standby dbs]$ mkdir -p /u02/oradata/PRIMARY
[oracle@standby dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area

Step 13: Copy above standby control file to standby server as per pfile.

[oracle@primary backup]$ [oracle@primary backup]$ pwd
/u02/backup
[oracle@primary backup]$ scp stndycntrl01.ctl oracle@standby.apps.com:/u02/oradata/PRIMARY/control01.ctl
oracle@standby.apps.com's password: 
stndycntrl01.ctl                                                                                                                                                                                           100% 9808KB   9.6MB/s   00:00    
[oracle@primary backup]$ scp stndycntrl01.ctl oracle@standby.apps.com:/u01/app/oracle/fast_recovery_area/PRIMARY/control02.ctl
oracle@standby.apps.com's password: 
stndycntrl01.ctl                                                                                                                                                                                           100% 9808KB   9.6MB/s   00:00    
[oracle@primary backup]$ 
Step 14: Copy password file to standby location.

[oracle@primary dbs]$ pwd
/u01/app/oracle/product/12.1.0/dbhome_1/dbs

[oracle@primary dbs]$ ls -ltr orapwPRIMARY 
-rw-r-----. 1 oracle dba 7680 May 27 20:06 orapwPRIMARY

[oracle@primary dbs]$ scp orapwPRIMARY oracle@standby.apps.com:/u01/app/oracle/product/12.1.0/dbhome_1/dbs
oracle@standby.apps.com's password: 
orapwPRIMARY                                                                                                                                                                                               100% 7680     7.5KB/s   00:00    
[oracle@primary dbs]$ 

Step 15: Backup primary database with archive logs.

[oracle@primary ~]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Mon Jul 30 10:13:49 2018

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PRIMARY (DBID=1814738684)

RMAN> backup database plus archivelogs;

Step 16: Copy backup from Primary database location to Standby database location. 

[oracle@primary PRIMARY]$ pwd
/u01/app/oracle/fast_recovery_area

[oracle@primary fast_recovery_area]$ scp -r PRIMARY oracle@standby.apps.com:/u01/app/oracle/fast_recovery_area

Step 17: Add below environment related parameters in .bash_profile

[oracle@standby ~]$ vi .bash_profile

export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_SID=PRIMARY
PATH=$PATH:$HOME/binz:/u01/app/oracle/product/12.1.0/dbhome_1/bin

Step 18: listener.ora and tnsnames.ora files entries in standby database.

Listener:

[oracle@standby admin]$ pwd
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin

[oracle@standby admin]$ cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = standby.apps.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

TNS:

[oracle@standby admin]$ cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = standby.apps.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = STANDBY.apps.com)
    )
  )

PRIMARY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = primary.apps.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PRIMARY.apps.com)
    )
  )

Step 19: Start the database in mount stage.

[oracle@standby ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Mon Jul 30 11:29:23 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 1560281088 bytes
Fixed Size     2924784 bytes
Variable Size   939527952 bytes
Database Buffers   603979776 bytes
Redo Buffers    13848576 bytes
Database mounted.

Step 20: Create spfile from pfile.

SQL> create spfile from pfile;

File created.

Step 21: Stat the listener in standby database.

[oracle@standby ~]$ lsnrctl start

Step 22: Catalog the copied backup.

RMAN> catalog start with '/u01/app/oracle/fast_recovery_area/PRIMARY';

searching for all files that match the pattern /u01/app/oracle/fast_recovery_area/PRIMARY

List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_ncsnf_TAG20180730T101524_fox61w05_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_annnn_TAG20180730T101653_fox61xtj_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_nnndf_TAG20180730T101524_fox5z5pk_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_annnn_TAG20180730T101458_fox5ycg5_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_18/o1_mf_1_14_flgb0jr2_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_19_fox35yh4_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_18_fowtgf3v_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_21_fox61x7r_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_20_fox5y8yy_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_27/o1_mf_1_16_fm637d94_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_17/o1_mf_1_13_flcpb4xc_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_01/o1_mf_1_11_fk33mo7l_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_01/o1_mf_1_12_fk33o5qf_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_01/o1_mf_1_10_fk33krqy_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_28/o1_mf_1_17_fmb8dsc4_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_21/o1_mf_1_15_flqrlc5l_.arc

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_ncsnf_TAG20180730T101524_fox61w05_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_annnn_TAG20180730T101653_fox61xtj_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_nnndf_TAG20180730T101524_fox5z5pk_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_annnn_TAG20180730T101458_fox5ycg5_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_18/o1_mf_1_14_flgb0jr2_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_19_fox35yh4_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_18_fowtgf3v_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_21_fox61x7r_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_07_30/o1_mf_1_20_fox5y8yy_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_27/o1_mf_1_16_fm637d94_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_17/o1_mf_1_13_flcpb4xc_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_01/o1_mf_1_11_fk33mo7l_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_01/o1_mf_1_12_fk33o5qf_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_01/o1_mf_1_10_fk33krqy_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_28/o1_mf_1_17_fmb8dsc4_.arc
File Name: /u01/app/oracle/fast_recovery_area/PRIMARY/archivelog/2018_06_21/o1_mf_1_15_flqrlc5l_.arc

Step 22: Restore and Recover the database.

RMAN> restore database;

Starting restore at 30-JUL-18
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u02/oradata/PRIMARY/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u02/oradata/PRIMARY/test01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u02/oradata/PRIMARY/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u02/oradata/PRIMARY/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u02/oradata/PRIMARY/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u02/oradata/PRIMARY/users01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u02/oradata/PRIMARY/test02.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_nnndf_TAG20180730T101524_fox5z5pk_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/PRIMARY/backupset/2018_07_30/o1_mf_nnndf_TAG20180730T101524_fox5z5pk_.bkp tag=TAG20180730T101524
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 30-JUL-18

RMAN> recover database;

Starting recover at 30-JUL-18
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 20 is already on disk as file /u01/app/oracle/fast_recovery_area/STANDBY/archivelog/2018_07_30/o1_mf_1_20_foxbbq2s_.arc
archived log for thread 1 with sequence 21 is already on disk as file /u01/app/oracle/fast_recovery_area/STANDBY/archivelog/2018_07_30/o1_mf_1_21_foxbbq0b_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/STANDBY/archivelog/2018_07_30/o1_mf_1_20_foxbbq2s_.arc thread=1 sequence=20
archived log file name=/u01/app/oracle/fast_recovery_area/STANDBY/archivelog/2018_07_30/o1_mf_1_21_foxbbq0b_.arc thread=1 sequence=21
media recovery complete, elapsed time: 00:00:01
Finished recover at 30-JUL-18


Note: Some times recover may fail with unknown archive log which does not exist in primary database. We can ignore those errors.

Step 23: Create stanby redolog files in both Primary and Standby databases for switch over purpose.

alter system set standby_file_management='manual' scope=spfile;
alter database add standby logfile('/u02/oradata/primary/stndby1.log') size 51m;
alter database add standby logfile('/u02/oradata/primary/stndby2.log') size 51m;
alter database add standby logfile('/u02/oradata/primary/stndby3.log') size 51m;
alter database add standby logfile('/u02/oradata/primary/stndby4.log') size 51m;
alter system set standby_file_management='auto' scope=spfile;

Step 24: Start managed recovery process in standby database.

SQL> alter database recover managed standby database disconnect from session;

Database altered.


SQL> select PROCESS,CLIENT_PROCESS,STATUS,SEQUENCE# from v$managed_standby;

PROCESS CLIENT_P STATUS SEQUENCE# --------- -------- ------------ ---------- RFS UNKNOWN IDLE 0 MRP0 N/A APPLYING_LOG 31 RFS LGWR IDLE 31

Step 25: Verify max sequence number in both Primary and Standby databases.

Primary:

SQL> show parameter db_unique_name

NAME              TYPE        VALUE
------------------------------------     -----------   ------------------------------
db_unique_name      string        PRIMARY

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
    21

Standby:

SQL> show parameter db_unique_name

NAME            TYPE      VALUE
------------------------------------   -----------   ------------------------------
db_unique_name     string       STANDBY


SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
    21

Verification:

On Primary:

Do some transactions in Primary database and check below verification.

SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string PRIMARY

SQL> SELECT THREAD# "Thread",SEQUENCE# "Last Sequence Generated"
FROM V$ARCHIVED_LOG
WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)
ORDER BY 1; 
  2    3    4  
    Thread      Last Sequence Generated
----------        -----------------------
1 27
1 27

On Standby:

SQL> show parameter db_unique_name

NAME            TYPE     VALUE
------------------------------------   -----------   ------------------------------
db_unique_name     string      STANDBY

SQL> SELECT THREAD# "Thread",SEQUENCE# "Last Sequence Generated"
FROM V$ARCHIVED_LOG
WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)
ORDER BY 1; 
  2    3    4  
    Thread    Last Sequence Generated
----------       -----------------------
1 27


Thanks for your patience to view this post........







Monday 23 July 2018

Step by Step Oracle 12c Golden Gate Installation and Configuration(Replication)


This document describes how to install Oracle 12c Golden Gate  and how to configure the replication.

Prerequisites:

1. Install Linux servers (Both source and target)
2. Install 12.1.0.2 database in  both source and target servers
3. Switch the database from noarchivelog mode to archivelog mode.
4. Download 12C Golden Gate software
5. Install Goldengate software
6. Configure Goldengate Replication.

1. Install Linux servers (Both source and target): Please Click Here to find how to install Linux 6 servers  in Virtual Box.

2. Install 12.1.0.2 database in  both source and target servers: Please Click Here to find how to install 12C database.

3. Switch the database from noarchivelog mode to archivelog mode: Please Click Here to find how to change database mode from Noarchivelog to Archivelog.

4. Download 12C Golden Gate software: Please Click Here to download 12C Golden Gate software.

Source and Target databases and servers info:

Source Server and Database:

Server: Oracle Linux Server release 6.9  - 64 Bit
Database: 12.1.0.2 - Enterprise Edition
Database Name: GOLD

Target Server and Database:

Server: Oracle Linux Server release 6.9  - 64 Bit
Database: 12.1.0.2 - Enterprise Edition
Database Name: SILVER



5. Installation of Golden Gate in Source Database: 12C Golden Gate is GUI based installation and needs to be run runInstaller upon unzipping the software.

Assumptions:

1. Installed 12.1.0.2 database in both source and target servers. Oracle home for database is /u01/app/oracle/product/12.1.0/dbhome_1

2. Create directory structure for Golden Gate home(/u01/app/oracle/product/ggate_home1)

Login as oracle user and run runInstaller from downloaded software.

[oracle@server1 Disk1]$ ./runInstaller
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 5449 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 6099 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-06-30_03-15-21PM. Please wait ...



Select "Oracle GoldenGate for Oracle database 12C(1009.0 MB) and click on "Next".



Select location which we have created for GG home.
Select database home location, port number for manager and click on "Next".


Click on "Install"



Click on "Close"


Install the same way in target server as well.


6. Golden Gate Configuration:

Agenda: Create table(Test) in source database(GOLD) and replicate it in target database(SILVER).

Step1: Create schema and create one table under the schema.

SQL> create user ggtest identified by ggtest default tablespace ggtest_data;

User created.

SQL> grant connect,resource,create  table to ggtest;

Grant succeeded.

SQL> alter user ggtest quota unlimited on ggtest_data;

User altered.

SQL> create table ggtest.test(
VAL NUMBER NOT NULL,
DESCR VARCHAR2(20),
CONSTRAINT TEST1_PK PRIMARY KEY (VAL) ENABLE);  2    3    4 

Table created.

SQL> insert into ggtest.test values(1,'Spring');

1 row created.

SQL> commit;

Commit complete.

Step 2: Create goldengate user (gguser) in both source and target databases. Create separate tablespace and assign that tablespace as default tablespace to goldengate user. Grant required privileges to capture data.

Source(GOLD):

SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string GOLD

SQL> create tablespace ggate_data datafile '/u02/oradata/GOLD/ggate_01.dbf' size 50m autoextend on maxsize 10G;

Tablespace created.
SQL> create  user gguser identified by gguser default tablespace ggate_data temporary tablespace temp;

User created.

SQL> alter user gguser quota unlimited on ggate_data;

User altered.

SQL> GRANT CREATE SESSION, CONNECT, RESOURCE, ALTER SYSTEM TO GGUSER;

Grant succeeded.

SQL> EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(grantee=>'gguser', privilege_type=>'CAPTURE', grant_optional_privileges=>'*');

PL/SQL procedure successfully completed.

SQL>


Target(SILVER):


SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string SILVER

SQL> create tablespace ggate_data datafile '/u02/oradata/SILVER/ggate_01.dbf' size 50m autoextend on maxsize 10G;

Tablespace created.

SQL> create  user gguser identified by gguser default tablespace ggate_data temporary tablespace temp;

User created.

SQL> alter user gguser quota unlimited on ggate_data;

User altered.

SQL> GRANT CREATE SESSION, CONNECT, RESOURCE, CREATE TABLE, dba, LOCK ANY TABLE TO GGUSER;

Grant succeeded.

SQL> GRANT INSERT ANY TABLE, UPDATE ANY TABLE, DELETE ANY TABLE TO GGUSER;

Grant succeeded.

SQL> EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(grantee=>'gguser', privilege_type=>'APPLY', grant_optional_privileges=>'*');

PL/SQL procedure successfully completed.

SQL> 


STEP 3:  Run DDL support scripts in source database(GOLD).

Go to Goldengate home location and execute below scripts.


script 1:

SQL> @marker_setup.sql

Marker setup script

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:GGUSER

Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGUSER

MARKER TABLE
-------------------------------
OK

MARKER SEQUENCE
-------------------------------
OK

Script complete.
SQL>

script 2:

SQL> @ddl_setup.sql

Oracle GoldenGate DDL Replication setup script

Verifying that current user has privileges to install DDL Replication...

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:GGUSER

Working, please wait ...
Spooling to file ddl_setup_spool.txt

Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...

Check complete.

script 3:

SQL> @role_setup.sql

GGS Role setup script

This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)

You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter GoldenGate schema name:GGUSER
Wrote file role_setup_set.txt

PL/SQL procedure successfully completed.


Role setup script complete

Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:

GRANT GGS_GGSUSER_ROLE TO <loggedUser>

where <loggedUser> is the user assigned to the GoldenGate processes.

SQL> GRANT GGS_GGSUSER_ROLE TO GGUSER;

Grant succeeded.

script 4:

SQL> @ddl_enable.sql

Trigger altered.


SQL>

STEP 4: Enable supplemental logging in source database(GOLD).

SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;

SUPPLEME FORCE_LOGGING
-------- ---------------------------------------
NO                    NO

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

SQL> ALTER SYSTEM SWITCH LOGFILE;

System altered.

SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;

SUPPLEME FORCE_LOGGING
--------         ---------------------------------------
YES             YES

STEP 5: Enable  Goldengate replication in both source and target databases.

Source(GOLD):

SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string GOLD
SQL> ALTER SYSTEM SET enable_goldengate_replication=TRUE;

System altered.

SQL>

Target(SILVER):

SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string SILVER

SQL> ALTER SYSTEM SET enable_goldengate_replication=TRUE;

System altered.

STEP 6: Add GGUSER entry in GLOBALS file.

GGSCI (server1.apps.com) 1> edit params ./GLOBALS

(It opens vi editor and add below entry and save it.)

GGSCHEMA GGUSER

STEP 7: Add entries in manager parameter file and restart manager.

GGSCI (server1.apps.com) 2> edit params mgr

(It opens vi editor and add below entries and save it.)

PORT 7809
AUTOSTART ER *
AUTORESTART ER *, RETRIES 6, WAITMINUTES 2, RESETMINUTES 30
PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPHOURS 2

stop/start manager:

GGSCI (server1.apps.com) 4> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           


GGSCI (server1.apps.com) 5> stop mgr
Manager process is required by other GGS processes.
Are you sure you want to stop it (y/n)?y

Sending STOP request to MANAGER ...
Request processed.
Manager stopped.


GGSCI (server1.apps.com) 6> start mgr
Manager started.

GGSCI (server1.apps.com) 7> info mgr

Manager is running (IP port server1.apps.com.7809, Process ID 9308).

GGSCI (server1.apps.com) 8> 

STEP8: Create credential store in source and target databases to GGUSER to connect database with alias

Source:

GGSCI (server1.apps.com) 1> dblogin, userid gguser@GOLD, password gguser
Successfully logged into database.

GGSCI (server1.apps.com as gguser@GOLD) 2> add credentialstore

Credential store created in ./dircrd/.

GGSCI (server1.apps.com as gguser@GOLD) 3> alter credentialstore add user gguser@GOLD alias gguser
Password: 

Credential store in ./dircrd/ altered.

GGSCI (server1.apps.com as gguser@GOLD) 5> info credentialstore

Reading from ./dircrd/:

Default domain: OracleGoldenGate

  Alias: gguser
  Userid: gguser@GOLD

GGSCI (server1.apps.com as gguser@GOLD) 6> 


Target:

GGSCI (server2.apps.com) 1> dblogin userid gguser@SILVER, password gguser
Successfully logged into database.

GGSCI (server2.apps.com as gguser@SILVER) 2> add credentialstore

Credential store created in ./dircrd/.

GGSCI (server2.apps.com as gguser@SILVER) 3> alter credentialstore add user gguser@SILVER alias gguser
Password: 

Credential store in ./dircrd/ altered.

GGSCI (server2.apps.com as gguser@SILVER) 4> info credentialstore

Reading from ./dircrd/:

Default domain: OracleGoldenGate

  Alias: gguser
  Userid: gguser@SILVER

GGSCI (server2.apps.com as gguser@SILVER) 5>


STEP 9: Enable trandata in source database(GOLD).

GGSCI (server1.apps.com as gguser@GOLD) 6> add trandata ggtest.TEST

Logging of supplemental redo data enabled for table GGTEST.TEST.
TRANDATA for scheduling columns has been added on table 'GGTEST.TEST'.
TRANDATA for instantiation CSN has been added on table 'GGTEST.TEST'.
GGSCI (server1.apps.com as gguser@GOLD) 7> 

STEP 10: Edit the  extract(CAPTURE) parameter file in source database and add below parameters.

GGSCI (server1.apps.com as gguser@GOLD) 7> edit params CAPTURE

(It opens vi editor and add below parameters and save it.)

EXTRACT CAPTURE
SETENV (ORACLE_SID='GOLD')
SETENV (ORACLE_HOME="/u01/app/oracle/product/12.1.0/dbhome_1")
USERIDALIAS gguser
EXTTRAIL ./dirdat/st
LOGALLSUPCOLS
UPDATERECORDFORMAT COMPACT
DDL INCLUDE MAPPED OBJNAME GGTEST.TEST;
TABLE GGTEST.TEST;

STEP 11: Add extract and trail to source database.

GGSCI (server1.apps.com as gguser@GOLD) 8> add extract CAPTURE integrated tranlog ,begin now
EXTRACT (Integrated) added.

GGSCI (server1.apps.com as gguser@GOLD) 9> ADD EXTTRAIL ./dirdat/st EXTRACT CAPTURE
EXTTRAIL added.

GGSCI (server1.apps.com as gguser@GOLD) 10> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     STOPPED     CAPTURE     00:00:00      00:00:46    


STEP 12: Edit pump(PUMP) parameter file and add below entries.

(It opens vi editor, add below entries and save it.)

EXTRACT PUMP
USERIDALIAS gguser
RMTHOST 192.168.1.120 MGRPORT 7809
RMTTRAIL ./dirdat/rt
TABLE GGTEST.TEST;

STEP 13: Add extract PUMP to source database.

GGSCI (server1.apps.com as gguser@GOLD) 12> ADD EXTRACT PUMP, EXTTRAILSOURCE ./dirdat/st
EXTRACT added.


GGSCI (server1.apps.com as gguser@GOLD) 13> ADD RMTTRAIL ./dirdat/rt EXTRACT PUMP MEGABYTES 50
RMTTRAIL added.

STEP 14: Register extracts CAPTURE in source database and start CAPTURE and PUMP.

GGSCI (server1.apps.com as gguser@GOLD) 14> register extract CAPTURE database

2018-07-23 15:15:58  INFO    OGG-02003  Extract CAPTURE successfully registered with database at SCN 1708881.

GGSCI (server1.apps.com as gguser@GOLD) 15> info all             

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     STOPPED     CAPTURE     00:00:00      00:10:52    
EXTRACT     STOPPED     PUMP        00:00:00      00:04:29    

GGSCI (server1.apps.com as gguser@GOLD) 16> start extract CAPTURE

Sending START request to MANAGER ...
EXTRACT CAPTURE starting

GGSCI (server1.apps.com as gguser@GOLD) 17> start extract pump

Sending START request to MANAGER ...
EXTRACT PUMP starting


GGSCI (server1.apps.com as gguser@GOLD) 18> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     CAPTURE     00:00:03      00:00:05    
EXTRACT     RUNNING     PUMP        00:00:00      00:00:03  


STEP 15: Export TEST table from source database and import in target database.

Export in source:

[oracle@server1 u02]$ expdp "'/as sysdba'" tables=GGTEST.TEST directory=DUMP dumpfile=TEST.dmp logfile=expdpTEST.log

Export: Release 12.1.0.2.0 - Production on Mon Jul 23 15:22:33 2018

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYS"."SYS_EXPORT_TABLE_01":  "/******** AS SYSDBA" tables=GGTEST.TEST directory=DUMP dumpfile=TEST.dmp logfile=expdpTEST.log 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/PROCACT_INSTANCE
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
. . exported "GGTEST"."TEST"                             5.484 KB       1 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
  /u02/DUMP/TEST.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Mon Jul 23 15:23:10 2018 elapsed 0 00:00:30


Import: Import table in target database.

[oracle@server2 DUMP]$ impdp "'/as sysdba'" tables=GGTEST.TEST directory=DUMP dumpfile=TEST.dmp logfile=impdpTEST.log

Import: Release 12.1.0.2.0 - Production on Mon Jul 23 15:34:36 2018

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SYS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLE_01":  "/******** AS SYSDBA" tables=GGTEST.TEST directory=DUMP dumpfile=TEST.dmp logfile=impdpTEST.log 
Processing object type TABLE_EXPORT/TABLE/PROCACT_INSTANCE
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "GGTEST"."TEST"                             5.484 KB       1 rows
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Job "SYS"."SYS_IMPORT_TABLE_01" successfully completed at Mon Jul 23 15:34:55 2018 elapsed 0 00:00:17

STEP 16: Edit manager parameter file in target database(SILVER) and add below parameters.

GGSCI (server2.apps.com as gguser@SILVER) 6> edit params mgr

(It opens vi editor, add below parameters and save it.)

PORT 7809
AUTOSTART ER *
AUTORESTART ER *, RETRIES 6, WAITMINUTES 2, RESETMINUTES 30
PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPHOURS 2

stop/start the manager.

GGSCI (server2.apps.com as gguser@SILVER) 7> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           


GGSCI (server2.apps.com as gguser@SILVER) 8> stop mgr
Manager process is required by other GGS processes.
Are you sure you want to stop it (y/n)?y

Sending STOP request to MANAGER ...
Request processed.
Manager stopped.

GGSCI (server2.apps.com as gguser@SILVER) 10> start mgr
Manager started.
                                       
GGSCI (server2.apps.com as gguser@SILVER) 12> info mgr

Manager is running (IP port server2.apps.com.7809, Process ID 10633).

STEP 17: Create globals file and add checkpoint file in target database.

GGSCI (server2.apps.com as gguser@SILVER) 13> EDIT PARAMS ./GLOBALS

(It opens vi editor, add below entry and save it.)

GGSCHEMA GGUSER

Add checkpoint table in target database.

GGSCI (server2.apps.com as gguser@SILVER) 16> ADD CHECKPOINTTABLE GGUSER.CHECKPOINTS

Successfully created checkpoint table GGUSER.CHECKPOINTS.

STEP 18: Edit replicat parameter file(APPLY) and add below entries.

GGSCI (server2.apps.com as gguser@SILVER) 17> edit params APPLY

(It opens vi editor, add below entries and save it.)

REPLICAT APPLY
SETENV (ORACLE_SID="SILVER")
SETENV (ORACLE_HOME="/u01/app/oracle/product/12.1.0/dbhome_1")
USERIDALIAS gguser
APPLYNOOPUPDATES
DBOPTIONS INTEGRATEDPARAMS(parallelism 2)
ASSUMETARGETDEFS
DISCARDFILE ./dirrpt/rsubsera.dsc, append, megabytes 500
MAP GGTEST.TEST, TARGET GGTEST.TEST ;

STEP 19: Add replicat(APPLY) to target database and start it.

GGSCI (server2.apps.com as gguser@SILVER) 18> ADD REPLICAT APPLY, integrated, EXTTRAIL ./dirdat/rt
REPLICAT (Integrated) added.

GGSCI (server2.apps.com as gguser@SILVER) 19> info all        

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
REPLICAT    STOPPED     APPLY       00:00:00      00:00:39    


GGSCI (server2.apps.com as gguser@SILVER) 20> start replicat apply

Sending START request to MANAGER ...
REPLICAT APPLY starting

GGSCI (server2.apps.com as gguser@SILVER) 21> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
REPLICAT    RUNNING     APPLY       00:00:00      00:00:03    

STEP 20: Insert record in test table for source database and verify table replication in target database.

Before insert data:

Source(GOLD):

SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string GOLD

SQL> select count(*) from ggtest.test;

  COUNT(*)
----------
1

SQL> select * from ggtest.test;

       VAL    DESCR
----------     --------------------
1        Spring


Target(SILVER):

SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string SILVER
SQL> select count(*) from ggtest.test;

  COUNT(*)
----------
1

SQL> select * from ggtest.test;

       VAL DESCR
---------- --------------------
1      Spring



After insert the record:

Source(GOLD):

SQL> insert into ggtest.test values(2,'WINTER');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from ggtest.test;

       VAL DESCR
---------- --------------------
1 Spring
2 WINTER


Verification in Target(SILVER):

SQL> show parameter db_name

NAME      TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string SILVER

SQL> select * from ggtest.test;

       VAL DESCR
---------- --------------------
1 Spring
2 WINTER



Thanks for your patience to review the post..............