Oracle GoldenGate on Exadata: Replication from Oracle 11gR2 to Oracle 11gR2
Overview
- Prepare your environment to configure the Oracle GoldenGate processes.
- Configure and start the change capture of database operations.
- Configure and start the change delivery of database operations.
- Manager:
- There is a Manager on the source host and a separate Manager on the target host. The Manager starts and stops the other processes on the source and target instances. The Manager is not required for passing traffic once the Extract or Replicat is running.
- Initial Load:
- Optional. Used to populate the target tables one time. It can read either from the source tables directly or from ASCII files. This OBE ignores the Initial Load. See other OBEs for how to do that.
- Extract:
- Runs on the source to capture transaction data to trail files. There are two versions of Extract: Classic (this OBE) and Integrated.
- Data Pump:
- Optional, but highly recommended. The Data Pump sends trail files from the source instance to the target instance over an IP network. Technically the Data Pump is a secondary Extract.
- Replicat:
- Delivers data to the target database. Normally the Replicat runs on the target. Yes, the spelling is correct, there is no final "e" (long story).
- View the basic GoldenGate Oracle-to-Oracle OBE for the "normal" tasks such as Initial Load, viewing Statistics, and so on. This OBE only concentrates on the unique Exadata aspects. See Resources at the bottom for more links.
- View the White Paper, especially the section on the My Oracle Support (MOS, requires an account to view) note 1054431.1.
- The source host has Oracle 11gR2 database with sample schemas installed and running.
- Oracle GoldenGate for 64-bit Linux zip distribution is staged on both the source and the target
/home/user/directories. This is available from the Oracle Software Delivery Cloud. - The Exadata Cluster Services is installed and running.
- Some_Command
- You type this as a command or a value. Example:
Enter ./ggsci to start the command line interpreter.
- Some_Prompt
- The system responds with this as a prompt or reply. Example:
After the welcome splash banner, you can enter commands at the GGSCI (host01) 1> prompt.
- Some_Button
- Click this on-screen button. Example:
After selecting the version you want, click Continue to start the download.
- Some_Variable
- A variable that you substitute with a real value. Example:
Enter your userid/password at the prompt.
- Some_Filename
- A filename, path, or folder/directory. Example:
Edit the hosts file in the /etc directory.
- Some_Code
- A keyword or code element. Example:
Change the parameter HandleCollisions to NoHandleCollisions after the initial load.
- p=process=
- e(xtract), p(ump), r(eplicat), i(nitial), d(efgen), s(tartup).
- xxxx=project=
- All files related to a common project xxxx, for example hr, sales, engr, test.
- hh=host-to-host=
- aa, ab, ba, bb, as indicated by source and target host names where a=host01, and b=host02. Later on you will see that you cannot use numbers as part of some file names, so better not to go there at all.
- ext=extension=
- prm=parameter (stored in dirprm/), dsc=discard, rpt=report (stored in dirrpt/), def=definition (stored in dirdef/), oby=obey (stored in installation directory), sql=SQL (stored in dirsql/).
Purpose
Upon completion of this Oracle-By-Example (OBE) tutorial, you will be able to keep two heterogeneous databases synchronized using Oracle GoldenGate (OGG); in this case a Linux Oracle 11gR2 database to an Exadata 11gR2 database.
During this lesson, you will learn how to:
Time to Complete
Approximately 2 hours
Introduction
Oracle GoldenGate on Exadata: Replication from Oracle 11gR2 to Oracle 11gR2
Oracle GoldenGate provides very fast replication of heterogeneous databases by reading transaction logs and writing the changes to one or more target databases. There are five processes involved in a typical environment:
Linux Oracle to Exadata configuration (Unidirectional)
The diagram illustrates a configuration using a primary Extract process creating a remote trail on the target. The Replicat process applies the changes from the remote trail to the target RAC database. It is not necessary for the source host01 to be Linux nor 64-bit.
In summary, the environment is:
| Host Name | Screen Color | OS | Hardware | Database | SID | OGG Source/Target | Primary Console |
|---|---|---|---|---|---|---|---|
| host01 | Red | Linux 64-bit | Single CPU PC | Oracle 11gR2 | orcl | Source | Both |
| qr01db02 (Node02) | Yellow | Linux 64-bit | Exadata DB node | Oracle 11gR2 RAC | dbm2 | Target | GGSCI |
| qr01db01 (Node01) | Green | Linux 64-bit | Exadata DB node | Oracle 11gR2 RAC | dbm1 | Target | SQL*Plus |
Prerequisites
The prerequisites for this lab include the following:
Bear in mind that there are two hosts: host01 and host02; and that each host has three environment prompts: OS, GGSCI, and SQL. That makes six different places in which you could be typing! Try to be extra careful about which command you enter in which location. The wrong command in the wrong context is the most common error.
Overview of Tasks
Prepare the Environment
In order to execute this lesson, the GoldenGate application must be installed on both the source and target systems. The installation includes a sample database and scripts to generate initial data as well as subsequent update operations. The source and target tables are created and loaded with initial data. The GoldenGate Manager processes are also started so that other processes may be configured and started. And finally, source definitions are generated and transferred to the target system.
Configure Change Capture (Extract)
For audited tables, the Extract process is configured to capture change data directly from the TMF audit trails and store the changes in a data queue known as a GoldenGate local trail.
Configure Change Delivery (Replicat)
Once the tables have been initially loaded with data and the Extract process is capturing all operations, the Replicat process is configured to deliver the captured operations to the target database.
Typographic Conventions
Text color and font in the directions and in the screens should be interpreted as follows:
File and Process Naming Conventions
File and process naming conventions can be whatever works for you or your company. Here are the sample conventions used in this OBE:
pxxxxhh.ext
where:
1. Preparing the Environment
- Prepare the Operating System (OS) environment variables as defined in
.profileor.bash_profileor equivalent. - Configure the application VIP address.
- Test
tnspingfor future sqlplus connectivity. - Prepare the Oracle Database 11gR2 by creating OGG admin users and altering the database parameters.
Objective
The goals of this exercise are to:
Commands you type will be in blue monospaced font. System responses will be in black monospaced font.
1.1 Preparing the OS Environment Variables
You will configure the .profile for environment variables, and the /etc/hosts file for host aliases. You will do this on all three hosts: the source and the two target nodes. Your existing profiles may have lines in them, this step focuses more on the lines to add to them.
Use your editor of choice and examine the initial state of the profile on the target host node 1. Add the variables for ORACLE_BASE, ORACLE_HOME, OGG_HOME, and LD_LIBRARY_PATH. Leave the other lines as they are.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ~]$ vi .bash_profile 1 # .bash_profile 2 3 # Get the aliases and functions 4 if [ -f ~/.bashrc ]; then 5 . ~/.bashrc 6 fi 7 8 # User specific environment and startup programs 9 10 PATH=$PATH:$HOME/bin 11 12 export PATH 13 export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 14 export ORACLE_SID=dbm1 15 ORAENV_ASK=NO;. /usr/local/bin/oraenv > /dev/null 2<&1 16 alias gogrid='export ORACLE_HOME=/u01/app/11.2.0/grid;export ORACLE_SID=+ASM1;. /usr/local/bin/oraenv > /dev/null 2<&1;env |grep ORA|grep -v BASE' 17 alias godb='export ORACLE_HOME=/u01/app/oracle/product/11.2.0 /dbhome_1;export ORACLE_SID=dbm1;. /usr/local/bin/oraenv > /d ev/null 2<&1;env|grep ORA|grep -v BASE' [oracle@qr01db01 ~]$ vi .bash_profile 1 # .bash_profile 2 3 # Get the aliases and functions 4 if [ -f ~/.bashrc ]; then 5 . ~/.bashrc 6 fi 7 8 # User specific environment and startup programs 9 10 PATH=$PATH:$HOME/bin 11 12 export PATH 13 export ORACLE_BASE=/u01/app/oracle 14 export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 15 export OGG_HOME=$ORACLE_BASE/ogg 16 export LD_LIBRARY_PATH=$ORACLE_HOME/lib 17 export ORACLE_SID=dbm1 18 ORAENV_ASK=NO;. /usr/local/bin/oraenv > /dev/null 2<&1 19 alias gogrid='export ORACLE_HOME=/u01/app/11.2.0/grid;export ORACLE_SID=+ASM1;. /usr/local/bin/oraenv > /dev/null 2<&1;env |grep ORA|grep -v BASE' 20 alias godb='export ORACLE_HOME=/u01/app/oracle/product/11.2.0 /dbhome_1;export ORACLE_SID=dbm1;. /usr/local/bin/oraenv > /d ev/null 2<&1;env|grep ORA|grep -v BASE' [oracle@qr01db02 ~]$ |
The alias gogrid and alias godb have been added for another demo, they are not part of the default profile. They make it easier to switch between the Grid Infrastructure and DB environments. Note that the aliases each span several lines. Be mindful to not introduce extra returns on those lines.
Switch user to root and edit the /etc/hosts file to append an alias for host01. Use the proper IP address for your environment.
| Exadata - Node 1 (target) |
[oracle@qr01db02 ~]$ su - root Password: [root@qr01db02 ~]# vi /etc/hosts 127.0.0.1 localhost.localdomain localhost (...rest of file not shown, too many possibilities...) [root@qr01db02 ~]# tail -1 /etc/hosts 192.0.2.16 host01.example.com host01 [root@qr01db02 ~]# exit [oracle@qr01db02 ~]$ |
The tail command assumes you appended the host01 address to the end of the file. Exit out of root when you are done editing.
Do the exact same thing for the other target node 2. The lines are not shown, they are the same for qr01db01 and qr01db02.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ~]$ vi .bash_profile (REPEAT ON OTHER QR01db02) [oracle@qr01db02 ~]$ su - root [root@qr01db02 ~]# vi /etc/hosts (REPEAT ON OTHER QR01db02) [root@qr01db02 ~]# exit [oracle@qr01db02 ~]$ |
The two nodes should have identical profiles and very similar /etc/hosts.
Do the same thing for the source host. There may be slight difference in where things are installed, but you are defining the same four environment variables: ORACLE_BASE, ORACLE_HOME, OGG_HOME, and LD_LIBRARY_PATH. The /etc/hosts points to the Exadata address.
| Host01 - Linux (source) |
[oracle@host01 ~]$ vi .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs ORACLE_BASE=/u01/app/oracle ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_home1 OGG_HOME=$ORACLE_BASE/ogg ORACLE_SID=orcl PATH=$PATH:$HOME/bin:$ORACLE_HOME:$ORACLE_HOME/bin LD_LIBRARY_PATH=$ORACLE_HOME/lib export PATH LD_LIBRARY_PATH export ORACLE_HOME ORACLE_BASE ORACLE_SID OGG_HOME [oracle@host01 ~]$ su - root Password: [root@host01 ~]# vi /etc/hosts 127.0.0.1 localhost.localdomain localhost (...rest of file not shown, too many possibilities...) [root@host01 ~]# tail -1 /etc/hosts 192.0.2.99 qr01-vip.example.com qr01-vip [root@host01 ~]# exit [oracle@host01 ~]$ |
This time the /etc/hosts addition is for an application "vip" address on Exadata that gets defined in the next step. For now, just enter that line on faith.
This completes preparing the OS environment variables.
1.2 Configure the Application Virtual IP (VIP) Address
The application Virtual IP (VIP) is part of Cluster Ready Services (CRS). It is used to define a single new address shared by multiple nodes. The purpose is for the source to point to a single target address regardless of which target node is handling it. This is similar to the Single Client Access Name (SCAN) address feature of Real Application Clusters (RAC), except that SCAN is only for use by the database, whereas VIP can be used by any application (in this example, GoldenGate).
On target node 2, perform the following tasks as root or oracle as indicated. You create the VIP as root, but you run it as oracle. The VIP address must be any unused address in the subnet configured as the public network for the cluster. The example uses 192.0.2.99 because the grep returns the 192.0.2.0 subnet, so .99 is unused in that subnet. It needs to match the /etc/hosts file on the source in the previous step.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ogg]$ su - root Password: [root@qr01db02 ~]# cd /u01/app/11.2.0/grid/bin [root@qr01db02 bin]# ./crsctl stat res -p | grep -ie .network -ie subnet | grep -ie name -ie subnet NAME=ora.net1.network USR_ORA_SUBNET=192.0.2.0 [root@qr01db02 bin]# ./appvipcfg create -network=1 -ip=192.0.2.99 -vipname=gg_vip_trg -user=root Production Copyright 2007, 2008, Oracle.All rights reserved 2013-02-27 14:06:52: Creating Resource Type 2013-02-27 14:06:52: Executing /u01/app/11.2.0/grid/bin/crsctl add type app.appvip_net1.type -basetype ora.cluster_vip_net1.type -file /u01/app/11.2.0/grid/crs/template/appvip.type 2013-02-27 14:06:52: Executing cmd: /u01/app/11.2.0/grid/bin/crsctl add type app.appvip_net1.type -basetype ora.cluster_vip_net1.type -file /u01/app/11.2.0/grid/crs/template/appvip.type 2013-02-27 14:06:55: Create the Resource 2013-02-27 14:06:55: Executing /u01/app/11.2.0/grid/bin/crsctl add resource gg_v ip_trg -type app.appvip_net1.type -attr "USR_ORA_VIP=192.0.2.99,START_DEPENDEN CIES=hard(ora.net1.network) pullup(ora.net1.network),STOP_DEPENDENCIES=hard(or a.net1.network),ACL='owner:root:rwx,pgrp:root:r-x,other::r--,user:root:r-x',HO STING_MEMBERS=qr01db02.example.com,APPSVIP_FAILBACK=" 2013-02-27 14:06:55: Executing cmd: /u01/app/11.2.0/grid/bin/crsctl add resource gg_vip_trg -type app.appvip_net1.type -attr "USR_ORA_VIP=192.0.2.99,START_DEPE NDENCIES=hard(ora.net1.network) pullup(ora.net1.network),STOP_DEPENDENCIES=har d(ora.net1.network),ACL='owner:root:rwx,pgrp:root:r-x,other::r--,user:root:r-x ',HOSTING_MEMBERS=qr01db02.example.com,APPSVIP_FAILBACK=" [root@qr01db02 bin]# ./crsctl setperm resource gg_vip_trg -u user:oracle:r-x [root@qr01db02 bin]# exit [oracle@qr01db02 ogg]$ cd /u01/app/11.2.0/grid/bin [oracle@qr01db02 bin]$ ./crsctl start resource gg_vip_trg CRS-2672: Attempting to start 'gg_vip_trg' on 'qr01db01' CRS-2676: Start of 'gg_vip_trg' on 'qr01db01' succeeded [oracle@qr01db02 bin]$ ./crsctl status resource gg_vip_trg NAME=gg_vip_trg TYPE=app.appvip_net1.type TARGET=ONLINE STATE=ONLINE on qr01db01 [oracle@qr01db02 bin]$ |
You are looking for a STATE=ONLINE to indicate success. A VIP is tied to one (and only one) IP address. In the case of an application VIP, you define it once (on any cluster node) and by default it can run on any cluster node.
This completes configuring the application VIP address.
1.3 Testing Connectivity
Use ping and tnsping to make sure both hosts can reach each other.
Make sure the source can reach the target via the application VIP address.
| Host01 - Linux (source) |
[oracle@host01 ogg]$ ping qr01-vip
PING qr01-vip.example.com (192.0.2.99) 56(84) bytes of data.
64 bytes from qr01-vip.example.com (192.0.2.99): icmp_seq=1 ttl=64 time=0.145 ms
64 bytes from qr01-vip.example.com (192.0.2.99): icmp_seq=2 ttl=64 time=0.143 ms
64 bytes from qr01-vip.example.com (192.0.2.99): icmp_seq=3 ttl=64 time=0.107 ms
64 bytes from qr01-vip.example.com (192.0.2.99): icmp_seq=4 ttl=64 time=0.109 ms
^C
--- qr01-vip.example.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.107/0.126/0.145/0.018 ms
[oracle@host01 ogg]$
|
After a few successful pings, cancel using Ctrl + C.
Make sure the target node 2 can access the database using tnsping. These aliases from tnsnames.ora will be used later by sqlplus.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ~]$ more $ORACLE_HOME/network/admin/tnsnames.ora # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome _1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. DBM = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = qr01-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dbm.example.com) ) ) [oracle@qr01db02 ~]$ tnsping dbm TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on 06-MAR-2013 13:45 Copyright (c) 1997, 2010, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = qr01-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dbm.example.com))) OK (0 msec) [oracle@qr01db02 ~]$ tnsping dbm1 TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on 06-MAR-2013 13:45 Copyright (c) 1997, 2010, Oracle. All rights reserved. Used parameter files: TNS-03505: Failed to resolve name [oracle@qr01db02 ~]$ |
The "failed" tnsping shows that you cannot tnsping to an individual instance such as dbm1, but you can sqlplus user/pswd@dbm to the clustered database. You can figure out which instance you are talking to by using sqlplus> show parameter instance_name. You can access a specific instance by setting and exporting ORACLE_SID=dbm1 or some other specific instance name.
Make sure the target node 1 can access the same database using the same tnsname.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ~]$ tnsping dbm
TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on 06-MAR-2013 13:45
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =
qr01-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =
dbm.example.com)))
OK (0 msec)
[oracle@qr01db01 ~]$
|
Note that qr01-scan points to both RAC instances (both nodes).
This completes testing database and IP connectivity.
1.4 Preparing the Database for Goldengate
The following section is pretty much the same regardless of whether you are using Exadata or RAC or just a single node.
Create the OGG administrator oggadm1 on source host01.
| Host01 - Linux (source) |
[oracle@host01 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Wed Feb 27 10:08:24 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> set sqlprompt 'host01_SQL> ' host01_SQL> SELECT log_mode, force_logging, supplemental_log_data_min FROM v$database; LOG_MODE FOR SUPPLEME ------------ --- -------- ARCHIVELOG YES YES host01_SQL> CREATE USER oggadm1 IDENTIFIED BY pswd1a; User created. host01_SQL> GRANT dba TO oggadm1; Grant succeeded. host01_SQL> EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE ('OGGADM1','capture',TRUE); PL/SQL procedure successfully completed. host01_SQL> |
If the SELECT returns ARCHIVELOG YES YES, then no further database modification is needed. If the SELECT returns NOARCHIVELOG NO NO, then see the next steps for how to change that, and perform that on the source database.
By default the database is in NOARCHIVELOG and force_logging=NO. Goldengate requires ARCHIVELOG and force_logging=YES. To change that requires the database (both nodes!) to be shut down. Shut down target node 2 first.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 27 09:59:04 2013 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> set sqlprompt 'qr01db_SQL> ' qr01db_SQL> SELECT log_mode, force_logging, supplemental_log_data_min FROM v$database; LOG_MODE FOR SUPPLEME ------------ --- -------- NOARCHIVELOG NO NO qr01db_SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. qr01db_SQL> |
Use of set sqlprompt is optional, but it helps you to keep straight which screen is connected to which function.
Shut down target node 1. Alter the database and system as needed.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 27 09:56:12 2013 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> set sqlprompt 'qr01db_SQL> ' qr01db_SQL> SELECT log_mode, force_logging, supplemental_log_data_min FROM v$database; LOG_MODE FOR SUPPLEME ------------ --- -------- NOARCHIVELOG NO NO qr01db_SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. qr01db_SQL> startup mount ORACLE instance started. Total System Global Area 939495424 bytes Fixed Size 2232088 bytes Variable Size 637534440 bytes Database Buffers 293601280 bytes Redo Buffers 6127616 bytes Database mounted. qr01db_SQL> ALTER DATABASE ARCHIVELOG; ALTER DATABASE ARCHIVELOG * ERROR at line 1: ORA-01126: database must be mounted in this instance and not open in any instance qr01db_SQL> ALTER DATABASE ARCHIVELOG; Database altered. qr01db_SQL> ALTER DATABASE OPEN; Database altered. qr01db_SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; Database altered. qr01db_SQL> ALTER DATABASE FORCE LOGGING; Database altered. qr01db_SQL> ALTER SYSTEM SWITCH LOGFILE; System altered. qr01db_SQL> SELECT log_mode, force_logging, supplemental_log_data_min FROM v$database; LOG_MODE FOR SUPPLEME ------------ --- -------- ARCHIVELOG YES YES qr01db_SQL> COMMIT; Commit complete. qr01db_SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. qr01db_SQL> |
Note the ERROR ORA-01126 in the middle of the screen. That is what you see if you forgot to shut down the other node first. Leave target node 1 shut down for the moment.
Perform similar steps on target node 2.
| Exadata - Node 2 (target) |
ORACLE instance shut down. SQL> set sqlprompt 'qr01db_SQL> ' qr01db_SQL> startup mount ORACLE instance started. Total System Global Area 939495424 bytes Fixed Size 2232088 bytes Variable Size 641728744 bytes Database Buffers 289406976 bytes Redo Buffers 6127616 bytes Database mounted. qr01db_SQL> ALTER DATABASE ARCHIVELOG; Database altered. qr01db_SQL> ALTER DATABASE OPEN; Database altered. qr01db_SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; Database altered. qr01db_SQL> ALTER DATABASE FORCE LOGGING; ALTER DATABASE FORCE LOGGING * ERROR at line 1: ORA-12920: database is already in force logging mode qr01db_SQL> ALTER SYSTEM SWITCH LOGFILE; System altered. qr01db_SQL> SELECT log_mode, force_logging, supplemental_log_data_min FROM v$database; LOG_MODE FOR SUPPLEME ------------ --- -------- ARCHIVELOG YES YES qr01db_SQL> |
It is interesting to note which things apply to the instances (there are two instances), and which things apply to the database (there is only one database). For example, each instance has to be set to ALTER DATABASE ADD SUPPLEMENTAL LOG DATA, but the single database is already in FORCE LOGGING from the previous instance.
When you are successful, the SELECT will return ARCHIVELOG YES YES.
Now that the database is altered, start it up. Node 2 is already running, now start the database on node 1. Create the OGG admin user/schema for Exadata (this user is accessible from either node dbm1 or dbm2).
| Exadata - Node 1 (target) |
ORACLE instance shut down. qr01db_SQL> startup ORACLE instance started. Total System Global Area 939495424 bytes Fixed Size 2232088 bytes Variable Size 637534440 bytes Database Buffers 293601280 bytes Redo Buffers 6127616 bytes Database mounted. Database opened. qr01db_SQL> sho parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string db_name string dbm db_unique_name string dbm global_names boolean FALSE instance_name string dbm1 lock_name_space string log_file_name_convert string processor_group_name string service_names string dbm.example.com qr01db_SQL> CREATE USER oggadm2 IDENTIFIED BY pswd2a; User created. qr01db_SQL> GRANT dba TO oggadm2; Grant succeeded. qr01db_SQL> EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE ('OGGADM2','capture',TRUE); PL/SQL procedure successfully completed. qr01db_SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@qr01db01 ~]$ |
Granting DBA to the OGG Admin is probably overkill, but it is convenient for this example. You would probably grant fewer privileges in a production environment.
At this point, you are done with things that require both nodes configured separately. From now on, you can choose to use just node 1 for all sqlplus operations.
This completes preparing the database for Oracle GoldenGate.
1.5 Preparing the Database for DBFS
Create two tablespaces (one big and one small) to hold two DBFS. The two tablespaces will have different caching characteristics later.
It does not matter whether this step is performed on target node 1 or target node 2, it all goes to the same shared storage space. The sizes you pick for the dbfs_ogg_big will probably be much larger in a production environment. They need to be big enough to hold all the trail files. The sizes you pick for the dbfs_ogg_small will probably be about right. All that is going in the small DBFS will be very tiny checkpoint files.
| Exadata - Node 2 (target) |
qr01db_SQL> CREATE bigfile TABLESPACE dbfs_ogg_big datafile '+DBFS_DG' SIZE 100M autoextend ON NEXT 10M MAXSIZE 200M LOGGING EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO; Tablespace created. qr01db_SQL> CREATE bigfile TABLESPACE dbfs_ogg_small datafile '+DBFS_DG' SIZE 10M autoextend ON NEXT 1M MAXSIZE 20M LOGGING EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO; Tablespace created. qr01db_SQL> SELECT tablespace_name, logging, bigfile FROM dba_tablespaces WHERE tablespace_name like 'DBFS%'; TABLESPACE_NAME LOGGING BIG --------------------------- --------- --- DBFS_OGG_BIG LOGGING YES DBFS_OGG_SMALL LOGGING YES qr01db_SQL> SELECT table_name, segment_name, cache, logging FROM dba_lobs WHERE tablespace_name like 'DBFS%'; no rows selected qr01db_SQL> CREATE USER dbfs_user IDENTIFIED BY dbfs_pswd DEFAULT TABLESPACE dbfs_ogg_big QUOTA UNLIMITED ON dbfs_ogg_big QUOTA UNLIMITED ON dbfs_ogg_small; User created. qr01db_SQL> GRANT create session, create table, create view, create procedure, dbfs_role TO dbfs_user; Grant succeeded. qr01db_SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@qr01db02 ~]$ |
Note the second SELECT shows that no LOBs exist yet. That will change in the next step.
This completes preparing the database for DBFS. For more info on DBFS, see the Large Objects (LOBs) docs.
This completes preparing the environment.
2. Preparing Database File System (DBFS)
- Create LOB tables to house DBFS.
- Create OS mount points and directory structure.
- Start OS clients to use DBFS.
Objective
The goals of this exercise are to:
2.1 Creating LOB Tables to House DBFS
It is important to run the scripts as the same user that will be specified in the client startup (step 2.3.1 and step 2.3.2), in this case dbfs_user. When running SQL @dbfs scripts, make sure they have no extra line feeds in the parameters (even though they show with line feeds in the examples).
| Exadata - Node 2 (target) |
[oracle@qr01db02 ~]$ cd $ORACLE_HOME/rdbms/admin [oracle@qr01db02 admin]$ sqlplus dbfs_user/dbfs_pswd SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 27 10:37:45 2013 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options qr01db_SQL> @dbfs_create_filesystem_advanced.sql dbfs_ogg_big dbfs_big nocompress nodeduplicate noencrypt non-partition qr01db_SQL> Rem qr01db_SQL> Rem $Header: rdbms/admin/dbfs_create_filesystem_advanced.sql /main/4 2010/04/14 13:21:30 weizhang Exp $ qr01db_SQL> Rem qr01db_SQL> Rem dbfs_create_filesystem.sql qr01db_SQL> Rem qr01db_SQL> Rem Copyright (c) 2009, 2010, Oracle and/or its affiliates. qr01db_SQL> Rem All rights reserved. qr01db_SQL> Rem qr01db_SQL> Rem NAME qr01db_SQL> Rem dbfs_create_filesystem_advanced.sql - DBFS create filesystem qr01db_SQL> Rem qr01db_SQL> Rem DESCRIPTION qr01db_SQL> Rem DBFS create filesystem script qr01db_SQL> Rem Usage: sqlplus @dbfs_create_filesystem_advanced.sql qr01db_SQL> Rem <tablespace_name> <filesystem_name> qr01db_SQL> Rem <compress-high | compress-medium | nocompress> qr01db_SQL> Rem <deduplicate | nodeduplicate> <encrypt | noencrypt> qr01db_SQL> Rem <non-partition | partition | partition-by-itemname | qr01db_SQL> Rem partition-by-guid, partition-by-path> qr01db_SQL> Rem qr01db_SQL> Rem NOTES qr01db_SQL> Rem qr01db_SQL> Rem MODIFIED (MM/DD/YY) qr01db_SQL> Rem weizhang 03/11/10 - bug 9220947: tidy up qr01db_SQL> Rem weizhang 06/12/09 - Package name change qr01db_SQL> Rem weizhang 04/06/09 - Created qr01db_SQL> Rem qr01db_SQL> qr01db_SQL> SET ECHO OFF No errors. -------- CREATE STORE: begin dbms_dbfs_sfs.createFilesystem(store_name => 'FS_DBFS_BIG', tbl_name => 'T_DBFS_BIG', tbl_tbs => 'dbfs_ogg_big', lob_tbs => 'dbfs_ogg_big', do_partition => false, partition_key => 1, do_compress => false, compression => '', do_dedup => false, do_encrypt => false); end; -------- REGISTER STORE: begin dbms_dbfs_content.registerStore(store_name=> 'FS_DBFS_BIG', provider_name => 'sample1', provider_package => 'dbms_dbfs_sfs'); end; -------- MOUNT STORE: begin dbms_dbfs_content.mountStore(store_name=>'FS_DBFS_BIG', store_mount=>'dbfs_big'); end; -------- CHMOD STORE: declare m integer; begin m := dbms_fuse.fs_chmod('/dbfs_big', 16895); end; No errors. qr01db_SQL> @dbfs_create_filesystem_advanced.sql dbfs_ogg_small dbfs_sm nocompress nodeduplicate noencrypt non-partition No errors. -------- CREATE STORE: begin dbms_dbfs_sfs.createFilesystem(store_name => 'FS_DBFS_SM', tbl_name => 'T_DBFS_SM', tbl_tbs => 'dbfs_ogg_small', lob_tbs => 'dbfs_ogg_small', do_partition => false, partition_key => 1, do_compress => false, compression => '', do_dedup => false, do_encrypt => false); end; -------- REGISTER STORE: begin dbms_dbfs_content.registerStore(store_name=> 'FS_DBFS_SM', provider_name => 'sample1', provider_package => 'dbms_dbfs_sfs'); end; -------- MOUNT STORE: begin dbms_dbfs_content.mountStore(store_name=>'FS_DBFS_SM', store_mount=>'dbfs_sm'); end; -------- CHMOD STORE: declare m integer; begin m := dbms_fuse.fs_chmod('/dbfs_sm', 16895); end; No errors. qr01db_SQL> conn / as sysdba Connected. qr01db_SQL> SELECT tablespace_name, file_name FROM dba_data_files WHERE tablespace_name LIKE 'DBFS%'; TABLESPACE_NAME FILE_NAME --------------- -------------------------------------------------- DBFS_OGG_BIG +DBFS_DG/dbm/datafile/dbfs_ogg_big.256.808464609 DBFS_OGG_SMALL +DBFS_DG/dbm/datafile/dbfs_ogg_small.257.808464635 qr01db_SQL> SELECT table_name, segment_name, cache, logging FROM dba_lobs WHERE tablespace_name like 'DBFS%'; TABLE_NAME SEGMENT_NAME CACHE LOGGING ----------------------- --------------------------- --------- ------- T_DBFS_BIG LOB_SFS$_FST_1 NO YES T_DBFS_SM LOB_SFS$_FST_11 NO YES qr01db_SQL> ALTER TABLE dbfs_user.T_DBFS_SM MODIFY LOB (FILEDATA) (CACHE LOGGING); qr01db_SQL> SELECT table_name, segment_name, cache, logging FROM dba_lobs WHERE tablespace_name like 'DBFS%'; TABLE_NAME SEGMENT_NAME CACHE LOGGING ----------------------- --------------------------- --------- ------- T_DBFS_BIG LOB_SFS$_FST_1 NO YES T_DBFS_SM LOB_SFS$_FST_11 YES YES qr01db_SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@qr01db02 admin]$ |
The ALTER TABLE changes the smaller DBFS to use caching. This is useful for the tiny checkpoint tables. The bigger DBFS default of no caching is better suited for sequential reading and writing, as is used by the trail files.
This completes creating DBFS LOB tables.
2.2 Creating Mount Points and Directory Structures
The DBFS lives on the shared storage cells.
You can locate the DBFS anywhere, the convention is under /mnt.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ~]$ su - root Password: [root@qr01db02 ~]# cd /mnt [root@qr01db02 mnt]# mkdir DBFS [root@qr01db02 mnt]# ll total 4 drwxr-xr-x 2 root root 4096 Feb 27 10:34 DBFS [root@qr01db02 mnt]# chown oracle:oinstall DBFS/ [root@qr01db02 mnt]# ll total 4 drwxr-xr-x 2 oracle oinstall 4096 Feb 27 10:34 DBFS [root@qr01db02 mnt]# exit [oracle@qr01db02 ~]$ |
You need to be root to create it, but then change the ownership back to oracle.
Even though DBFS itself is on shared storage, the mount points need to be defined on both nodes.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ~]$ su - root Password: [root@qr01db01 ~]# cd /mnt [root@qr01db01 mnt]# mkdir DBFS [root@qr01db01 mnt]# ll total 4 drwxr-xr-x 2 root root 4096 Feb 27 10:34 DBFS [root@qr01db01 mnt]# chown oracle:oinstall DBFS/ [root@qr01db01 mnt]# ll total 4 drwxr-xr-x 2 oracle oinstall 4096 Feb 27 10:34 DBFS [root@qr01db01 mnt]# exit [oracle@qr01db01 ~]$ |
This should be identical on all Exadata nodes.
This completes creating mount points and directory structures.
2.3 Starting OS Clients to use DBFS
While these DBFS clients are started manually as part of the Proof of Concept, in production you would define this as an auto-restarting resource.
The dbfs_user matches the user that defined the scripts back in step 2.1.1. Start the DBFS client on Exadata target node 2. Do not press enter in the middle of typing the nohup command, that should all be on one logical line. However, after it replies, "appending output to nohup.out", you do have to press Enter again to get control back to the OS prompt.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ~]$ cd ~ [oracle@qr01db02 ~]$ echo dbfs_pswd > passwd.txt [oracle@qr01db02 ~]$ nohup $ORACLE_HOME/bin/dbfs_client dbfs_user@dbm -o allow_other,direct_io /mnt/DBFS < ~/passwd.txt & [1] 5670 [oracle@qr01db02 ~]$ nohup: appending output to `nohup.out' [oracle@qr01db02 ~]$ ll /mnt/DBFS/ total 0 drwxrwxrwx 3 root root 0 Feb 27 10:39 dbfs_big drwxrwxrwx 3 root root 0 Feb 27 10:40 dbfs_sm [oracle@qr01db02 ~]$ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda2 8022104 2639960 4968072 35% / /dev/xvda1 101086 13048 82819 14% /boot tmpfs 1146880 748004 398876 66% /dev/shm /dev/xvdb1 20635700 12517612 7069852 64% /u01 dbfs-dbfs_user@dbm:/ 222640 304 222336 1% /mnt/DBFS [oracle@qr01db02 ~]$ |
The ampersand "&" at the end of the command line sends the dbfs_client to run in the background. You can manipulate the background jobs with jobs (lists jobs), fg (foreground), and bg (background).
You need to start the client on both nodes. The order (node 1 versus node 2) does not matter. Start the DBFS client on Exadata target node 1. Again, be mindful to not put in any stray line feeds when entering the nohup command.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ~]$ cd ~ [oracle@qr01db01 ~]$ echo dbfs_pswd > passwd.txt [oracle@qr01db01 ~]$ nohup $ORACLE_HOME/bin/dbfs_client dbfs_user@dbm -o allow_other,direct_io /mnt/DBFS < ~/passwd.txt & [1] 6358 [oracle@qr01db01 ~]$ nohup: appending output to `nohup.out' [oracle@qr01db01 ~]$ ll /mnt/DBFS/ total 0 drwxrwxrwx 3 root root 0 Feb 27 10:39 dbfs_big drwxrwxrwx 4 root root 0 Feb 27 11:19 dbfs_sm [oracle@qr01db01 ~]$ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda2 8022104 2660752 4947280 35% / /dev/xvda1 101086 13048 82819 14% /boot tmpfs 1146880 797380 349500 70% /dev/shm /dev/xvdb1 20635700 12054256 7533208 62% /u01 dbfs-dbfs_user@dbm:/ 222640 304 222336 1% /mnt/DBFS [oracle@qr01db01 ~]$ |
The df -k is optional, just to check that the sizes of the DBFS directories are what you expected.
This completes starting clients to use DBFS.
This completes preparing the DBFS.
3. Installing Oracle GoldenGate (OGG) Software
- Unzip the software.
- Fix the symbolic links.
- Create the base parameter files.
Objective
The goals of this exercise are to:
This OBE assumes that the source is a Linux 64-bit Intel architecture box, but if it is something else the steps are still fairly similar.
3.1 Unzipping the Oracle GoldenGate Software
Install the software on all three hosts. This assumes that you have already downloaded V34339-01.zip (or a later version) from the Oracle Software Delivery Cloud, and staged it in your home directory (~) on each host.
Install the OGG software on Exadata target node 2. Note the leading dot on the first command. Use that dot to "source" the .bash_profile to pick up the $OGG_HOME and other environment variables.
| Exadata - Node 2 (target) |
[oracle@qr01db02 admin]$ . ~/.bash_profile [oracle@qr01db02 admin]$ echo $OGG_HOME /u01/app/oracle/ogg [oracle@qr01db02 ~]$ cd $ORACLE_BASE [oracle@qr01db02 oracle]$ mkdir ogg [oracle@qr01db02 oracle]$ cd $OGG_HOME [oracle@qr01db02 ogg]$ pwd /u01/app/oracle/ogg [oracle@qr01db02 ogg]$ unzip ~/V34339-01.zip Archive: /home/oracle/V34339-01.zip inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar inflating: Oracle_GoldenGate_11.2.1.0.3_README.doc inflating: Oracle GoldenGate_11.2.1.0.3_README.txt inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.3.pdf [oracle@qr01db02 ogg]$ tar -xvpf fbo_ggs_Linux_x64_ora11g_64bit.tar UserExitExamples/ UserExitExamples/ExitDemo_more_recs/ UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.HPUX UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.SOLARIS UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.LINUX UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.AIX UserExitExamples/ExitDemo_more_recs/exitdemo_more_recs.vcproj UserExitExamples/ExitDemo_more_recs/exitdemo_more_recs.c UserExitExamples/ExitDemo_more_recs/readme.txt UserExitExamples/ExitDemo_passthru/ (...many lines omitted for clarity...) reverse role_setup.sql sequence.sql server sqlldr.tpl tcperrs ucharset.h ulg.sql usrdecs.h zlib.txt [oracle@qr01db02 ogg]$ |
You may want to see the README.txt for late-breaking news.
Do the same thing on the other Exadata target node 1.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ~]$ . ~/.bash_profile [oracle@qr01db01 ~]$ echo $OGG_HOME /u01/app/oracle/ogg [oracle@qr01db01 ~]$ cd $ORACLE_BASE [oracle@qr01db01 oracle]$ mkdir ogg [oracle@qr01db01 oracle]$ cd $OGG_HOME [oracle@qr01db01 ogg]$ pwd /u01/app/oracle/ogg [oracle@qr01db01 ogg]$ unzip ~/V34339-01.zip Archive: /home/oracle/V34339-01.zip inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar inflating: Oracle_GoldenGate_11.2.1.0.3_README.doc inflating: Oracle GoldenGate_11.2.1.0.3_README.txt inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.3.pdf [oracle@qr01db01 ogg]$ tar -xvpf fbo_ggs_Linux_x64_ora11g_64bit.tar UserExitExamples/ UserExitExamples/ExitDemo_more_recs/ (...many lines omitted for clarity...) ulg.sql usrdecs.h zlib.txt [oracle@qr01db02 ogg]$ |
It should be the same.
Do the same thing on the source host01.
| Host01 - Linux (source) |
(screens not shown, they are the same as above)
|
This completes unzipping the Oracle GoldenGate software.
3.2 Creating Symbolic Links to DBFS
The symbolic links tell OGG to use DBFS for the common files and for the trail files. You need to make the DBFS subdirectories only once, but need to make the links on both Exadata nodes. They will have the same name and structure as the subdirectories in $OGG_HOME.
Create the DBFS subdirectories and symbolic links on Exadata target node 2.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ogg]$ cp ./dirprm/jagent.prm jagent.backup [oracle@qr01db02 ogg]$ rm -rf dirprm [oracle@qr01db02 ogg]$ mkdir /mnt/DBFS/dbfs_sm/ogg [oracle@qr01db02 ogg]$ mkdir /mnt/DBFS/dbfs_sm/ogg/dirprm [oracle@qr01db02 ogg]$ mkdir /mnt/DBFS/dbfs_sm/ogg/dirpcs [oracle@qr01db02 ogg]$ mkdir /mnt/DBFS/dbfs_sm/ogg/dirchk [oracle@qr01db02 ogg]$ mkdir /mnt/DBFS/dbfs_big/ogg [oracle@qr01db02 ogg]$ mkdir /mnt/DBFS/dbfs_big/ogg/dirdat [oracle@qr01db02 ogg]$ ln -s /mnt/DBFS/dbfs_sm/ogg/dirprm/ $OGG_HOME/dirprm [oracle@qr01db02 ogg]$ ln -s /mnt/DBFS/dbfs_sm/ogg/dirpcs/ $OGG_HOME/dirpcs [oracle@qr01db02 ogg]$ ln -s /mnt/DBFS/dbfs_sm/ogg/dirchk/ $OGG_HOME/dirchk [oracle@qr01db02 ogg]$ |
The dirprm/jagent.prm was created as part of the unzip, you need to move it to the DBFS after the other directories are created.
Create the subdirectories on Exadata target node 2 in $OGG_HOME using GGSCI.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ogg]$ ./ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (qr01db02.example.com) 1> Create SubDirs Creating subdirectories under current directory /u01/app/oracle/ogg Parameter files /u01/app/oracle/ogg/dirprm: already exists Report files /u01/app/oracle/ogg/dirrpt: created Checkpoint files /u01/app/oracle/ogg/dirchk: already exists Process status files /u01/app/oracle/ogg/dirpcs: already exists SQL script files /u01/app/oracle/ogg/dirsql: created Database definitions files /u01/app/oracle/ogg/dirdef: created Extract data files /u01/app/oracle/ogg/dirdat: created Temporary files /u01/app/oracle/ogg/dirtmp: created Stdout files /u01/app/oracle/ogg/dirout: created GGSCI (qr01db02.example.com) 2> Exit [oracle@qr01db02 ogg]$ mv jagent.backup /mnt/DBFS/dbfs_sm/ogg/dirprm/jagent.prm [oracle@qr01db02 ogg]$ cd dirprm/ [oracle@qr01db02 dirprm]$ ll total 1 -rwxr-x--- 1 oracle oinstall 53 Feb 27 11:11 jagent.prm [oracle@qr01db02 dirprm]$ pwd /u01/app/oracle/ogg/dirprm [oracle@qr01db02 dirprm]$ cd $OGG_HOME |
Note the three subdirectories that exist as symbolic links pointing to DBFS. And now you have moved back the jagent.prm file to one of those links: ogg/dirprm.
Do the same thing on target node 1. There are slightly fewer steps this time.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ogg]$ cp ./dirprm/jagent.prm jagent.backup [oracle@qr01db01 ogg]$ rm -rf dirprm [oracle@qr01db01 ogg]$ ll /mnt/DBFS/dbfs_sm/ogg/ total 0 drwxr-xr-x 2 oracle oinstall 0 Feb 27 11:19 dirchk drwxr-xr-x 2 oracle oinstall 0 Feb 27 11:19 dirpcs drwxr-xr-x 2 oracle oinstall 0 Feb 27 11:23 dirprm [oracle@qr01db01 ogg]$ [oracle@qr01db01 ogg]$ ln -s /mnt/DBFS/dbfs_sm/ogg/dirprm/ $OGG_HOME/dirprm [oracle@qr01db01 ogg]$ ln -s /mnt/DBFS/dbfs_sm/ogg/dirpcs/ $OGG_HOME/dirpcs [oracle@qr01db01 ogg]$ ln -s /mnt/DBFS/dbfs_sm/ogg/dirchk/ $OGG_HOME/dirchk [oracle@qr01db01 ogg]$ |
Note that the DBFS ogg/ substructure is already there.
Create the other subdirectories on Exadata target node 1 in $OGG_HOME using GGSCI.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ogg]$ ./ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (qr01db01.example.com) 1> Create SubDirs Creating subdirectories under current directory /u01/app/oracle/ogg Parameter files /u01/app/oracle/ogg/dirprm: already exists Report files /u01/app/oracle/ogg/dirrpt: created Checkpoint files /u01/app/oracle/ogg/dirchk: already exists Process status files /u01/app/oracle/ogg/dirpcs: already exists SQL script files /u01/app/oracle/ogg/dirsql: created Database definitions files /u01/app/oracle/ogg/dirdef: created Extract data files /u01/app/oracle/ogg/dirdat: created Temporary files /u01/app/oracle/ogg/dirtmp: created Stdout files /u01/app/oracle/ogg/dirout: created GGSCI (qr01db01.example.com) 2> Exit [oracle@qr01db01 ogg]$ mv jagent.backup /mnt/DBFS/dbfs_sm/ogg/dirprm/jagent.prm [oracle@qr01db01 ogg]$ cd dirprm/ [oracle@qr01db01 dirprm]$ ll total 1 -rwxr-x--- 1 oracle oinstall 53 Feb 27 11:37 jagent.prm [oracle@qr01db01 dirprm]$ pwd /u01/app/oracle/ogg/dirprm [oracle@qr01db01 dirprm]$ cd $OGG_HOME [oracle@qr01db01 ogg]$ |
The GGSCI keywords are not case-sensitive, but by convention they will be shown in MixedCase to make them more readable (and to distinguish them from UPPERCASE SQL keywords and lowercase Linux keywords).
This completes creating symbolic links to DBFS.
3.3 Creating Base Parameter Files
The parameter files are ASCII files created with your editor of choice. The default editor is vi. Comments are indicated by a double-dash starting in column one. Most of the parameter files are stored in the common folder /dirprm on the DBFS.
There is no formal startup script, but you will find it very useful to have, especially for the DBLogin commands. Configure source host01, then run the startup.oby obey script.
| Host01 - Linux (source) |
[oracle@host01 ogg]$ vi startup.oby -- Created by Joe Admin 10/11/2012 on host01 DBLogin UserID oggadm1@orcl, Password pswd1a Start Mgr Info Mgr Info CheckpointTable -- Set Editor gedit [oracle@host01 ogg]$ vi GLOBALS -- Created by Joe Admin 10/11/2012 on host01 CheckpointTable oggadm1.oggchkpt [oracle@host01 ogg]$ ./ggsci GGSCI (host01) 1> Create SubDirs (response not shown, no harm in doing it twice...) GGSCI (host01) 2> Edit Param mgr -- Created by Joe Admin 10/11/2012 on host01 Port 15001 PurgeOldExtracts ./dirdat/*, UseCheckpoints GGSCI (host01) 3> Obey startup.oby GGSCI (host01) 4> -- Created by Joe Admin 10/11/2012 on host01 GGSCI (host01) 5> DBLogin UserID oggadm1@orcl, Password pswd1a Successfully logged into database. GGSCI (host01) 6> Start Mgr Manager started. GGSCI (host01) 7> Info Mgr Manager is running (IP port host01.example.com.15001). GGSCI (host01) 8> Info CheckpointTable No checkpoint table specified, using GLOBALS specification (oggadm1.oggchkpt)... Checkpoint table oggadm1.oggchkpt does not exist. GGSCI (host01) 9> |
For host01 that supports a GUI, you may want to set the default editor to be something more friendly, such as gedit. To do that, add one more line to the end of startup.oby (just remove the double-dash comments):
Set Editor gedit
Note that this is not an option on the Exadata that does not support a GUI.
See basic OGG Oracle-to-Oracle OBE for more explanation about managers, ports, purges, and checkpoints. Do not worry that the checkpoint file does not exist yet. Note that GLOBALS is the only "parameter" file that is uppercase, does not have an extension of .prm, and lives in $OGG_HOME (versus lowercase and live in $OGG_HOME/dirprm).
Make the same basic configuration files on Exadata target node 1.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ogg]$ vi startup.oby -- Created by Joe Admin 10/11/2012 on Exadata qr01db01 DBLogin UserID oggadm2@dbm, Password pswd2a Start Mgr Info Mgr Info CheckpointTable [oracle@qr01db01 ogg]$ vi GLOBALS -- Created by Joe Admin 10/11/2012 on qr01db01 CheckpointTable oggadm2.oggchkpt [oracle@qr01db01 ogg]$ ./ggsci GGSCI (qr01db01) 1> Edit param mgr -- Created by Joe Admin 10/11/2012 on Exadata qr01db Port 15002 Autostart ER * AutoRestart ER * PurgeOldExtracts ./dirdat/*, UseCheckpoints GGSCI (qr01db01) 3> Obey startup.oby GGSCI (qr01db01) 4> -- Created by Joe Admin 10/11/2012 on Exadata qr01db GGSCI (qr01db01) 5> DBLogin UserID oggadm2@dbm, Password pswd2a Successfully logged into database. GGSCI (qr01db01) 6> Start Mgr Manager started. GGSCI (qr01db01) 7> Info Mgr Manager is running (IP port qr01db01.example.com.15002). GGSCI (qr01db01) 8> Info CheckpointTable No checkpoint table specified, using GLOBALS specification (oggadm2.oggchkpt)... Checkpoint table oggadm2.oggchkpt does not exist. GGSCI (qr01db01) 9> Exit [oracle@qr01db01 ogg]$ |
The Autostart/AutoRestart is optional, but is recommended for MAA.
Configure the basic parameter files for Exadata target node 2.
| Exadata - Node 2 (target) |
[oracle@qr01db02 ogg]$ vi startup.oby -- Created by Joe Admin 10/11/2012 on Exadata qr01db02 DBLogin UserID oggadm2@dbm, Password pswd2a Start Mgr Info Mgr Info CheckpointTable [oracle@qr01db02 ogg]$ vi GLOBALS -- Created by Joe Admin 10/11/2012 on qr01db02 CheckpointTable oggadm2.oggchkpt [oracle@qr01db02 ogg]$ |
Note that the mgr.prm parameter file already exists on the shared DBFS. That implies that node 1 and node 2 share the same port (15002), and that implies that only one can be running at a time! This is different than the database where you have two instances running. Only one instance of OGG can be running on the target at a time. This is important enough to repeat: Only one instance of OGG can be running on the target at a time.
This completes creating base parameter files.
This completes installing OGG software.
4. Preparing the Schema
- Add transaction data tracking.
- Confirm TranData columns.
Objective
The goals of this exercise are to:
This assumes that the sample hr (Human Resources) schema is installed with the source and target Oracle 11g databases.
4.1 Adding Transaction Data Tracking
You have to do this each time you add a table or change the structure of a table.
You can add transaction data tracking for a single table, for a wildcard group of tables, or for a whole schema. In this example, add TranData for a single table on the source host01.
| Host01 - Linux (source) |
GGSCI (host01) > Add TranData hr.regions Logging of supplemental redo data enabled for table HR.REGIONS. GGSCI (host01) > Info TranData hr.* Logging of supplemental redo log data is disabled for table HR.COUNTRIES. Logging of supplemental redo log data is disabled for table HR.DEPARTMENTS. Logging of supplemental redo log data is disabled for table HR.EMPLOYEES. Logging of supplemental redo log data is disabled for table HR.JOBS. Logging of supplemental redo log data is disabled for table HR.JOB_HISTORY. Logging of supplemental redo log data is disabled for table HR.LOCATIONS. Logging of supplemental redo log data is enabled for table HR.REGIONS. Columns supplementally logged for table HR.REGIONS: REGION_ID. GGSCI (host01) > |
Note that by default it only tracks the primary key columns, in this case REGION_ID.
DO NOT DO THIS STEP, JUST READ IT.
Alternatively, you could have done either of the following commands with the same effect:
Add TranData hr.reg*
Add SchemaTranData hr
DO NOT DO THIS STEP, JUST READ IT.
If the source and target schemas do not match, then you also have to run defgen (not shown) to make a column mapping definition file. For more information on defgen, see Chapter 13: Associating replicated data with metadata in the OGG Windows and UNIX Administrator's Guide.
This completes adding TransData.
This completes adding transaction data.
5. Configuring Data Extract
- Configure the primary Extract.
- Configure the secondary Extract (the data pump).
- Register the processes with the database.
Objective
The goals of this exercise are to:
"Data extract" is also known as "data capture."
5.1 Configuring the Primary Extract
Configure source host01 to extract hr.regions and send it to a local data pump.
| Host01 - Linux (source) |
GGSCI (host01) > Edit Param eregab -- Primary Extract from host01(a) to QR01(b) -- Created by Joe Admin on 10/11/2012 -- SETENV(ORACLE_SID = "orcl") Extract eregab ExtTrail ./dirdat/aa UserID oggadm1@orcl, Password pswd1a -- TranLogOptions ExcludeUser oggadm1 Table hr.regions; GGSCI (host01) > |
The external trail file aa is local to the source. The optional TranLogOptions ExcludeUser would be used for future bidirectional replication.
This completes configuring the primary extract. There are many more possible options not shown, such as filtering and column mapping.
5.2 Configuring the Secondary Extract (Data Pump)
The purpose of a data pump is to provide higher availability in case of a network outage. It is optional, but recommended for MAA. Configure the data pump on source host01.
| Host01 - Linux (source) |
GGSCI (host01) > Edit Param pregab -- Data pump (secondary Extract) from host01(a) to qr01(b) -- Created by Joe Admin on 10/11/2012 Extract pregab RmtHost qr01-vip, MgrPort 15002, Compress RmtTrail /mnt/DBFS/dbfs_big/ogg/dirdat/ab Passthru Table hr.regions; GGSCI (host01) > |
Note that the remote trail (RmtTrail) is writing to the remote target DBFS location using the virtual IP address defined in /etc/hosts. Only Table statements (here on Extract) and Map statements (there on Replicat) must end in a semi-colon and therefore can span lines. Other statements must be on one logical line (it is okay for the screen to wrap as you type, just don't insert an Enter).
This completes configuring the data pump.
5.3 Registering the Extract Processes with the Database
You must be logged in to the local database (DBLogin) for the registration to work. Using startup.oby back in step 3.3.1 can take care of that for you. Register the primary Extract on source host01.
| Host01 - Linux (source) |
GGSCI (host01) > Add Extract eregab, TranLog, Begin Now EXTRACT added. GGSCI (host01) > Add ExtTrail ./dirdat/aa, Extract eregab, Megabytes 2 EXTTRAIL added. GGSCI (host01) > |
The default Megabytes size is 100 MB. You may need more or less depending on your traffic and lag.
Register the secondary Extract (the data pump) on source host01.
| Host01 - Linux (source) |
GGSCI (host01) > Add Extract pregab, ExtTrailSource ./dirdat/aa EXTRACT added. GGSCI (host01) > Add RmtTrail /mnt/DBFS/dbfs_big/ogg/dirdat/ab, Extract pregab, Megabytes 2 RMTTRAIL added. GGSCI (host01) > |
All these registration values must match the parameter file values. There are GUI tools, such as Oracle GoldenGate Director, that can assemble all of the matching pieces from a wizard.
This completes registering the Extract processes with the database.
This completes configuring data extract.
6. Configuring Data Delivery (Replication)
- Configure the Replicat.
- Create the Checkpoint table.
- Register the Replicat process with the database.
- Start the Replicat process.
Objective
The goals of this exercise are to:
"Data delivery" is also known as "Replicat," usually capitalized. Note that there is no final "e" in "Replicat" (that is a long story for another day).
6.1 Configuring the Replicat
Configure the Replicat on either target node. In this case use node 2 for GGSCI commands (and use node 1 for SQL commands).
| Exadata - Node 2 (target) |
[oracle@qr01db02 dirdat]$ cd $OGG_HOME [oracle@qr01db02 ogg]$ ./ggsci GGSCI (qr01db02) 1> Obey startup.oby GGSCI (qr01db02) 2> -- Created by Joe Admin 10/11/2012 on Exadata qr01db GGSCI (qr01db02) 3> DBLogin UserID oggadm2@dbm, Password pswd2a Successfully logged into database. GGSCI (qr01db02) 4> Start Mgr Manager started. GGSCI (qr01db02) 5> Info Mgr Manager is DOWN! GGSCI (qr01db02) 6> Info CheckpointTable No checkpoint table specified, using GLOBALS specification (oggadm2.oggchkpt)... Checkpoint table oggadm2.oggchkpt does not exist. GGSCI (qr01db02) 7> Edit Param rregab -- Delivery from host01(a) to qr01db(b) -- Created by Joe Admin on 10/11/2012 Replicat rregab UserID oggadm2@dbm, password pswd2a AssumeTargetDefs -- SourceDefs dirdef/dsalesab.def DiscardFile dirrpt/rsalesab.dsc, Append -- Map ogguser1.tcustmer, Target ogguser2.tcustmer; Map hr.*, Target hr.*; GGSCI (qr01db02) 8> Add Replicat rregab, ExtTrail /mnt/DBFS/dbfs_big/ogg/dirdat/ab REPLICAT added. GGSCI (qr01db02) > |
Note that the startup.oby script may mistakenly report that the manager is down. Well, at that millisecond it probably was down, but a few seconds later it was running. The scripts do not pause, running faster than the commands they invoke. To fix that timing anomoly, you may want to sprinkle sh sleep 5 statments after slower commands, such as Start mgr and complex DBLogin calls to wait for GGSCI to catch up. See the OBE on automating GGSCI for more ideas on how to do that.
The AssumeTargetDefs and SourceDefs (pick one or the other, they are mutually exclusive) have to do with the defgen utility mentioned earlier. There are many more possible options not shown, such as filtering and column mapping.
This completes configuring the Replicat.
6.2 Creating the Checkpoint Table
Checkpoint tables are optional, but highly recommended. Checkpoint tables are only used by the Replicat (though there is no harm to having them on the source system as well). You can have individual checkpoint tables for some Replicats, or you can have a global checkpoint table for all Replicats.
Create the generic checkpoint table on the target database as defined by the GLOBALS parameter.
| Exadata - Node 2 (target) |
GGSCI (qr01db02) > Add CheckpointTable
No checkpoint table specified, using GLOBALS specification (oggadm2.oggchkpt)...
Successfully created checkpoint table oggadm2.oggchkpt.
GGSCI (qr01db02) >
|
The startup.oby script reports the status of the checkpoint file each time you run it.
This completes creating the checkpoint table.
6.3 Starting the Replicat Process
It is okay to start the Replicat without starting the Extract. It will sit and wait for the Extract to start later.
Start the replicat process on the target.
| Exadata - Node 2 (target) |
GGSCI (qr01db02) > Start * Sending START request to MANAGER ... REPLICAT RREGAB starting GGSCI (qr01db02) > Info All Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT RUNNING RREGAB 00:00:00 00:00:02 GGSCI (qr01db02) > |
Had you ended GGSCI and restarted it, there is an Autostart for the process as well. Alternatively, you could have started a subset of the processes using commands such as:
Start ER * (start all Extracts and Replicats, as opposed to initial tasks)
Start RR* (start all processes with a naming wildcard)
Start Replicat rregab (explicitly start only one process)
Once the manager starts or stops processes, the manager is not required for the handling of traffic. This completes starting the Replicat with the database.
This completes configuring data replication.
7. Test All Data Synchronization
- Start all OGG processes.
- Insert rows of data.
- Select rows of data.
Objective
The goals of this exercise are to:
You could have started the Extract before the Replicat, but then there is a danger of the trail file filling up. The Replicat was started in the previous step 6.3.
7.1 Starting All OGG Processes
Using Autostart may simplify this step.
Start all processes on the source host01.
| Host01 - Linux (source) |
[oracle@host01 ~]$ cd $OGG_HOME [oracle@host01 ogg]$ pwd /u01/app/oracle/ogg [oracle@host01 ogg]$ ./ggsci GGSCI (host01) 1> Obey startup.oby GGSCI (host01) 2> -- Created by Joe Admin 10/11/2012 on host01 GGSCI (host01) 3> DBLogin UserID oggadm1@orcl, Password pswd1a Successfully logged into database. GGSCI (host01) 4> Start Mgr MGR is already running. GGSCI (host01) 5> Info Mgr Manager is running (IP port host01.example.com.15001). GGSCI (host01) 6> Info CheckpointTable No checkpoint table specified, using GLOBALS specification (oggadm1.oggchkpt)... Checkpoint table oggadm1.oggchkpt does not exist. GGSCI (host01) 7> Add CheckpointTable No checkpoint table specified, using GLOBALS specification (oggadm1.oggchkpt)... Successfully created checkpoint table oggadm1.oggchkpt. GGSCI (host01) 8> Info All Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT STOPPED EREGAB 00:00:00 02:06:59 EXTRACT STOPPED PREGAB 00:00:00 02:06:38 GGSCI (host01) 9> Start * Sending START request to MANAGER ... EXTRACT EREGAB starting Sending START request to MANAGER ... EXTRACT PREGAB starting GGSCI (host01) 10> Info All Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING EREGAB 00:00:00 00:00:04 EXTRACT RUNNING PREGAB 00:00:00 00:00:08 GGSCI (host01) 11> Exit |
The checkpoint table on the source is optional and not used, but it does no harm, and you might need it later if you ever implement bidirectional replication.
This completes starting all OGG processes.
7.2 Inserting Rows of Data on the Source
Display the before view of the table. Insert two rows of data into hr.regions on host01. Commit the transaction.
| Host01 - Linux (source) |
[oracle@host01 ogg]$ sqlplus hr/hr@orcl SQL> set sqlprompt 'host01_SQL> ' host01_SQL> SELECT * from regions; REGION_ID REGION_NAME ---------- ------------------------- 1 Europe 2 Americas 3 Asia 4 Middle East and Africa host01_SQL> INSERT INTO regions values (10,'Polar'); 1 row created. host01_SQL> INSERT INTO regions values (11,'Oceans'); 1 row created. host01_SQL> COMMIT; Commit complete. host01_SQL> SELECT * FROM regions; REGION_ID REGION_NAME ---------- ------------------------- 10 Polar 11 Oceans 1 Europe 2 Americas 3 Asia 4 Middle East and Africa 6 rows selected. host01_SQL> |
Nothing is replicated unless it is committed.
This completes inserting rows of data on the source.
7.3 Selecting Rows of Data on the Target
You can use either node to see the target database. Show the new table data.
| Exadata - Node 1 (target) |
[oracle@qr01db01 ~]$ sqlplus hr/hr SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 27 17:48:34 2013 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options qr01db_SQL> SELECT * FROM regions; REGION_ID REGION_NAME ---------- ------------------------- 10 Polar 11 Oceans 1 Europe 2 Americas 3 Asia 4 Middle East and Africa 6 rows selected. qr01db_SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@qr01db01 DBFS]$ ll /mnt/DBFS/dbfs_big/ogg/dirdat/ total 2 -rw-rw-rw- 1 oracle oinstall 1374 Feb 27 17:47 ab000000 [oracle@qr01db01 DBFS]$ ll /mnt/DBFS/dbfs_sm/ogg/dirchk/ total 5 -rw-rw-r-- 1 oracle oinstall 4096 Feb 27 17:50 RREGAB.cpr -rw-rw-r-- 1 oracle oinstall 54 Feb 27 17:50 RREGAB.cps [oracle@qr01db01 DBFS]$ |
Note the trail files and checkpoint files on the DBFS. You can use tools such as logdump to examine the trail files.
If you installed the sample schemas but never used them, then they are probably locked. You can unlock the hr schema with a sqlplus DBA command similar to:
This completes selecting rows of data on the target.
This completes testing all data synchronization.
Summary
- Configure the DBFS to support Oracle GoldenGate on Exadata
- Configure the Cluster Ready Services to support multi-node IP access on Exadata
- Configure and start Extract and Replicat processes for synchronization of existing tables
- Generate sample data and test the validity of the replication
- Oracle GoldenGate Product Documentation version 11.2.1 (E35209-01) and other older versions. Of particular interest is the very short section "5.8 Using Oracle GoldenGate with Oracle Exadata".
- Oracle GoldenGate on Linux: Bidirectional Replication from Oracle 11gR2 to Oracle 11gR2 OBE
- White Paper
"A Technical Overview of the Oracle Exadata Database Machine and Exadata Storage Server"
(June 2012) Author: Ronald Weiss - White Paper
(Maximum Availability Architecture)
"Oracle GoldenGate on Oracle Database Machine [Exadata] Configuration"
(January 2013) Author: Stephan Haisley, Contributing Authors: MAA team - Courses from Oracle University
- To learn more about Oracle GoldenGate, refer to additional OBEs in the Oracle Learning Library
- You can see other OGG OBEs listed by going here.
- Home page for http://www.oracle.com/goldengate
- Home page for http://www.oracle.com/exadata
- Home page for http://www.oracle.com/goto/maa (Maximum Availability Architecture)
- Lead Curriculum Developer: Steve Friedberg.
- Other Contributors: Peter Fusek, Stephan Haisley, Chris Lawless, Doug Reid, Matt Taylor.
Oracle GoldenGate can do far more than was demonstrated in this simple exercise.
In this tutorial, you have learned how to:
Resources
Help topics relevant to the topic of this tutorial:
Credits
To help navigate this Oracle by Example, note the following:
- Hiding Header Buttons:
- Click the Title to hide the buttons in the header. To show the buttons again, simply click the Title again.
- Topic List Button:
- A list of all the topics. Click one of the topics to navigate to that section.
- Expand/Collapse All Topics:
- To show/hide all the detail for all the sections. By default, all topics are collapsed.
- Show/Hide All Images:
- To show/hide all the screenshots. By default, all images are displayed.
- Print:
- To print the content. The content currently displayed or hidden will be printed.
To navigate to a particular section in this tutorial, select the topic from the list.