LINUX ORACLE OGG12C整合模式安裝(一)

夢夕林1992發表於2023-01-18

版本支援

支援資料庫

如下為OGG12C 支援的資料庫版本(以OGG12.3 版本以及Linux 環境為例)

OS Version

OS Update Type

OS Update Level

Run Mode 32/64 Bit

Database Version

Oracle Linux 6

Update Level

1+

64

12.1.0.1+; 11.2.0.3+

Oracle Linux 6

Update Level

4+

64

12.2.0.1+

Oracle Linux 7

Update Level

0+

64

12.2.0.1+; 12.1.0.2+, 11.2.0.4+

Red Hat Enterprise Linux 6

Update Level

1+

64

12.1.0.1+; 11.2.0.3+

Red Hat Enterprise Linux 6

Update Level

4+

64

12.2.0.1+

Red Hat Enterprise Linux 7

Update Level

0+

64

12.2.0.1+; 12.1.0.2+, 11.2.0.4+

SLES 11

Service Pack

0+

64

12.2.0.1+; 12.1.0.1+; 11.2.0.1+

SLES 12

Service Pack

0+

64

12.2.0.1+; 12.1.0.2+; 11.2.0.4+

 

具體其他環境支援的資料庫可以檢視:

 

檢查生產庫

開啟歸檔

SQL> archive log list

若沒開啟,則需要開啟

將資料庫開啟至mount 狀態

SQL> alter database archivelog;

建立附加日誌

SQL> select supplemental_log_data_min from v$database;

 

SUPPLEME

--------

YES                       ------------- 若不是YES ,需要開啟

 

開啟語句:

SQL> alter database add supplemental log data;         --------- mount 狀態下建立速度快

SQL> ALTER SYSTEM SWITCH LOGFILE;

 

開啟force log

SQL> select force_logging from v$database;

 

FOR

---

YES

 

開啟語句:

SQL> ALTER DATABASE FORCE LOGGING;

 

查詢不支援的列的表格

SQL> select owner,table_name,column_name,data_type from dba_tab_columns where owner in ('SCHEMA1',’ SCHEMA2’,’ SCHEMA3’) and data_type in ('ANYDATA','ANYDATASET','ANYTYPE','BFILE','BINARY_INTEGER','MLSLABEL','PLS_INTEGER','TIMEZONE_ABBR','TIMEZONE_REGION','URITYPE,UROWID');

 

查詢nologging表以及物化檢視

檢視要複製的表的日誌資訊是完整的,確保是logging 。把nologing 變成logging

SQL> select owner,table_name from dba_tables where owner in ('SCHEMA1',’ SCHEMA2’,’ SCHEMA3’) and logging='NO' and temporary='N';

 

SQL> alter table xxx.xxxx logging;

 

SQL> select object_name,owner from dba_objects where object_type='MATERIALIZED VIEW' and owner in ('SCHEMA1',’ SCHEMA2’,’ SCHEMA3’);

生產庫建立管理使用者

-- 建立管理使用者表空間(可選)

SQL> create tablespace odc_tps datafile '/ora12c/app/oradata/ORA12C/odc01.dbf' size 100M autoextend on;

 

-- 建立管理使用者表空間和賦權

-- CDB/PDB 環境

SQL> create user odc identified by odc default tablespace odc_tps;

SQL> GRANT CREATE SESSION,CONNECT,RESOURCE,ALTER ANY TABLE,ALTER SYSTEM, DBA,SELECT ANY DICTIONARY,SELECT ANY TRANSACTION,FLASHBACK ANY TABLE, SELECT ANY TABLE TO ODC;

--11204

exec dbms_goldengate_auth.grant_admin_privilege('odc')

--11203

Exec dbms_goldengate_auth.grant_admin_privilege('ggadm',grant_select_privileges=>true)

 

-- 安裝成功後可以收回dba 許可權,但是要授予UNLIMITED TABLESPACE 許可權。

GRANT UNLIMITED TABLESPACE TO odc;

或者alter user odc quota unlimited on users;

 

-- ddl_setup 時報錯,透過授予以下許可權解決。

grant create any table to odc;

grant create any view to odc;

grant create any procedure to odc;

grant create any sequence to odc;

grant create any index to odc;

grant create any trigger to odc;

grant create any view to odc;

 

--CDB/PDB 環境

SQL> create user C##odc12c identified by C##odc12 default tablespace odc_tps;

 

-- 授權,在CDB PDB 中都需要授權,所以使用container=all

Exec dbms_goldengate_auth.grant_admin_privilege (grantee => 'C##ODC',  privilege_type => 'CAPTURE',  grant_select_privileges => TRUE,  do_grants => TRUE,  container => 'ALL'  )

 

grant connect, create session, resource, ALTER ANY TABLE, ALTER SYSTEM, SELECT ANY DICTIONARY, SELECT ANY TRANSACTION, FLASHBACK ANY TABLE to c##odc12 container=all;

grant dba to c##odc12 container=all;

 

 

開啟引數

alter system set enable_goldengate_replication=true;

 

新增表級別Supplemental Logging

ggsci>dblogin userid odc password odc

ggsci>add trandata test1.*

ggsci>info trandata test1.*

 

--CDB/PDB 環境

ggsci>dblogin userid C##odc12@ORA12C password C##odc12 

ggsci>add trandata PDBORA12C.test1.*

ggsci>info trandata PDBORA12C.test1.*

 

設定閃回查詢 ( 可選 )

可以設定如下引數

UNDO_MANAGEMENT=AUTO

UNDO_RETENTION=86400

在大容量環境中,可以向上調整UNDO_RETENTION

 

新特性 Credential Store and USERIDALIAS

類似於錢包的概念,提高安全性。

-- 生成credentialstore 檔案

GGSCI (XQZT-PC) 1> add credentialstore

Credential store created in .\dircrd\.

 

GGSCI (XQZT-PC) 2> alter credentialstore add user c##ggadmin alias ggroot

Password:

Credential store in .\dircrd\ altered.

 

-- 使用別名登入

GGSCI (XQZT-PC) 3> dblogin useridalias ggroot

Successfully logged into database CDB$ROOT.

 

-- 也可以建立PDB 的儲存別名

GGSCI (XQZT-PC) 1> alter credentialstore add user c##ggadmin@pdborcl alias ggpd

borcl

Password:

Credential store in .\dircrd\ altered.

GGSCI (XQZT-PC) 2> dblogin useridalias ggpdborcl

Successfully logged into database PDBORCL.

 

-- 檢視別名

GGSCI (XQZT-PC) 1> info credentialstore

Reading from .\dircrd\:

Default domain: OracleGoldenGate

Alias: ggroot

Userid: c##ggadmin

Alias: ggpdborcl

Userid: c##ggadmin@pdborcl

 

安裝支援 Oracle Sequences 元件(根據需要設定)

1 SYSDBA 連線資料庫

 

2 、若已經組裝DDL 元件則不需要這個步驟

CREATE USER DDLuser IDENTIFIED BY password; 

GRANT CONNECT, RESOURCE, DBA TO DDLuser;

 

3 、編輯./GLOBALS

EDIT PARAMS ./GLOBALS

GGSCHEMA schema

 

4 、進入到安裝ogg 目錄,並連線資料庫執行

@sequence.sql

 

5 、源端

GRANT EXECUTE on DDLuser.updateSequence TO DBLOGINuser;

 

6 、目標端

GRANT EXECUTE on DDLuser.replicateSequence TO Replicatuser;

 

7 、源端

ALTER TABLE sys.seq$ ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;

 

配置整合模式的連線串

如果您將使用整合捕獲和整合Replicat ,則在tnsnames 中每一個都需要一個專用的伺服器連線。

在配置這些程式時,您可以透過Extract Replicat 引數檔案中的USERID USERIDALIAS 引數指示程式使用這些連線。

test =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.238.57)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

使用者連線

USERID xjm@test, PASSWORD xjm

USERIDALIAS ext

GGSCI (rac11gn1) 5> INFO CREDENTIALSTORE DOMAIN OracleGoldenGate

Reading from credential store:

Domain: OracleGoldenGate

  Alias: xjm

  Userid: xjm@test

 

安裝軟體(生產和備端步驟一樣)

建立安裝目錄或檔案系統

# mkdir /odc/

#chown oracle:oinstall /odc

 

配置library 環境變數

HP-UX : SHLIB_PATH

AIX : LIBPATH

LINUX : LD_LIBRARY_PATH

例如:

export LD_LIBRARY_PATH=/odc:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

 

source .bash_profile

 

安裝軟體

12 版本後很少有直接解壓就可以用的版本,都是需要圖形化安裝或者靜默安裝。

1 、上傳壓縮包並解壓至 odc 目錄

$unzip xxx.zip

 

靜默安裝

進入到Disk1/response 目錄下,編輯檔案oggcore.rsp

vi oggcore.rsp

#------------------------------------------------------------------------

# Specify the installation option.

# Specify ORA18c for installing Oracle GoldenGate for Oracle Database 18c or

#         ORA12c for installing Oracle GoldenGate for Oracle Database 12c or

#         ORA11g for installing Oracle GoldenGate for Oracle Database 11g 

#------------------------------------------------------------------------

INSTALL_OPTION=ORA11g

 

#------------------------------------------------------------------------

# Specify a location to install Oracle GoldenGate

#------------------------------------------------------------------------

SOFTWARE_LOCATION=/odc/

 

#------------------------------------------------------------------------

# Specify true to start the manager after installation. 

#------------------------------------------------------------------------

START_MANAGER=true

 

#------------------------------------------------------------------------

# Specify a free port within the valid range for the manager process.

# Required only if START_MANAGER is true.

#------------------------------------------------------------------------

MANAGER_PORT=7809

 

#------------------------------------------------------------------------

# Specify the location of the Oracle Database.

# Required only if START_MANAGER is true.

#------------------------------------------------------------------------

DATABASE_LOCATION=/oracle/app/product/11.2.0/db_1

 

 

安裝

[oracle@rac11gn1 Disk1]$ ./runInstaller -silent -responseFile /odc/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp

 

2 、建立子工作目錄

$ ./ggsci

ggsci>create subdirs

 

以上所建立的目錄的作用:

Name

purpose


dirchk

Checkpoint files

用來存放檢查點(checkpoint) 檔案, 次檢查點是ogg 自己的檢查點與例項不同

dirdat

GoldenGate trails

用來存放TRAIL 檔案

dirdef

Data definition files

用來存放透過DEFGEN 工具生成的源或目標端資料定義檔案

dirprm

Parameter files

用來存放配置引數檔案

dirpcs

Process status files

用來存放程式狀態檔案

dirrpt

Report files

用來存放程式報告檔案

dirsql

SQL script files

用來存放SQL 指令碼檔案

dirtmp

Temporary files

當事物所需要的記憶體超過已分配記憶體時, 預設儲存在這個目錄

 

3 、建立管理程式

建立管理程式所需引數:

引數

閥值

定義

port

7809

mgr 程式使用的TCP/IP 埠偵聽請求,預設埠為7809

DYNAMICPORTLIST

7800-7810

指定可用動態 TCP/IP  埠列表,用於源端與目標端程式通訊的繫結,最大支援256 個埠

PURGEOLDEXTRACTS

./dirdat/cr*

定期清理抽取出的過期檔案,可以被設定在Manager, Extract, and Replicat 引數檔案中,oracle 建議設定在Manager

USECHECKPOINTS


根據任何MINKEEP 規則,允許清除那些已經被Extract Replicat 程式檢測過的,保證資料不丟失。

MINKEEPHOURS

24

trail 檔案的保留時間,超過這個時間則刪除

autorestart

extract *

指定程式失敗時自動重啟

retries 

10

指定嘗試重新啟動程式的次數(預設嘗試2 次)

waitminutes

10

指定重新啟動程式的時間,直到必要資源變得可用或一些其他的事件發生。預設的延遲時間為2 分鐘。

 

具體設定如下:

ggsci>edit param mgr

輸入:

port 7809

DYNAMICPORTLIST 7800-7810

PURGEOLDEXTRACTS ./dirdat/cr*, USECHECKPOINTS, MINKEEPHOURS 24

autorestart extract * retries 10 waitminutes 10

 

ggsci>edit param ./GLOBALS

輸入:

GGSCHEMA odc

CHECKPOINTTABLE odc.ggs_checkpoint --- 儲存退出

 

ggsci>start mgr

 

 


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

相關文章