Oracle GoldenGate for MS SQL Server 2008 Page 1 Oracle GoldenGate for MS SQL Server 2008 Objective Upon completion of this lesson, you will be able to configure GoldenGate to provide SQL Server to SQL Server transactional data management using log-based extraction. During this lesson, you will learn how to: Prepare your user environment Prepare the database Configure and start the change capture process of database operations Configure and execute the initial data load process Configure and start the change delivery process of database operations SQL Server configuration The following diagram illustrates a SQL Server to SQL Server configuration. Windows server <target> MS SQL Server <dsn> Target <schema> Windows server <source> MS SQL Server <dsn> Source <schema> Network Extract Replicat Collector Trails Manager Manager Log
31
Embed
Oracle GoldenGate for MS SQL Server 2008 Extract …...Oracle GoldenGate for MS SQL Server 2008 Page 1 Oracle GoldenGate for MS SQL Server 2008 Objective Upon completion of this lesson,
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Oracle GoldenGate for MS SQL Server 2008
Page 1
Oracle GoldenGate for MS SQL Server 2008
Objective
Upon completion of this lesson, you will be able to configure GoldenGate to provide SQL
Server to SQL Server transactional data management using log-based extraction.
During this lesson, you will learn how to:
Prepare your user environment
Prepare the database
Configure and start the change capture process of database operations
Configure and execute the initial data load process
Configure and start the change delivery process of database operations
SQL Server configuration
The following diagram illustrates a SQL Server to SQL Server configuration.
Windows server <target>
MS SQL Server
<dsn>
Target
<schema>
Windows server <source>
MS SQL Server
<dsn>
Source
<schema> Network
Extract
Replicat
Collector
Trails
Manager Manager
Log
Oracle GoldenGate for MS SQL Server 2008
Page 2
Overview of Tasks
Prepare the GoldenGate Environment
The GoldenGate application must be installed on both the source and target systems. A
checkpoint table and Manager Service will be implemented.
In order to execute this lesson, the SQL Server source database must be configured to support
log-based extraction, and an ODBC data source must be created and configured correctly. The
source and target tables will be created with scripts provided in the GoldenGate installation.
For log-based SQL Server extraction, additional logging must be enabled to provide enough
information to reconstruct update operations.
Configure Initial Data Load
Initial database synchronization is almost always required. To initially load data across
actively changing databases, you have limited choices. GoldenGate provides the ability to
perform initial data synchronization while your application remains active. There are several
techniques available, including sending data to files to be loaded by Replicat or by Microsoft
BCP/DTS bulk-load utility, or sending data directly to Replicat.
This lesson demonstrates extracting the data with Extract and sending the data directly to the
Replicat process. This is known as the Direct Load method.
Configure Change Capture
The Extract process is configured to capture change data directly from the SQL Server
transaction logs and distribute the changes to a series of files known as a GoldenGate trails.
Configure Change Delivery
Once the tables have been initially loaded with data, the Replicat process is configured to
deliver the captured change data into the target database.
<source> server <target> server
Network
Initial
ExtractInitial
Replicat
MS SQL Server
<dsn>
Target
<schema>
MS SQL Server
<dsn>
Source
<schema>
Prepare the Environment
Page 3
Exercise 1.
Prepare the Environment
Objective
The goals of this exercise are to:
Create the database
Create SQL Server logins and users
Create ODBC data source.
Set up transaction logging.
Create tables and populate source data.
Prerequisites
This lab assumes that the GLOBALS parameters have been created with a <mgr service> name
and that the Manager service has been added. This should have been done when installing
GoldenGate for Windows.
Prepare the SQL Server 2008 source environment
Install Manager
1. Configure Manager process on the source
Execute the following commands on the <source> system.
Note! The port numbers must be unique if you are installing GoldenGate more than once on
the same server.
Shell> ggsci
GGSCI> EDIT PARAMS MGR
In the parameter file, enter the following parameter, then save and close the file.
PORT <port>
Start Manager.
GGSCI> START MANAGER
Verify the results:
Prepare the Environment
Page 4
GGSCI> INFO MANAGER
Create the database
2. Create the database
From Start>Programs, run SQL Server Management Studio.
Enter the name of the local SQL Server instance, then click connect.
Note: These instructions assume SQL Server Authentication which requires the
more complex, double layer, of authentication. SQL Server Authentication is an
option only if it is permitted at the server level, and only Windows Authentication is
enabled by default. If you are using Windows Authentication, you can leave out
most of the login and password entries.
This displays the main SQL Server Management Studio dialog box. Right, right-click Database and select the New Database option.
Prepare the Environment
Page 5
The New Database dialog box appears. In the Name box, type the <database> from
the Lab Preparation worksheet.
Prepare the Environment
Page 6
Click OK to add the database.
The main SQL Server Management Studio dialog box reappears.
3. Create SQL Server logins and users
Right click Security and select the New > Login.
Prepare the Environment
Page 7
The New Login dialog box appears.
For Name, type the <login>.
Select Authentication,
Prepare the Environment
Page 8
If you selected SQL Server Authentication, type the <password> in the two
Password fields.
Under Defaults, select your <database> for Database, and leave Language set to the
default.
Do not click OK. Instead, from Select a page in the upper left-hand box, double click
Server Roles.
Under Server Role, check the box for the System Administrators role.
Click OK to exit.
The next step creates a schema that you will associate with the new user.
While you have the database selected, click on the New Query button in the main
menu.
The right side of the dialog displays the SQL Query interface. Type in:
Prepare the Environment
Page 9
create schema <schema_name>;
And press the Execute button from the toolbar.
Now you need to associate the new user with the login and the schema that you have created
with the new database.
In the SQL Query interface, type in:
create user <user_name>
for login <select login_name>
with default_schema=<schema_name>;
And press the Execute button from the toolbar.
Prepare the Environment
Page 10
4. Create the ODBC system data source name
The GoldenGate Extract process connects to a SQL Server database through an ODBC (Open
Database Connectivity) connection. Both the Extract and Replicat components of GoldenGate
require that a system data source name (DSN) be established, which stores the information
about how to connect to the SQL Server.
Click Start > Settings > Control Panel.
Double-click Administrative Tools.
Double-click Data Sources (ODBC) to open the ODBC Data Source Administrator
dialog box.
Click the System DSN tab, and then click the Add button. The Create New Data
Source dialog box appears.
Prepare the Environment
Page 11
Select the SQL Server Native Client 10.0 driver and then click Finish. The Create a
New Data Source to SQL Server dialog box appears.
For Name, type <dsn>.
Prepare the Environment
Page 12
Optionally type in a description, type for this source DSN.
For Which SQL Server do you want to connect to, select local if SQL Server is on
the local system, or enter the server name at your SQL Server location.
Click Next.
Answer the question about how SQL Server should verify the login by selecting the option that you entered when creating the <login>. Then type <login> in Login ID and
<password> in Password.
Click Next.
Make certain the default database is set to the database that you created; otherwise
select Change the default database to: and select it. Leave the other settings to their
defaults to use ANSI.
Prepare the Environment
Page 13
Click Next.
Leave the next dialog box set to the defaults, and click Finish.
In the confirmation, click Test Data Source to test the connection.
Close the confirmation dialog box and the Create a New Data Source box.
You can leave the SQL Server Management Studio running on the source system,
because you will be using it later.
5. Create the practice tables and insert source data
Execute the following commands on the <source> system only.
Go to SQL Server Management Studio, select your database and select New Query
from the toolbar.
If the correct database is not displayed in the drop down box, click on the arrow and
select it from the list.
Click the File > Open and navigate to the demo_mss_create.sql script.
Click Open to open the script in the New Query window.
Execute the script by clicking the Execute Query button on the toolbar.
Prepare the Environment
Page 14
Verify the results using the following commands in the input window:
sp_help tcustmer
go
sp_help tcustord
go
Click the X button to close the input tab. Click New Query whenever you need to run
another SQL command.
Following the steps you used to execute the table create script, run the
demo_mss_insert.sql script to insert source data into the source tcustmer and
tcustord tables.
Note! Run this on the source only.
Verify the results as you did before.
Leave the SQL Management Studio running on the source system.
Prepare the Environment
Page 15
Prepare for transaction logging
To support GoldenGate extraction, the following are required. Execute these steps on the <source> system only.
Log truncation and non-logged bulk copy must be turned off.
The SQL Server database must be set to the full recovery model (this is the default for
SQL Server 2008).
At least one full database backup must be done before GoldenGate processes are
started for the first time.
Additional log data must be enabled so GoldenGate can reconstruct update
operations.
6. Turn off log truncation and bulk copy
In SQL Management Studio on the source system perform the following steps to turn off log
truncation and bulk copy.
Clear the input window and then use the following command to check the status of
the log truncation option. Type the command in the input window (upper window),
then click the F5 key to execute it.
exec sp_dboption '<database>', 'trunc. log on chkpt.'
The following response appears in the results (lower) window with a status of either
ON or OFF.
If log truncation is ON, turn it off by executing the following command.
exec sp_dboption '<database>', 'trunc. log on chkpt.', false
The output should now show a CurrentSetting of OFF’.
Check the status of the non-logged bulk copy option by executing the following
Issue the following commands to force the logging of the full before and after image
for updates.
GGSCI > ADD TRANDATA <owner/schema>.tcustmer
GGSCI > ADD TRANDATA <owner/schema>.tcustord
Verify that supplemental logging has been turned on for these tables.
GGSCI> INFO TRANDATA <owner/schema>.tcust*
Prepare the SQL Server 2008 target system
Install Manager
1. Configure Manager process on the target
Execute the following commands on the <target> system.
Note! The port numbers must be unique if you are installing GoldenGate more than once on
the same server.
Shell> cd <install location>
Prepare the Environment
Page 17
Shell> ggsci
GGSCI> EDIT PARAMS MGR
In the parameter file, enter the following parameter, then save and close the file.
-- GoldenGate Manager Parameter file
PORT <port>
Start Manager.
GGSCI> START MANAGER
Verify the results:
GGSCI> INFO MANAGER
Steps to create the database
2. Create the database
From Start>Programs, run SQL Server Management Studio.
Enter the name of the local SQL Server instance, then click connect.
Note: These instructions assume SQL Server Authentication which requires the
more complex, double layer, of authentication. For only Windows Authentication,
you can leave out most of the login and password entries.
This displays the main SQL Server Management Studio dialog box. Right, right-click Database and select the New Database option.
The New Database dialog box appears. In the Name box, type the <database> from
the Lab Preparation worksheet.
Click OK to add the database.
The main SQL Server Management Studio dialog box reappears.
3. Create SQL Server logins and users
Right-click Security and select the New > Login.
The New Login dialog box appears.
For Name, type the <login>.
Select Authentication,
Prepare the Environment
Page 18
If you selected SQL Server Authentication, type the <password> in the two
Password fields.
Under Defaults, select your <database> for Database, and leave Language set to the
default.
Do not click OK. Instead, from Select a page in the upper left-hand box, double click User Mapping.
In the upper Users mapped to this login area, activate the checkmark next to your
database.
In the lower Database role membership for <database> area, check the box for the
db_owner role.
Click OK to exit.
The next step creates a schema that you will associate with the new user.
Prepare the Environment
Page 19
While you have the database selected, click on the New Query button in the main
menu.
The right side of the dialog displays the SQL Query interface. Type in:
create schema <schema_name>;
And press the Execute button from the toolbar.
Now you need to associate the new user and the schema that you have created with the new
database.
In the SQL Query interface, type in:
alter user <user_name>
with default_schema=<schema_name>;
And press the Execute button from the toolbar.
4. Create the ODBC system data source name
The GoldenGate Extract process connects to a SQL Server database through an ODBC (Open
Database Connectivity) connection. Both the Extract and Replicat components of GoldenGate
require that a system data source name (DSN) be established, which stores the information
about how to connect to the SQL Server.
Click Start > Settings > Control Panel.
Double-click Administrative Tools.
Double-click Data Sources (ODBC) to open the ODBC Data Source Administrator
dialog box.
Click the System DSN tab, and then click the Add button. The Create New Data
Source dialog box appears.
Select the SQL Server Native Client 10.0 driver and then click Finish. The Create a
New Data Source to SQL Server dialog box appears.
For Name, type <dsn>.
For a description, type "GG Training Data source" when creating this source DSN.
This field is optional.
For Which SQL Server do you want to connect to, select the server name.
Click Next.
Answer the question about how SQL Server should verify the login by selecting the option that you entered when creating the <login>. Then type <login> in Login ID
and <password> in Password.
Prepare the Environment
Page 20
Click Next.
Make certain the default database is set to the database that you created; otherwise select Change the default database to: and select it. Leave the other settings to their
defaults to use ANSI.
Click Next.
Leave the next dialog box set to the defaults, and click Finish.
In the confirmation, click Test Data Source to test the connection.
Close the confirmation dialog box and the Create a New Data Source box.
5. Create the practice tables
Execute the following commands on the <target> system.
Go to SQL Server Management Studio, select your database and select New Query
from the toolbar.
If the correct database is not displayed in the drop down box, click on the arrow and
select it from the list.
Click the File > Open and navigate to the demo_mss_create.sql script.
Note: Just run the "create" script. Do not run the insert script. The data will be loaded
into the target database using the Oracle GoldenGate Direct Load Method - the steps
are detailed in the next section.
Click Open to open the script in the New Query window.
Execute the script by clicking the Execute Query button on the toolbar.
Verify the results using the following commands in the input window:
sp_help tcustmer
go
sp_help tcustord
go
Initial Data Load using Direct Load Method
Page 21
Exercise 2.
Initial Data Load using Direct Load Method
Objective
These steps configure initial load groups that copy source data and apply it to the target
tables.
Steps to configure initial load
1. Add the initial data load extract batch task group
Execute the following commands on the <source> system to add an Extract process called
EINI<unique id>1.
Execute the following command in GGSCI to create the batch task.
Shell> cd <install location>
Shell> ggsci
GGSCI> ADD EXTRACT EINI<unique id>, SOURCEISTABLE
Verify the results:
GGSCI> INFO EXTRACT EINI<unique id>
2. Configure the initial data load Extract parameter file
Execute the following commands on the <source> system.
Execute the following command in GGSCI to open the editor.