Oracle GoldenGate 安裝配置全記錄
1 安裝OGG
1.1 上傳OGG壓縮包
解壓壓縮包
1.2 配置環境變數
.bash_profile中新增如下內容
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
1.3 建立OGG工作目錄
GGSCI (rac01) 3> create subdirs
Creating subdirectories under current directory /home/oracle/ogg
Parameter files /home/oracle/ogg/dirprm: already exists
Report files /home/oracle/ogg/dirrpt: created
Checkpoint files /home/oracle/ogg/dirchk: created
Process status files /home/oracle/ogg/dirpcs: created
SQL script files /home/oracle/ogg/dirsql: created
Database definitions files /home/oracle/ogg/dirdef: created
Extract data files /home/oracle/ogg/dirdat: created
Temporary files /home/oracle/ogg/dirtmp: created
Stdout files /home/oracle/ogg/dirout: created
2 為OGG配置資料庫
2.1 源端、目標端建立GGS使用者
SQL> create tablespace ggs_tbs datafile size 50m;
Tablespace created.
SQL> create user ggs identified by ggs default tablespace ggs;
User created.
SQL> grant dba to ggs;
Grant succeeded.
2.2 源端、目標端開啟force logging和輔助日誌
SQL> alter database force logging;
Database altered.
SQL> alter database add supplemental log data;
Database altered.
2.3 源端、目標端支援sequence
GGSCI (rac01) 1> edit params ./globals
輸入:ggschema ggs
SQL> @sequence
Please enter the name of a schema for the GoldenGate database objects:
ggs
2.4 源端、目標端支援ddl複製
SQL> alter system set recyclebin=off deferred scope=both;
System altered.
SQL> @marker_setup.sql
Marker setup script
You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter Oracle GoldenGate schema name:ggs
SQL> @ddl_setup.sql
Oracle GoldenGate DDL Replication setup script
Verifying that current user has privileges to install DDL Replication...
You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter Oracle GoldenGate schema name:ggs
SQL> @role_setup.sql
GGS Role setup script
This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:ggs
GRANT GGS_GGSUSER_ROLE TO <loggedUser>
SQL> @?/rdbms/admin/dbmspool.sql
Package created.
Grant succeeded.
SQL> @ddl_pin ggs;
3 源端配置OGG
3.1 配置manager
GGSCI (rac01) 3> edit params mgr (空檔案直接儲存退出即可,除非預設埠7809被佔用)
GGSCI (rac01) 4> start mgr
Manager started.
3.2 新增表級trandata
GGSCI (rac01) 8> DBLOGIN USERID ggs
Password:
Successfully logged into database.
GGSCI (rac01) 9> add trandata hr.test (表名test可以為*萬用字元)
2016-10-25 08:04:43 WARNING OGG-00869 No unique key is defined for table 'TEST'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table HR.TEST.
3.3 新增抽取程序
GGSCI (rac01) 10> add extract ext01,tranlog,begin now,threads 2
EXTRACT added.
GGSCI (rac01) 12> add exttrail ./dirdat/ex,extract ext01
EXTTRAIL added.
GGSCI (rac01) 13> edit params ext01
EXTRACT ext01
USERID ggs, PASSWORD ggs
TRANLOGOPTIONS ASMUSER sys@asm,ASMPASSWORD oracle
DISCARDFILE ./dirdat/ex.dsc, purge
EXTTRAIL ./dirdat/ex
ddl include all
TABLE hr.*;
3.4 新增傳輸程序
GGSCI (rac01) 17> add extract pump01,exttrailsource ./dirdat/ex
EXTRACT added.
GGSCI (rac01) 18> add rmttrail /home/oracle/ogg/dirdat/ex,EXTRACT pump01
RMTTRAIL added.
GGSCI (rac01) 19> edit params pump01
EXTRACT pump01
USERID ggs, PASSWORD ggs
PASSTHRU
RMTHOST 192.168.56.203, MGRPORT 7809, TCPBUFSIZE 100000, TCPFLUSHBYTES 300000
RMTTRAIL /home/oracle/ogg/dirdat/ex
TABLE hr.*;
4 目標端配置OGG
4.1 建立checkpoint table
GGSCI (hadoop03) 1> dblogin userid ggs,password ggs
Successfully logged into database.
GGSCI (hadoop03) 2> add checkpointtable ggs.checkpoint
Successfully created checkpoint table ggs.checkpoint.
GGSCI (hadoop03) 3> edit params ./GLOBALS
CHECKPOINTTABLE ggs.checkpoint
4.2 建立複製程序
GGSCI (hadoop03) 1> add replicat rep01,exttrail /home/oracle/ogg/dirdat/ex,checkpointtable ggs.checkpoint
REPLICAT added.
GGSCI (hadoop03) 14> edit params rep01
REPLICAT repnd
USERID ggs, PASSWORD ggs
BATCHSQL
PURGEOLDEXTRACTS
HANDLECOLLISIONS
ASSUMETARGETDEFS
INSERTAPPEND
DISCARDFILE ./dirdat/r1.dsc, purge
ddl include all
map hr.*, target hr.*;
5 啟動抽取和複製程序
5.1 源端
GGSCI (rac01) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT STOPPED EXT01 00:00:00 00:20:23
EXTRACT STOPPED TRANS01 00:00:00 00:11:37
GGSCI (rac01) 2> start EXT01
Sending START request to MANAGER ...
EXTRACT EXT01 starting
GGSCI (rac01) 3> start TRANS01
Sending START request to MANAGER ...
EXTRACT TRANS01 starting
GGSCI (rac01) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXT01 00:00:00 00:20:31
EXTRACT RUNNING TRANS01 00:00:00 00:11:45
5.2 目標端
GGSCI (hadoop03) 13> start repnd
Sending START request to MANAGER ...
REPLICAT REPND starting