Wednesday, January 27, 2016

steps to move data file to one disk group to another disk group


Move ASM files from one diskgroup to another diskgroup
---------------------------------------------------------------------------


Step 1: Get the data file name:

select   file_name from   dba_data_files where file_name like '%user%';

Step 2:  Identify the target diskgroup to migrate to:


select    name from    v$asm_diskgroup;
FRA

Step 3:  Take the old data file offline:

alter database datafile    '+DATA/RAC/DATAFILE/users.261.898200463' offline;

Step 4:  Copy the datafile to the new diskgroup (using RMAN)

$ rman target /

connected to target database: RAC (DBID=2486182530)


RMAN> copy datafile '+DATA/RAC/DATAFILE/users.261.898200463' to '+FRA';

Starting backup at 2-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=262 instance=RAC1 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=+DATA/RAC/DATAFILE/users.261.898200463
output file name=+FRA/RAC/DATAFILE/users.271.902270597 tag=TAG20160127T224316 RECID=3 STAMP=902270598
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2-JAN-15

Starting Control File and SPFILE Autobackup at 2-JAN-15
piece handle=+FRA/RAC/AUTOBACKUP/2016_01_27/s_902270598.261.902270605 comment=NONE
Finished Control File and SPFILE Autobackup at 2-JAN-15


Step 6: Re-name the data file:

SQL> alter database rename file  '+DATA/RAC/DATAFILE/users.261.898200463'  to  '+FRA/RAC/DATAFILE/users.271.902270597';

Step 7: Get the new filename:

SQL> select   file_name from   dba_data_files where file_name like '%user%';

FILE_NAME
--------------------------------------------------------------------------------
+FRA/RAC/DATAFILE/users.271.902270597

Step 8: Rename the RMAN data file:

RMAN> switch datafile '+FRA/RAC/DATAFILE/users.271.902270597' to copy;

using target database control file instead of recovery catalog
datafile 6 switched to datafile copy "+FRA/RAC/DATAFILE/users.271.902270597"

Step 9: Use RMAN recovery to the new data file:

RMAN> recover datafile '+FRA/RAC/DATAFILE/users.271.902270597';

Starting recover at 2-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=284 instance=RAC1 device type=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:02

Finished recover at 2-JAN-15


Step 10:  Put the data file online:

RMAN> alter database datafile '+FRA/RAC/DATAFILE/users.271.902270597' online;

Statement processed


After Oracle renames the ASM database file in the data dictionary, it will remove the original ASM database file

steps to move oracle Data file online one location to another location in oracle 12c

In Oracle 12c  we can move Oracle  data file online.
Here is the steps for online movement.

SQL*Plus: Release 12.1.0.1.0 Production

SQL> select  file_name from dba_data_files where file_name like '%users01%';

FILE_NAME
--------------------------------------------------------------------------------

/u01/app/oracle/oradata/source/users01.dbf


SQL> ALTER DATABASE MOVE DATAFILE '/u01/app/oracle/oradata/source/users01.dbf' to '/u02/app/oracle/oradata/source/users01.dbf';

Database altered.

SQL> select  file_name from dba_data_files where file_name like '%users01%';

FILE_NAME
--------------------------------------------------------------------------------

/u02/app/oracle/oradata/source/users01.dbf

Thursday, January 21, 2016

oracle standby database important views used for troubleshooting.

select PROCESS,STATUS,SEQUENCE# from v$managed_standby;

select * from v$archive_gap;

select * from V$DATAGUARD_CONFIG;

select name,value from V$DATAGUARD_STATS;

select DEST_ID,ERROR_CODE,MESSAGE from V$DATAGUARD_STATUS

select DEST_NAME,RECOVERY_MODE,APPLIED_THREAD#,DESTINATION from V$archive_dest_status;

select name,APPLIED,STATUS ,FAL ,END_OF_REDO_TYPE from V$ARCHIVED_LOG

select PROCESS,AFFIRM,MAX_FAILURE,FAILURE_COUNT,NET_TIMEOUT,status ,DEST_NAME from V$ARCHIVE_DEST;

select * from V$archive;

select PROCESS,STATUS,STATE from V$ARCHIVE_PROCESSES;

select name,IS_RECOVERY_DEST_FILE,END_OF_REDO,SOURCE_DBID from V$FOREIGN_ARCHIVED_LOG;

select * from V$FS_FAILOVER_STATS;

select GROUP#,STATUS,USED from  V$STANDBY_LOG;

select name,count,LAST_TIME_UPDATED from  V$STANDBY_EVENT_HISTOGRAM;

v$logstdby_stats
v$logstdby_transaction
v$logstdby_process
v$logstdby_progress
v$logstdby_state

steps to create baseline for a SQL statement in oracle database


1. -- Creating SQL tuning set to load better plan from AWR repository

exec dbms_sqltune.create_sqlset(sqlset_name => 'dz7j81n20pfm4_sqlset_test',description => 'sqlset descriptions');

2. -- Selecting historical SQL from AWR and loading that plan into tuning set

declare
baseline_ref_cur DBMS_SQLTUNE.SQLSET_CURSOR;
begin
open baseline_ref_cur for
select VALUE(p) from table(
DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY(&begin_snap_id, &end_snap_id,'sql_id='||CHR(39)||'&sql_id'||CHR(39)||' and plan_hash_value=4245310385',NULL,NULL,NULL,NULL,NULL,NULL,'ALL')) p;
DBMS_SQLTUNE.LOAD_SQLSET('dz7j81n20pfm4_sqlset_test', baseline_ref_cur);
end;
/

-- input values..

sql id : dz7j81n20pfm4
bein snap: 38451
end snap: 38454

3. -- check to see tuning set was created above.

SELECT NAME,OWNER,CREATED,STATEMENT_COUNT FROM DBA_SQLSET where name='dz7j81n20pfm4_sqlset_test';

4. -- Load SQL and good plan into baseline

set serveroutput on
declare
my_int pls_integer;
begin
my_int := dbms_spm.load_plans_from_sqlset (
sqlset_name => 'dz7j81n20pfm4_sqlset_test',
basic_filter => 'sql_id="dz7j81n20pfm4" and plan_hash_value =4245310385',
sqlset_owner => 'SYS',
fixed => 'NO',
enabled => 'YES');
DBMS_OUTPUT.PUT_line(my_int);
end;
/

5. -- verify baseline is created

SELECT SQL_HANDLE, PLAN_NAME, ORIGIN, ENABLED, ACCEPTED, FIXED, MODULE FROM   DBA_SQL_PLAN_BASELINES;

Sunday, January 17, 2016

steps to install DDboost on AIX server

Here is the list of steps to install DDboost on AIX server.
----------------------------------------------------------------------

assumption we had already installed oracle software binaries on the target server and down load the DDBoost  and move to server.
untar the requested files.

rw-rw-r--    1 oracle   dba         5580800 Mar 06 2014  RMAN_1.1.1.3-415543_RMAN_aix_64.tar
(server_name:oracle)/oracle/ddboost>./install.sh
ksh: ./install.sh:  not found.
(server_name:oracle)/oracle/ddboost>install.sh
ksh: install.sh:  not found.
(server_name:oracle)/oracle/ddboost>sh install.sh
Installing the Data Domain plugin for RMAN ...
Copying libraries to /oracle/product/11gR2_3/lib
cp libddobk.so /oracle/product/11gR2_3/lib/libddobk.so
cp libDDBoost.so /oracle/product/11gR2_3/lib/libDDBoost.so
Successfully installed the Data Domain plugin for RMAN

step to install NZPORTAL on linux for Netezza applicance

Here is the list of steps  follow to install NZPORTAL for NPS appliance
---------------------------------------------------------------------------------------------------

rw-r--r--  1 root    root       71317688 Dec  8 12:20 nzportal.package.tar.z
[root@<server_name> netback]# tar -xvf  nzportal.package.tar.z
nzportal.2.0.0-4.tar
unpack
[root@<server_name> netback]# ls -ltr
total 12428300

-rw-r--r--  1 root    root       71317688 Dec  8 12:20 nzportal.package.tar.z
[root@<server_name> netback]# mkdir portal
[root@<server_name> netback]# cd portal
[root@<server_name> portal]# pwd
/netback/portal
[root@<server_name> portal]# ls -ltr
total 70476
-rw-r--r-- 1 root root 72087525 Dec  8 12:24 nz-portal-v2.0.0.4.tar.gz
[root@<server_name> portal]# tar -xvf nz-portal-v2.0.0.4.tar.gz
Netezza_portal_user_guide.pdf
nzportal.package.tar.z
NzPortal_Readme.txt
[root@<server_name> portal]# ls -tlr
total 141560
-rw-r--r-- 1 10507 12009 71317688 Mar  3  2014 nzportal.package.tar.z
-rw-r--r-- 1 10507 12009     3561 Mar  3  2014 NzPortal_Readme.txt
-rw-r--r-- 1 10507 12009  1385661 Mar  3  2014 Netezza_portal_user_guide.pdf
-rw-r--r-- 1 root  root  72087525 Dec  8 12:24 nz-portal-v2.0.0.4.tar.gz
[root@<server_name> portal]# tar -xvf nzportal.package.tar.z
nzportal.2.0.0-4.tar
unpack
[root@<server_name> portal]# ls -tlr
total 299668
-rwxr-xr-x 1 10507 12009     63620 Mar  3  2014 unpack
-rw-r--r-- 1 10507 12009 161669120 Mar  3  2014 nzportal.2.0.0-4.tar
-rw-r--r-- 1 10507 12009  71317688 Mar  3  2014 nzportal.package.tar.z
-rw-r--r-- 1 10507 12009      3561 Mar  3  2014 NzPortal_Readme.txt
-rw-r--r-- 1 10507 12009   1385661 Mar  3  2014 Netezza_portal_user_guide.pdf
-rw-r--r-- 1 root  root   72087525 Dec  8 12:24 nz-portal-v2.0.0.4.tar.gz
[root@<server_name> portal]# ./unpack
-------------------------------------------------------------------------------
IBM Netezza -- IBM Netezza Performance Portal 2.0.0.4
(C) Copyright IBM Corp. 2002, 2014  All Rights Reserved.
-------------------------------------------------------------------------------

Validating package checksum ... ok

Directory '/usr/local/nzWebAdmin' does not exist; create it (y/n)? [y] y
Checking the system...
This is NPS Appliance. OK
Checking if Apache server is already running:
http server is not running
Checking if IBM Netezza Performance Portal is already installed/running:
IBM Netezza Performance Portal is not running
******************************************************************************
Unpacking web application files into:  /usr/local/nzWebAdmin
******************************************************************************
Deleting existing cache files...

0%          25%         50%         75%          100%
|||||||||||||||||||||||||||||||||||||||||||||||||||


Installing web services RPMs ...
Searching for Installation of
Preparing...                ########################################### [100%]
   1:apr                    ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:apr-util               ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:distcache              ########################################### [100%]
Searching for Installation of
expat-1.95.8-8.3.el5_5.3.i386
expat-1.95.8-8.3.el5_5.3.i386.rpm already installed
Searching for Installation of
Preparing...                ########################################### [100%]
   1:freetype               ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:gmp                    ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:httpd                  ########################################### [100%]
Searching for Installation of
libidn-0.6.5-1.1.i386
libidn-0.6.5-1.1.i386.rpm already installed
Searching for Installation of
Preparing...                ########################################### [100%]
   1:libjpeg                ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:libpng                 ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:libxml2                ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:mod_ssl                ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:pcre                   ########################################### [100%]
Searching for Installation of
Preparing...                ########################################### [100%]
   1:postgresql-libs        ########################################### [100%]
Removing old link: /lib/libssl.so.6 to libssl.so.0.9.8e
Linking /lib/libssl.so.6 to /lib/libssl.so.0.9.8e
Removing old link: /lib64/libssl.so.6 to libssl.so.0.9.8e
Linking /lib64/libssl.so.6 to /lib64/libssl.so.0.9.8e
Removing old link: /lib/libcrypto.so.6 to libcrypto.so.0.9.8e
Linking /lib/libcrypto.so.6 to /lib/libcrypto.so.0.9.8e
Removing old link: /lib64/libcrypto.so.6 to libcrypto.so.0.9.8e
Linking /lib64/libcrypto.so.6 to /lib64/libcrypto.so.0.9.8e
Removing old link: /lib/libssl.so.4 to libssl.so.0.9.7a
Linking /lib/libssl.so.4 to /lib/libssl.so.6
Removing old link: /lib64/libssl.so.4 to libssl.so.0.9.7a
Linking /lib64/libssl.so.4 to /lib64/libssl.so.6
Removing old link: /lib/libcrypto.so.4 to libcrypto.so.0.9.7a
Linking /lib/libcrypto.so.4 to /lib/libcrypto.so.6
Removing old link: /lib64/libcrypto.so.4 to libcrypto.so.0.9.7a
Linking /lib64/libcrypto.so.4 to /lib64/libcrypto.so.6
Checking for existing SSL preferences in httpd.conf
Existing SSL preferences not found. SSL support is required and will be added.
******************************************************************************
Generating certificate for Apache SSL
******************************************************************************
Default SSL values settings:
Country Name: US
State or Province Name: New York
Locality Name: Endicott
Organization Name: International Business Machines Corporation
Organizational Unit Name: 07
Common Name: <server_name>
Do you want to use "US" as country name ? (y/n)? [y] y
Do you want to use "New York" as State or Province Name ? (y/n)? [y] n
State or Province Name (full name):
texas
Do you want to use "Endicott" as Locality Name ?  (y/n)? [y] n
Locality Name (eg, city):
dallas
Do you want to use "International Business Machines Corporation" as Organization Name ?  (y/n)? [y] n
Organization Name (eg, company):
<companay_name>
Do you want to use "07" Organizational Unit Name ?  (y/n)? [y] n
Organizational Unit Name (eg, section):
EDW
Do you want to use "<server_name>" as Common Name ?  (y/n)? [y] y

WARNING:
The existing file /etc/syslog.conf has been moved to
/etc/syslog.conf.old.30891

Shutting down kernel logger:                               [  OK  ]
Shutting down system logger:                               [  OK  ]
Starting system logger:                                    [  OK  ]
Starting kernel logger:                                    [  OK  ]
root: Starting nzSoapService server
                                                           [  OK  ]
Checking httpd v0 modules names on /etc/httpd/conf/httpd.conf file...
- mod_access :
   there is no reference to mod_access on httpd.conf file.
- mod_auth_dbm :
   there is no reference to mod_auth_dbm on httpd.conf file.
- mod_imap :
   there is no reference to mod_imap on httpd.conf file.
Starting httpd:                                            [  OK  ]

********************************************************************************

         Be sure to check your firewall settings for restrictions.
         If ports 80 and/or 443 are blocked, the web application
         will not be accessible.
         Please consult the NzPortal_Readme.txt file for more information.

         To connect to IBM Netezza Performance Portal
         please start a browser and point to:
         https://<server_name>/com.netezza.portal.Portal/index.html

******************************************************************************


Unpacking complete.
[root@<server_name> portal]# su - nz

     <server_name> NPS environment
==================================================

     HOME                 = /export/home/nz
     USER                 = nz

     NZ_USER              = admin
     NZ_DATABASE          = system


     /nz/data/config/system.cfg settings
==================================================

    startup.maxConnections    = 1000
    system.enableCTA2         = 1


[nz@<server_name> ~]$ exit
logout
[root@<server_name> portal]# service httpd status
httpd (pid  21877) is running...
[root@<server_name> portal]# service nzportal status
nzSoapService (pid 21471) is running...

https://<server_name>/com.netezza.portal.Portal/index.html

now login into the portal with default user and password and create your ownn user & password

RAc issues||CRS-4535: Cannot communicate with Cluster Ready Services


Here is the steps that I followed to clear the priority tickets.
-----------------------------------------------------------------------

connected to ASM instance on the 1st node via
sqlpls / as sysasm
o checked status of the diskgroups using
select name,state from v$asm_diskgroup;
all showed "DISMOUNTED"
o then issued
alter diskgroup OCRVD mount;
alter diskgroup DATBA mount;
alter diskgroup FRA mount;
all of which succeeded.
o next issued
crsctl start res ora.crsd -init
which started the CRS daemon
o checked CRS resources using
crsctl stat res -t
which showed that database resources are being started
o repeated the same on the 2nd node which succeeded
o databases now up & running again on both nodes 

step by step golden gate unidirectional setup procedure on Linux



1)Prerequisite:
Assumption that two database (Source and Destination) are available with archive log enabled.  Both source & target hosts should be able to do ping/ssh/ each other.

Environment:
Particulars
Source DB:source
Target DB :target

DB Version
12.1.2.0.0
12.1.2.0.0

2)PATH=$ORACLE_HOME/bin:/u01/app/GGS:$PATH; export PATH          

3)      Login into Golden Gate
cd  /u01/app/GGS

4)$./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 12.1.2.0.0 17185003 OGGCORE_12.1.2.0.0_PLATFORMS_130924.1316_FBO
Linux, x64, 64bit (optimized), Oracle 12c on Sep 25 2013 02:33:54
Operating system character set identified as UTF-8.

Copyright (C) 1995, 2013, Oracle and/or its affiliates. All rights reserved.



5)      Create the mandatory files and directories if does not exist:    
GGSCI (source_server) 1> create subdirs
GGSCI (source_server) 2> exit
$ mkdir /u01/app/GGS/discard

This will complete the Golden Gate software Installation on source_server
Repeat all the above steps on target_server to install the software on second host.

Preparing the database for replication:
Source Database:(source)
---------------------------
Switch the database to Archive log mode
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open

Enable Minimal Database Level Supplemental Logging
SQL> alter database add supplemental log data;

Prepare the database to support DDL Replication
a)      Turn Off Recyclebin for The Database and then bounce it.
SQL> alter system set recyclebin=off scope=spfile;

6)      Create New Schema for DDL Support Replication And Grant a Necessary Privileges To New User

SQL> create user gg_user identified by oracle default tablespace users temporary tablespace temp;
SQL> grant connect, resource, unlimited tablespace to gg_user;
SQL> grant execute on utl_file to gg_user;

7)       Go to Golden Gate Installed location (in our scenario /u01/app/GGS) and then run the following Golden Gate inbuild scripts for creating all necessary objects to support DDL replication.
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:GG_USER


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

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

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

Script complete.

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:GG_USER

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.


WARNING: Tablespace GG_TBS does not have AUTOEXTEND enabled.

/****************Need to create separate TBS for this***********************/



Using GG_USER as a Oracle GoldenGate schema name.

Working, please wait ...

DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GG_USER

CLEAR_TRACE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

CREATE_TRACE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

TRACE_PUT_LINE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

INITIAL_SETUP STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLVERSIONSPECIFIC PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLREPLICATION PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLREPLICATION PACKAGE BODY STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDL IGNORE TABLE
-----------------------------------
OK

DDL IGNORE LOG TABLE
-----------------------------------
OK

DDLAUX  PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLAUX PACKAGE BODY STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

SYS.DDLCTXINFO  PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

SYS.DDLCTXINFO  PACKAGE BODY STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDL HISTORY TABLE
-----------------------------------
OK

DDL HISTORY TABLE(1)
-----------------------------------
OK

DDL DUMP TABLES
-----------------------------------
OK

DDL DUMP COLUMNS
-----------------------------------
OK

DDL DUMP LOG GROUPS
-----------------------------------
OK

DDL DUMP PARTITIONS
-----------------------------------
OK

DDL DUMP PRIMARY KEYS
-----------------------------------
OK

DDL SEQUENCE
-----------------------------------
OK

GGS_TEMP_COLS
-----------------------------------
OK

GGS_TEMP_UK
-----------------------------------
OK

DDL TRIGGER CODE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDL TRIGGER INSTALL STATUS
-----------------------------------
OK

DDL TRIGGER RUNNING STATUS
-----------------------------------
ENABLED

STAYMETADATA IN TRIGGER
-----------------------------------
OFF

DDL TRIGGER SQL TRACING
-----------------------------------
0

DDL TRIGGER TRACE LEVEL
-----------------------------------
0

LOCATION OF DDL TRACE FILE
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/target/target/trace/ggs_ddl_trace.log

Analyzing installation status...


VERSION OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------
OGGCORE_12.1.2.0.0_PLATFORMS_130924.1316

STATUS OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components

Script complete.


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 pref                        erred 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:GG_USER
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 gg_user;

SQL>@ddl_enable.sql

Trigger altered.

Note: There are two ways/approach to connect the golden gate on target.
1.       Use the same user (gg_user) which created on source database by using tns service name and database link.
2.       Create an individual/same user on target.
                Here we following the create an individual/same user approach, so the above points b) and c) to be executed on target database also.

Create Test Schemas for Replication.
                I will create a replication from schema sender to schema receiver (on target_db database).
Source Database:
SQL> create user sender identified by oracle default tablespace users temporary tablespace temp;    
SQL> grant connect,resource, unlimited tablespace to sender;

             On Destination Database target_db (target_server):
SQL> create user receiver identified by oracle default tablespace users temporary tablespace temp;
SQL> grant connect, resource, unlimited tablespace to receiver;


Setup Replication:
The goal is to create DDL and transform DML from the sender schema on the SOURCE database to receiver schema on the destination target_db database.
1. Create and Start Manager on the Source and the Destination.
Source: SOURCE
[oracle@SOURCE ~]$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 12.1.2.0.0 17185003 OGGCORE_12.1.2.0.0_PLATFORMS_130924.1316_FBO
Linux, x64, 64bit (optimized), Oracle 12c on Sep 25 2013 02:33:54
Operating system character set identified as UTF-8.

Copyright (C) 1995, 2013, Oracle and/or its affiliates. All rights reserved.



GGSCI (source_server) 1> info  all

Program     Status     Group       Lag          Time Since Chkpt

MANAGER     STOPPED

GGSCI (source_server) 2> edit params mgr

It will open the parameter file for manager. Enter the following in the file:      
PORT 7809      
Then Save And Quit The File.
                 
edit params ./GLOBALS
GGSCHEMA gg_user
CHECKPOINTTABLE gg_user.ckptab

GGSCI (source_server) 1> start mgr
Manager started.        
GGSCI (source_server) 1> info all
Program     Status      Group       Lag           Time Since Chkpt
MANAGER    RUNNING


Note:
     (a)The status shows it is running
     (b)Repeat the same on TARGET  to create manager process.
     (c) 7809 is Default Port for Golden Gate  

2. Create the extract group on the source side (SOURCE)
GGSCI (source_server) 1> add extract ex_grp, tranlog,begin now
EXTRACT added.

GGSCI  (source_server) 2> add exttrail /u01/app/GGS/dirdat/lt, extract ex_grp
EXTTRAIL added.

GGSCI  (source_server) 3> edit params ex_grp

Enter the following for the content of extract parameter ex_grp and then save and exit.

EXTRACT ex_grp

USERID gg_user, PASSWORD oracle
DBOPTIONS ALLOWNOLOGGING

SETENV (ORACLE_HOME = "/u01/app/oracle/product/12.1.2/db_1")
SETENV (ORACLE_SID = "SOURCE")
RMTHOST <TARGET_HOST_IP>, MGRPORT 7809
RMTTRAIL /u01/app/GGS/dirdat/lt

DISCARDFILE discard.txt, APPEND

DDL include mapped objname sender.*;
DDLOPTIONS ADDTRANDATA
table sender.*;

3. Create replicat on the destination side (target_db)
$ cd /u01/app/GGS
$ ./ggsci

To create a checkpoint Table in the target database.                                  
GGSCI (target_server) 1> edit params ./GLOBAL
CHECKPOINTTABLE gg_user.checkpoint

Save and quit the file.

GGSCI (target_server) 2> dblogin userid gg_user, Password oracle
Successfully logged into database.      
GGSCI (target_server) 3>add checkpointtable gg_user.checkpoint
Successfully created checkpointtablegg_user.CHECKPOINT.                      

Create replicat group: target_db

GGSCI (target_server) 4>add replicat rep_grp2, exttrail /u01/app/GGS/dirdat/lt, checkpointtable gg_user.checkpoint
REPLICAT added.


Create Parameter File For Replicat:
GGSCI (target_server) 5> edit params rep_grp2  
And put following lines in the parameter file:
replicat rep_grp2
ASSUMETARGETDEFS
userid gg_user, password oracle
SETENV (ORACLE_HOME = "/u01/app/oracle/product/12.1.2/db_1")
SETENV (ORACLE_SID = "target_db")
DDL INCLUDE ALL
DDLERROR DEFAULT IGNORE RETRYOP
discardfile /u01/app/GGS/discard/rep_grp2_discard.txt, append, megabytes 10
map sender.*, target receiver.*;

Save and quit

4. Start Extract and Replicat:
Make sure that manager is up and running before starting these.        
Source: SOURCE
GGSCI (source_server) 14> start extract ex_grp

Destination: target_db
GSCI (target_server) 15> start replicat rep_grp2

5. Check the extract and replicat running in source and target system
Source: SOURCE
1 GGSCI (source_server) 8> info all
2 Program     Status     Group       Lag          Time Since Chkpt
3 MANAGER     RUNNING
4vEXTRACT     RUNNING     ex_grp        00:00:00      00:12:25

Destination: target_db
1
2
3
4
GGSCI (target_server) 8> info all
Program     Status     Group       Lag          Time Since Chkpt
MANAGER     RUNNING
REPLICAT    RUNNING     rep_grp2        00:00:00      00:12:30
           

Once all the processes are running means that replication is created successfully.
RESULTS
Now we can check our replication.
We will create some table in the sender schema on the source, insert some rows, and check how it will replicate to destination side.
1. Source Database:
SQL>conn sender/oracle
SQL> select * from table_name;
 Select * from table_name
             *
ERROR at line 1:  
ORA-00942: table or view does not exist
SQL> create table table_name (id number primary key, name varchar2(50));
Table created.
SQL> insert into table_name values (1,'testable_name');
1 row created.    
SQL> insert into table_name values (2,'test_apple');
1 row created.    
SQL> commit;
Commit complete.

       2. Destination Database:                          
SQL> conn receiver/oracle
SQL> select * from table_name;
        ID NAME
---------- --------------------------------------------------
         1 testable_name                                            
         2 test_apple                                                            
                                                                                                                               
Our Golden Gate replication is now running fine. The table was created on the target_db side and data were replicated.