一般第一步都是创建用户。前面我们已经做过操作,用户已建好,这里仍然沿用前面创建的ggate用户,当然此刻也可以创建一个新的用户,注意用户的默认表空间不要指定为SYSTEM,否则在初始化DDL支持时可能会遇到段无法扩展,或包无法编译等错误。
正式应用的话,需要注意ggate用户所在表空间是否有充足的空间。
为ggate用户授予utl_file的execute权限,执行命令如下:
SQL> grant execute on utl_file to ggate;
Grant succeeded.
增加下列内容:
接下来有一个可选操作,就是说是否要自定义DDL相关对象的名称,一般情况下不需要修改,ORACLE也建议保持数据库对象默认值,如果由于某些特殊的需求要改的话,那么就需要现在改,而不能等到部署完成。
修改主要是通过重定义params.sql中的相关变量值,该文件位于GoldenGate软件安装目录下,编译并保存即可。
另外,改完params.sql后,还需要修改GLOBALS配置文件,新增对象名称的对应关系,例如:
MARKERTABLE
DDLTABLE前者表示Marker表,后一个表示DDL历史表。
接下来要执行一堆的SQL脚本,这些脚本均在GoldenGate安装目录,因此建议移动到GoldenGate目录下,以方便调用脚本(当然,直接完整路径方式调用也是可以的):
以SYSDBA身份登录到SQL*Plus,此时应该断开所有连接到ORACLE数据库的会话,并且不再允许创建新会话,仅保留刚刚创建的SYSDBA身份登录的SQL*Plus。
本步要执行的脚本比如多,先列个列表备忘:
详细执行步骤如下:
该脚本安装marker系统,这部分为启用DLL支持所必备,执行该脚本时会提示输入GoldenGate管理帐户schema名,例如:
[oracle@ora9node1 ggate]$ sqlplus "/ as sysdba"
SQL> set line 150 pages 1000
SQL> @marker_setup
Marker setup 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:ggate
Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE
MARKER TABLE
-------------------------------
OK
MARKER SEQUENCE
-------------------------------
OK
Script complete.
执行该脚本要确认关闭掉所有ORACLE会话,未被关闭的会话会以列表形式显示,执行过程中会要求希望对象属主,并选择安装模式。
如果是初次安装就选择“INITIALSETUP”,该模式假设当前没有任何GoldenGate DDL对象存在,如果存在则会删除并重建。如果是重新安装,则应该选择“NORMAL”。具体执行示例如下:
SQL> @ddl_setup
GoldenGate DDL Replication setup script.
Verifying that current user has privileges to install DDL Replication...
Checking user sessions...
Check complete.
You will be prompted for the name of a schema for the 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 GoldenGate schema name:ggate
You will be prompted for the mode of installation.
To install or reinstall DDL replication, enter INITIALSETUP
To upgrade DDL replication, enter NORMAL
Enter mode of installation:INITIALSETUP
Working, please wait ...
Spooling to file ddl_setup_spool.txt
Using GGATE as a GoldenGate schema name, INITIALSETUP as a mode of installation.
Working, please wait ...
DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE
DDLORA_GETTABLESPACESIZE STATUS:
.....................
.....................
Analyzing installation status...
STATUS OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components
Script complete.
该操作会重建DDL同步所需的权限,授予GoldenGate中的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:ggate
Wrote file role_setup_set.txt
PL/SQL procedure successfully completed.
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
where is the user assigned to the GoldenGate processes.
按照上面返回的提示,执行授权操作,注意是将权限授予执行Extract/GGSCI或其它管理操作的用户,我们这里的情况看显然是ggate,执行命令如下:
SQL> GRANT GGS_GGSUSER_ROLE TO GGATE;
Grant succeeded.
启用DDL触发器,以捕获DDL操作:
SQL> @ddl_enable
Trigger altered.
要提高DDL触发器的性能,可以通过ddl_pin脚本,该脚本会将触发器使用的包加载到内存,以此提高效率。该脚本执行时需要引用dbms_shared_pool系统包,因此在使用ddl_pin脚本前需要确保dbms_shared_pool可用。
SQL> @?/rdbms/admin/dbmspool.sql
Package created.
Grant succeeded.
View created.
Package body created.
执行ddl_pin脚本需要指定GoldenGate管理员schema名称,例如:
SQL> @ddl_pin ggate
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
然后,用于同步DDL操作的对象就创建完成了。
首先在源端修改extract进程的配置文件,例如:
在适当位置增加下列内容:
该语句用以支持create table操作,如果需要其它如alter/drop等,则增加相应配置即可。
启动extract进程:
GGSCI (ora9node1) 20> start extract ext2
Sending START request to MANAGER ...
EXTRACT EXT2 starting
随后sqlplus中创建新表:
SQL> conn jss/jss
Connected.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
J1 TABLE
J2 TABLE
2 rows selected.
SQL> create table j3(id number);
Table created.
登录到目标端ggsci命令行模式下,同样需要对replicat的参数进行配置:
在适当位置增加一模一样的内容(当然此处也可以与源端不同,具体根本实际情况设定):
启动replicat进程:
GGSCI (rhel5u3) 5> start replicat rep2
Sending START request to MANAGER ...
REPLICAT REP2 starting
查看新创建的对象是否同步过来的:
GGSCI (rhel5u3) 9> dblogin userid ggate,password ggate
Successfully logged into database.
GGSCI (rhel5u3) 10> list tables jss.j3
JSS.J3
Found 1 tables matching list criteria.
成功同步。
=========================================
相关文章:
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7607759/viewspace-704065/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7607759/viewspace-704065/