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>
各个目录的作用:
(1)dirprm
用于存放GG的参数文件,这些参数文件可以通过系统文本编辑器直接编辑,也可以通过在ggsci命令行下edit params来编辑,达到的效果是一样的。
文件格式如下:
<group name/user-defined name>.prm
比如mgr.prm
(2)dirrpt
用于存放各个进程的报告文件,内容为extract、replicat和manager进程运行相关的统计报告信息。
文件格式如下:
<group name><sequencenumber>.rpt
(3)dirchk
用于存放由extract抽取进程和replicat复制进程创建的checkpoint文件,checkpoint文件保存当前读和写的时间戳信息,通过这些信息保证了数据的准确性和数据容错功能。
文件格式如下:<groupname><sequence number>.<ext>
group name就是我们配置的进程名称,序列号,加上后缀名成,后缀名称分为cpe(checkpoint extract)和cpr(checkpoint replicat)。
(4)dirpcs
用于存放各个进程的状态信息,当相关进程运行的时候,这些进程的相关信息,比如程序名称,进程名称,进程监听端口,进程ID等等都将被写入各自状态信息文件。
文件格式如下:
<group>.<extension>
其中extension有3个:pce(extract) pcr(replicat) pcm(manager)
(5)dirsql
用于存放由TRIGGEN组件创建的SQL脚本文件,这些SQL脚本用于创建GG相关的记录触发器和日志表。
文件格式如下:
用户自定义名称.sql
或者
表名称.sql
注意都是SQL结尾的脚本文件。
(6)dirdef
用于存放由DEFGEN组件创建的定义文件,包含在异构环境同步中的源或者目标端的数据定义。是一个可编辑的文本文件,比如你要添加一个新进创建表的相关的同步定义就可以在此直接编辑。
文件格式如下:
用户通过DEFGEN参数文件自定义
(7)dirdat
用于存放GG跟踪文件和由extract进程创建的抽取文件,这些文件将被复制进程(或者其他需要的)进一步处理和使用。
文件格式如下:
用户自定义的2个前缀字符+6位序列号(跟踪文件)
或者
用户自定义的格式(抽取文件)
(8)dirtmp
用于执行大事务处理过程,官方的说法是当请求的内存超过分配的内存的时候,就会……巴拉巴拉,这个怎么理解和解释呢?临时文件目录?
记住一点就是了:不要编辑里面的任何文件和内容。
(9)dirout
废弃,不再使用。
最后用表格来归纳一下:
目录
说明
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,然后执行四个配置脚本。
(1)marker_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>
(2)ddl_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.
(3)role_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;
授权成功。
(4)ddl_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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29485627/viewspace-1758677/