oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate

--继昨天的测试,这一篇实施单实例双向复制(完全重新搭建)

--环境不变

db1,db2(单实例)
10.1*.1*
orcl,ogg
centos 6.5,centos 6.5
11.2.0.4,11.2.0.4

1 检查归档,日志模式(orcl,ogg)

SCOTT@ orcl >conn / as sysdba
Connected.
SYS@ orcl >select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database;

NAME      OPEN_MODE           FOR SUPPLEME
--------- -------------------- --- --------
ORCL      READ WRITE           YES YES
SYS@ orcl >archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     21
Next log sequence to archive   23
Current log sequence           23
SYS@ orcl >alter system switch logfile;

System altered.
1 row selected.

SCOTT@ ogg >conn / as sysdba
Connected.
SYS@ ogg >select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database;

NAME      OPEN_MODE           FOR SUPPLEME
--------- -------------------- --- --------
OGG      READ WRITE           YES YES
SYS@ ogg >archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     74
Next log sequence to archive   76
Current log sequence           76
SYS@ ogg >alter system switch logfile;

System altered.

2 创建OGG表空间和OGG用户---两个服务器都要做之前已经执行过 (orcl,ogg)

---运行 OGG 支持 DDL 脚本
如果要让 OGG 支持 DDL 操作,还需要额外运行几个脚本,这些脚本是 OGG 带的而不是 ORACLE 带的,源端与目标端都需要

grant CONNECT, RESOURCE to ogg;
grant SELECT ANY DICTIONARY, SELECT ANY TABLE to ogg;
grant ALTER ANY TABLE to ogg;
grant FLASHBACK ANY TABLE to ogg;
grant EXECUTE on DBMS_FLASHBACK to ogg;
grant insert any table to ogg;
grant update any table to ogg;
grant delete any table to ogg;
GRANT EXECUTE ON UTL_FILE TO  ogg;
GRANT CREATE TABLE,CREATE SEQUENCE TO ogg;  
grant create any table to ogg;
grant create any view to ogg;
grant create any procedure to ogg;
grant create any sequence to ogg;
grant create any index to ogg;
grant create any trigger to ogg;
grant create any view to ogg;
[oracle@ogg ~]$ cd /u01/app/ogg
[oracle@ogg ogg]$ sqlplus / as sysdba
---SYS@ orcl >@/u01/app/ogg/marker_setup.sql
---SYS@ orcl >@/u01/app/ogg/ddl_setup.sql
---SYS@ orcl >@/u01/app/ogg/role_setup.sql
---SYS@ orcl >@/u01/app/ogg/ddl_enable.sql

如果安装过程中报错

SYS@ orcl >@/u01/app/ogg/ddl_setup.sql
Line/pos                 Error
---------------------------------------- -----------------------------------------------------------------
126/9                     PL/SQL: SQL Statement ignored
128/23                     PL/SQL: ORA-00942: table or view does not exist
133/21                     PL/SQL: ORA-02289: sequence does not exist
133/5                     PL/SQL: SQL Statement ignored
657/14                     PLS-00905: object OGG.DDLAUX is invalid
657/5                     PL/SQL: Statement ignored
919/25                     PL/SQL: ORA-00942: table or view does not exist
919/4                     PL/SQL: SQL Statement ignored

###卸载ogg,并使支持DDL功能失效

---SYS@ orcl >@/u01/app/ogg/ddl_disable.sql
SYS@ orcl >@/u01/app/ogg/ddl_disable.sql
Trigger altered.
SYS@ orcl >@/u01/app/ogg/ddl_remove.sql
DDL replication removal script.
WARNING: this script removes all DDL replication objects and data.
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.
Enter Oracle GoldenGate schema name:scott
Working, please wait ...
Spooling to file ddl_remove_spool.txt
Script complete.
SYS@ orcl >@/u01/app/ogg/marker_remove.sql
Marker removal script.
WARNING: this script removes all marker objects and data.
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.
Enter Oracle GoldenGate schema name:scott
PL/SQL procedure successfully completed.
Sequence dropped.
Table dropped.
Script complete.
View Code

相关文章: