goldengate for oracle to sqlserver

Cross RDBMS replication using GoldenGate
One of the very popular uses of GoldenGate is to replicate data between databases running
in different RDBMS. Different RDBMS systems have different data types and use different
data structures to store the data. It is due to these complications that replicating between
different systems becomesa complex task. GoldenGate extracts data from a database and
stores it in its proprietary format. This data in proprietary format can then be replayed in any
other supported database. You can use this feature to perform a one-off data migration from
one RDBMS to another or you can use it to set up a permanent replication between a data set
from one RDBMS to another.
In this recipe we will set up a continuous replication between an Oracle database and an SQL
Server database. We will also cover the steps to install and configure GoldenGate in an SQL
Server environment.
Getting ready
For this recipe, we will set up GoldenGate replication between an Oracle instance called
dboratestwhich is running on an Oracle Enterprise Linux server called prim1-ol6-112,
and SQL Server 2012 database which is running on a Windows server called oggwin.
localdomain. The setup does not cover the steps to install SQL Server 2012 binaries, set
up an SQL Server instance and to create the oggtestdatabase. It is assumed that you have
already installed and configured both the source and target databases and a SCOTTschema
with the EMPtable has been created. The EMPtable has similar rows in both databases
therefore the setup does not require any initial load.
Advanced Administration Tasks – Part II
We will be installing Oracle GoldenGate on the Windows server in this recipe. For this we have
downloaded Oracle GoldenGate V 11.2.1.0.1 for SQL Server 2008 on Windows 2003 and
2008 (64 bit). We will also be referring to some steps from previous recipes about installing
GoldenGate in the Linux environment.
How to do it...
The steps to set up the replication between the Oracle database and the SQL Server database
are as follows:
Perform the following steps on the prim1-ol6-112 (source server):
1.  Follow the steps from the Installing Oracle GoldenGate in an x86_64 Linux-based
environmentrecipe in Chapter 1, Installation and Initial Setup, to install Oracle
GoldenGate 112101 on prim1-ol6-112.
2.  Follow the steps from the Enabling supplemental logging in the source database
and Preparing the source database for GoldenGate setuprecipes in Chapter 1,
Installation and Initial Setup, to set up a GoldenGate Administrator user in the
DBORATESdatabase on the prim1-ol6-112 server.
3.  Create a Manager process parameter file as follows:
EDIT PARAMS MGR
PORT 7809
DYNAMICPORTLIST 7810-7820, 7830
AUTOSTART ER *
AUTORESTART ER *, RETRIES 4, WAITMINUTES 4
PURGEOLDEXTRACTS /u01/app/ggate/dirdat/st*, USECHECKPOINTS,
MINKEEPHOURS 2
4.  Create an Extract process parameter file as follows:
EDIT PARAMS EGGTEST1
EXTRACT EGGTEST1
USERID GGATE_ADMIN@DBORATEST, PASSWORD ******
EXTTRAIL /u01/app/ggate/dirdat/st
TABLE SCOTT.EMP;
5.  Add the Extract process to the GoldenGate instance:
ADD EXTRACT EGGTEST1, TRANLOG, BEGIN NOW
6.  Add the local trail to the Extract process configuration:
ADD EXTTRAIL /u01/app/ggate/dirdat/st, EXTRACT EGGTEST1
7.  Create a Datapump process parameter file as follows:
EXTRACT PGGTEST1
USERID GGATE_ADMIN@DBORATEST, PASSWORD *****
RMTHOST oggwin.localdomain, MGRPORT 7809
RMTTRAIL C:\ggate\dirdat\rt
TABLE SCOTT.EMP;
8.  Add the Datapump extract to the GoldenGate instance:
ADD EXTRACT PGGTEST1, EXTTRAILSOURCE /u01/app/ggate/dirdat/st
9.  Add the remote trail to the Datapump configuration:
ADD RMTTRAIL c:\ggate\dirdat\rt, EXTRACT PGGTEST1
10. Create a parameter file for the defgenutility as follows:
cd /u01/app/ggate/dirprm
vi defs.prm
DEFSFILE ./dirdef/scott_defs.def
USERID ggate_admin@dboratest, PASSWORD GGATE_ADMIN
TABLE SCOTT.EMP;
11. Generate the definitions using the parameter file:
[ggate@prim1-ol6-112 ggate]$ ./defgen paramfile ./dirprm/defs.prm
*********************************************************
Oracle GoldenGate Table Definition Generator for Oracle
Version 11.2.1.0.1
OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 05:08:19
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights
reserved.
Starting at 2013-06-18 10:01:48
*********************************************************
Operating System Version:
Linux
Version #1 SMP Sat Jun 23 02:39:07 EDT 2012, Release
2.6.39-200.24.1.el6uek.x86_64
Node: prim1-ol6-112.localdomain
Machine: x86_64
soft limit hard limit
Address Space Size : unlimited unlimited
Heap Size : unlimited unlimited
File Size : unlimited unlimited
CPU Time : unlimited unlimited
Process id: 2855
*********************************************************
** Running with the following parameters
**
*********************************************************
DEFSFILE ./dirdef/scott_defs.def
USERID ggate_admin@dboratest, PASSWORD ***********
TABLE SCOTT.EMP;
Retrieving definition for SCOTT.EMP
Definitions generated for 1 table in ./dirdef/scott_defs.def
Perform the following steps on oggwin.localdomain (target server):
1.  Copy the GoldenGate binaries to the Windows server.
2.  InstallGoldenGate binaries to c:\ggateby unzipping the downloaded binaries file.
3.  Create GoldenGate subdirectories as follows:
C:\ggate>ggsci
Oracle GoldenGate Command Interpreter for SQL Server
Version 11.2.1.0.2 OGGCORE_11.2.1.0.2T3_PLATFORMS_120724.2205
Windows x64 (optimized), Microsoft SQL Server on Jul 25 2012
03:04:52
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights
reserved.
GGSCI (oggwin) 1> create subdirs
Creating subdirectories under current directory C:\ggate
Parameter files C:\ggate\dirprm: already exists
Report files C:\ggate\dirrpt: created
Checkpoint files C:\ggate\dirchk: created
Process status files C:\ggate\dirpcs: created
SQL script files C:\ggate\dirsql: created
Database definitions files C:\ggate\dirdef: created
Extract data files C:\ggate\dirdat: created
Temporary files C:\ggate\dirtmp: created
Stdout files C:\ggate\dirout: created
4.  Add the GoldenGate Manager process as a Windows service:
C:\ggate>INSTALL ADDSERVICE
Service 'GGSMGR' created.
Install program terminated normally.
5.  Create the GoldenGate Administrator user in the Oggtestdatabase in the SQL
Server Management Studio. For this, login to the SQL Server Management
Studio as sa.
6.  Expand the Securityoption and right-click on Logins.
7.  Click on New Login:

8.  Enter the login name, password, select default database as oggtest.
Advanced Administration Tasks – Part II
9.  Next, click on User Mapping and select the oggtestdatabase and db_ownerrole
as follows:
10. Click OKto create the user.
11. Next, create an ODBC data source to enable GoldenGate to access the SQL
Server database. For this go to Control Panel| Administrative Tools| Data
Sources (ODBC):
12. Clickon System DSNandthen on Add.
Advanced Administration Tasks – Part II
13. Select SQL Server Native clientdriver and click on Finish:
14. Enter a name for this connection,a description, and select local sql server instance
and click on Next.
15. On the next window select SQL Server Authenticationand specify the GGATE_ADMIN
user and password, and click on Next:
16. Change the default database to oggtestand click on Next.
17.  Click on Finishin the next window:
18. You should see the data source creation summary. Click on Test Data Source to test
it and click on OKto create the data source.
19. Copy the source definitions file /u01/app/ggate/dirdef/scott_defs.deffrom
prim1-ol6-112to c:\ggate\dirdef\on the oggwinserver.
20. Create a Manager process as follows:
C:\ggate>ggsci
Oracle GoldenGate Command Interpreter for SQL Server
Version 11.2.1.0.2 OGGCORE_11.2.1.0.2T3_PLATFORMS_120724.2205
Windows x64 (optimized), Microsoft SQL Server on Jul 25 2012
03:04:52
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights
reserved.
GGSCI (oggwin) 1> edit params mgr
PORT 7809
DYNAMICPORTLIST 7810-7820, 7830
AUTOSTART ER *
AUTORESTART ER *, RETRIES 4, WAITMINUTES 4
PURGEOLDEXTRACTS C:\GGATE\DIRDAT\tt*, USECHECKPOINTS, MINKEEPHOURS
2
Advanced Administration Tasks – Part II
21. Start the Manager process:
GGSCI (oggwin) 3> start mgr
Starting Manager as service ('GGSMGR')...
Service started.
22. Create a Checkpoint table in thetarget database:
GGSCI (oggwin) 8> DBLOGIN SOURCEDB OGGTEST, USERID ADMIN
Password:
2013-06-18 17:32:14 INFO OGG-03036 Database character set
identified as windows-1252. Locale: en_US.
2013-06-18 17:32:14 INFO OGG-03037 Session character set
identified as windows-1252.
Successfully logged into database.
GGSCI (oggwin) 10> ADD CHECKPOINTTABLE CHECKPOINT
Successfully created checkpoint table CHECKPOINT.
23. Create a Replicat process parameter file as follows:
GGSCI (oggwin) 2> edit params rggtest1
REPLICAT RGGTEST1
TARGETDB OGGTEST, USERID ADMIN, PASSWORD ADMIN
SOURCEDEFS ./dirdef/scott_defs.def
DISCARDFILE ./dirrpt/RGGTEST1.DSC, PURGE
MAP SCOTT.EMP, TARGET SCOTT.EMP;
24. Add the Replicat process to the Manager configuration:
GGSCI (oggwin) 4> ADD REPLICAT RGGTEST1, EXTTRAIL ./dirdat/rt,
CHECKPOINTTABLE CHECKPOINT
REPLICAT added.
25. Start the Extract, Datapump, and Replicat processes.
26. Let's perform some sample DML operations on the EMPtable in the source database.
SQL> SELECT ENAME FROM EMP WHERE EMPNO=7782;
ENAME
-------------------------CLARK
SQL> UPDATE EMP SET ENAME='JAMES' WHERE EMPNO=7782;
1 row updated.
Chapter 8
SQL> SELECT COUNT(*) FROM EMP WHERE EMPNO=7566;
COUNT(*)
----------1
SQL> DELETE EMP WHERE EMPNO=7566;
1 row deleted.
SQL> INSERT INTO EMP VALUES(8888,'ROBIN','CLERK',7788,TO_DATE('14-01-1985','DD-MM-YYYY'),9850,NULL,20);
1 row created.
SQL> commit;
Commit complete.
27.  VerifytheDML changes in the target database.
Advanced Administration Tasks – Part II
How it works...
In this recipe we went through the steps to set up a replication between an Oracle database
environment and a SQL server database environment. In steps 1 and 2, the setup begins with
GoldenGate installation in the Linux environment for which you should refer to some recipes
from Chapter 1, Installation and Initial Setup. In the next steps we created a Manager process,
and set up an Extract and a Datapump process for the GoldenGate setup in the Oracle
environment. Both the Oracle and SQL Server systems use different data types and have their
own ways of storing table structures. Copying data from one system to another requires these
table definitions to be converted. This is done by generating a definitions file, which is done in
steps 11 to 13.
Alter this under the steps for target server, we install GoldenGate binaries on the Windows
machine. The installation is straightforward and only requiresextracting the binaries from the
ZIP file and creating subdirectories. GoldenGate requires an Administrator user to be set up
in the database to be able to apply the extracted records and read the required metadata.
This user is created in steps 5 to 10. In a SQL server environment, the client connectivity is
performed by creating an ODBC connection at the operating-system level. This connection
has the relevant details; for example, the default database to connect to, the user ID and
password to be used for connection, and so on. In this setup we have created this ODBC
connection in steps 11 to 18. Once the connection is in place and it is tested, we need to
configure the target's GoldenGate setup. For this we copied the definitions file to the target
server and create a Manager process. We also created a Checkpoint table in the target SQL
Server database by connecting from GoldenGate using the GoldenGate Administrator user.
In steps 23 to 24, we create a Replicat process and then start all the processes.
Inorder to test the replication, we perform some DML transactions in the source database
and then verify the data in the target database.
标签: 暂无标签
dongxujian

写了 86 篇文章,拥有财富 384,被 13 人关注

转播转播 分享分享 分享淘帖
回复

使用道具

成为第一个吐槽的人

您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

意见
反馈