Linux下安裝GoldenGate

zhenghaishu發表於2015-08-01

Linux下安裝GoldenGate

一、檢查資料庫配置情況

檢查歸檔模式、附加日誌、強制日誌引數是否開啟。

10g要檢查回收站功能是否關閉;11g則不必檢查。這裡我們們用的11g,所以不檢查。

SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;

 

LOG_MODE     SUPPLEMENTAL_LOG_DATA_MIN      FORCE_LOGGING

------------ ------------------------------ ---------------

ARCHIVELOG   NO                             NO

   

這裡歸檔模式已開,附加日誌和強制日誌是關閉的。需要開啟附加日誌和強制日誌。

SQL> alter database add supplemental log data;

 

資料庫已更改。

 

SQL> alter database force logging;

 

資料庫已更改。

 

LOG_MODE     SUPPLEMENTAL_LOG_DATA_MIN      FORCE_LOGGING

------------ ------------------------------ ---------------

ARCHIVELOG   YES                YES

 

 

二、安裝GoldenGate

1 先在/u01/下建立ogg目錄,用來安裝GoldenGate程式。當然也可以選擇別的路徑。

$ cd /u01

$ mkdir ogg

 

2 xshell工具把ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip傳到/u01 /ogg/目錄下,並解壓縮

$ cd ogg/

$ unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

Archive:  ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

  inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar 

  inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf 

  inflating: Oracle GoldenGate 11.2.1.0.1 README.txt 

  inflating: Oracle GoldenGate 11.2.1.0.1 README.doc 

$ tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar

 

3 執行ggsci,進入ogg管理控制檯

$ ./ggsci

 

Oracle GoldenGate Command Interpreter for Oracle

Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

 

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

 

 

 

GGSCI (localhost) 1>

 

4 執行create subdirs來建立ogg所需要的目錄

GGSCI (localhost) 1> create subdirs

 

Creating subdirectories under current directory /u01/ogg

 

Parameter files                /u01/ogg/dirprm: already exists

Report files                   /u01/ogg/dirrpt: created

Checkpoint files               /u01/ogg/dirchk: created

Process status files           /u01/ogg/dirpcs: created

SQL script files               /u01/ogg/dirsql: created

Database definitions files     /u01/ogg/dirdef: created

Extract data files             /u01/ogg/dirdat: created

Temporary files                /u01/ogg/dirtmp: created

Stdout files                   /u01/ogg/dirout: created

 

 

GGSCI (localhost) 2>

 

各個目錄的作用:

1dirprm

用於存放GG的引數檔案,這些引數檔案可以透過系統文字編輯器直接編輯,也可以透過在ggsci命令列下edit params來編輯,達到的效果是一樣的。

檔案格式如下:

<group name/user-defined name>.prm

比如mgr.prm

 

2dirrpt

用於存放各個程式的報告檔案,內容為extractreplicatmanager程式執行相關的統計報告資訊。

檔案格式如下:

<group name><sequencenumber>.rpt

 

3dirchk

用於存放由extract抽取程式和replicat複製程式建立的checkpoint檔案,checkpoint檔案儲存當前讀和寫的時間戳資訊,透過這些資訊保證了資料的準確性和資料容錯功能。

檔案格式如下:<groupname><sequence number>.<ext>

group name就是我們配置的程式名稱,序列號,加上字尾名成,字尾名稱分為cpecheckpoint extract)和cprcheckpoint replicat)。

 

4dirpcs

用於存放各個程式的狀態資訊,當相關程式執行的時候,這些程式的相關資訊,比如程式名稱,程式名稱,程式監聽埠,程式ID等等都將被寫入各自狀態資訊檔案。

檔案格式如下:

<group>.<extension>

其中extension3個:pceextract  pcrreplicat  pcmmanager

 

5dirsql

用於存放由TRIGGEN元件建立的SQL指令碼檔案,這些SQL指令碼用於建立GG相關的記錄觸發器和日誌表。

檔案格式如下:

使用者自定義名稱.sql

或者

表名稱.sql

注意都是SQL結尾的指令碼檔案。

 

6dirdef

用於存放由DEFGEN元件建立的定義檔案,包含在異構環境同步中的源或者目標端的資料定義。是一個可編輯的文字檔案,比如你要新增一個新進建立表的相關的同步定義就可以在此直接編輯。

檔案格式如下:

使用者透過DEFGEN引數檔案自定義

 

7dirdat

用於存放GG跟蹤檔案和由extract程式建立的抽取檔案,這些檔案將被複制程式(或者其他需要的)進一步處理和使用。

檔案格式如下:

使用者自定義的2個字首字元+6位序列號(跟蹤檔案)

或者   

使用者自定義的格式(抽取檔案)

 

8dirtmp

用於執行大事務處理過程,官方的說法是當請求的記憶體超過分配的記憶體的時候,就會……巴拉巴拉,這個怎麼理解和解釋呢?臨時檔案目錄?

記住一點就是了:不要編輯裡面的任何檔案和內容。

 

9dirout

廢棄,不再使用。

 

最後用表格來歸納一下:

目錄

說明

dirprm

引數檔案

dirrpt

報告檔案

dirchk

檢查點檔案

dirpcs

狀態檔案

dirsql

sql指令碼檔案

dirdef

資料定義檔案

dirdat

跟蹤檔案和抽取檔案

dirtmp

臨時檔案

 

5 Oracle中建立GoldenGate專屬使用者

SQL> create user ogg identified by oracle;

 

使用者已建立。

 

SQL> grant connect,resource to ogg;

 

授權成功。

 

SQL> grant unlimited tablespace to ogg;

 

授權成功。

 

SQL> grant execute on utl_file to ogg;

 

授權成功。

 

SQL> grant create table,create sequence to ogg;

 

授權成功。

 

SQL>

 

6為新建立的ogg使用者執行配置指令碼。在ogg的安裝目錄下使用sys登陸sqlplus,然後執行四個配置指令碼。

1marker_setup.sql,作用是安裝DDL支援所需要的GoldenGate marker系統

[oracle@localhost ~]$ cd /u01/ogg/

[oracle@localhost ogg]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期二 7 28 14:05:39 2015

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

 

連線到:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> @marker_setup

 

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:ogg

 

 

Marker setup table script complete, running verification script...

Please enter the name of a schema for the GoldenGate database objects:

Setting schema name to OGG

 

MARKER TABLE

-------------------------------

OK

 

MARKER SEQUENCE

-------------------------------

OK

 

Script complete.

SQL>

 

2ddl_setup.sql

SQL> @ddl_setup

 

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:ogg

 

Working, please wait ...

Spooling to file ddl_setup_spool.txt

 

Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...

 

Check complete.

 

3role_setup.sql作用是刪除和建立DDL同步需要的角色,它授權DDL物件上的DML操作。

SQL> @role_setup

 

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:ogg

已寫入 file role_setup_set.txt

 

PL/SQL 過程已成功完成。

 

 

Role setup script complete

 

Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:

 

GRANT GGS_GGSUSER_ROLE TO <loggedUser>

 

where <loggedUser> is the user assigned to the GoldenGate processes.

SQL>

 

根據提示,這裡要執行GRANT GGS_GGSUSER_ROLE TO ogg

SQL> GRANT GGS_GGSUSER_ROLE TO ogg;

 

授權成功。

 

4ddl_enable.sql,作用是啟用ddl觸發器。

SQL> @ddl_enable    

 

觸發器已更改

 

SQL>

 

7 測試使用者是否建立成功

GGSCI (localhost) 2> dblogin userid ogg

Password:

Successfully logged into database.

 

GGSCI (localhost) 3>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29485627/viewspace-1758677/,如需轉載,請註明出處,否則將追究法律責任。

相關文章