Friday, August 24, 2012

Install Oracle Goldengate on Redhat Linux

Steps to Install Oracle Goldengate on Redhat Linux


1. First of all we will need to Install Oracle 11g database on Redhat Linux both on Source side and 
    Receiver side.
Source
2. Insure that sources side database archive log mode
SQL> select log_mode from v$database;

LOG_MODE
------------
NOARCHIVELOG

Put your sources side database archive log mode

SQL> shutdown immediate;
To enable the database in archive log mode following parameters must be set in init.ora file of instance
log_archive_dest_1=’location=/u01/app/oracle/archivelog’
log_archive_dest_state_1=enable
sqlplus '/as sysdba'
SQL> create spfile from pfile;
SQL> startup mount;
SQL> alter database archivelog;
Database altered
SQL> alter database open;
Database altered


3. Download Oracle goldengate 11g for linux from (size 89 Mb)
4. Unzip it and rename the folder to goldengate

5. Set LD_LIBRARY_PATH
 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/goldengate

6. Create sub directories for goldengate
    $cd /u01/goldengate
    $./ggsci
    $create subdirs




GGSCI (localhost.localdomain) 3> exit
$mkdir discard

Destination
7. Now repeat the same steps on destination side.

Source
8.  Add supplimental logging on the source side.


sql> alter database add supplemental log data;


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

create user schema to support replication
sql>create user ggate identified by ggate default tablespace users temporary tablespace temp;
sql>grant connect,resource to ggate;
sql>grant execute on utl_file to ggate;
sql>exit



9. These scripts are necessary for user ggate to be able to support replication.
   i)@marker_setup.sql



ii) @ddl_setup.sql

choose INITIALSETUP as mode of Install


iii) @role_setup.sql
iv) grant GGS_GGSUSER_ROLE to ggate;
v)@ddl_enable.sql


10. Now we will create test schemas to test our replication.

Source Database : ORCL
sql> create user sender identified by sender default tablespace users temporary tablespace temp;
sql> grant connect,resource,unlimited tablespace to sender;


Destination Database : ORCL2
sql> create user receiver identified by receiver default tablespace users temporary tablespace temp;
sql> grant connect,resource,unlimited tablespace to receiver;

11. Lets start replication....


Source Side


$./ggsci


On the command line of goldengate type info all
It will show which processes are configured manager/Extract/Replicat

GGSCI > info all
 it will show manager as stopped

Edit Parameter file of Manager and put ( PORT 7809 ) in the file.
GGSCI >edit params mgr
PORT 7809
save and exit
Now lets start manager


GGSCI >start manager
GGSCI > info all
Now it will show Manager as running

Next step is to configure Extraction process
GGSCI> add extract ext1,tranlog,begin now

Define path for exttrail

GGSCI>add exttrail /u01/goldengate/dirdat/lt,extract ext1


Now edit ext1 parameter file and add following lines into it where 192.168.x.xxx is IP Adrress of your machine

GGSCI>edit params ext1



--extract group--
extract ext1
--connection to database--
userid ggate, password ggate
--hostname and port for trail--
rmthost 192.168.x.xxx, mgrport 7809
--path and name for trail--
rmttrail /u01/goldengate/dirdat/lt
--DDL support
ddl include mapped objname sender.*;
--DML
table sender.*;







Destination Side


create user schema to support replication on destination side also and repeat the following steps on destination side too.

sql>create user ggate identified by ggate default tablespace users temporary tablespace temp;
sql>grant connect,resource to ggate;
sql>grant execute on utl_file to ggate;



SQL> @marker_setup.sql
SQL> @ddl_setup.sql
SQL> @role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggate;
SQL> @ddl_enable.sql
sql>exit

$./ggsci


On the command line of goldengate type info all
It will show which processes are configured manager/Extract/Replicat

GGSCI > info all
 it will show manager as stopped

Edit Parameter file of Manager and put ( PORT 7809 ) in the file.
GGSCI >edit params mgr
PORT 7809
save and exit
Now lets start manager


GGSCI >start manager
GGSCI > info all
Now it will show Manager as running


Next step is to configure Replicat process


Now add the following lines to rep1 parameter file


--Replicat group --
replicat rep1
--source and target definitions
ASSUMETARGETDEFS
--target database login --
userid ggate, password ggate
--file for dicarded transaction --
discardfile /u01/goldengate/discard/rep1_discard.txt, append, megabytes 10
--ddl support
DDL
--Specify table mapping ---
map sender.*, target receiver.*;


Source Side

Now lets try to start extract ext1

GGSCI>start extract ext1
if there are any errors you will find the log in /u01/goldengate/dirrpt/EXT1.rpt
rectify them and start the extract process again.


GGSCI>info all


This time we see them running.


Destination Side

Now lets try to start replicat rep1
GGSCI>start manger
manager started


GGSCI>start replicat rep1sending start request to manager...
Replicat rep1 started


Testing


Sourec side
a) create a test table and insert 2 rows into it.




Destination Side

To overcome errors like
ERROR OGG-01223 TCP/IP error 110 (Connection timed out). 
and
ERROR OGG-01224 TCP/IP error 10061 (No connection could be made because the target machine actively refused it.)



Note: I had to Disable firewalls on both machines to let extract intercat with replicat for the time being.
The best solution is to open ports through iptables.


1. First look your listner is running or not
2. use Ping to check connection between machines
3. use tnsping connection between databases. check you have correct entries in tnsnames.ora
4. Try to connect to other database through sqlplus.

select * from test; --to see those rows have arrived



Thanks

No comments: