1.源数据库启用最少的补充日志记录和强制日志记录(源端-xag130)--本次系列先配置 xag130 --> xag131 单向
[oracle@xag130 ~]$ sql / as sysdba
SQL> SET SQLFORMAT ansiconsole
SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;
SUPPLEMENTAL_LOG_DATA_MIN FORCE_LOGGING
NO NO
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL> ALTER DATABASE FORCE LOGGING;
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;
SUPPLEMENTAL_LOG_DATA_MIN FORCE_LOGGING
YES YES
#检查被用于测试得普通用户xag及其pdb1 的 补充日志记录和强制日志记录
[oracle@xag130 ~]$ sql xag/123456@xag130:1521/pdb1
SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;
SUPPLEME FORCE_LOGGING
-------- ---------------------------------------
YES YES
2.在数据库中启用Oracle GoldenGate 复制(xag130,xag131)
#必须为Oracle 11.2.0.4或更高版本的数据库显式启用支持Oracle GoldenGate捕获和应用所需的数据库服务
[oracle@xag130 ~]$ sql / as sysdba
SQL> ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE;
3.创建单独的用户 ogg_admin 来管理ogg复制 (xag130,xag131)
[oracle@xag130 ~]$ sql sys/123456@xag130:1521/pdb1 as sysdba
SQL> create tablespace PDB1_OGG datafile ‘/u02/oradata/cdb1/pdb1/PDB1_OGG1.dbf‘ size 128M AUTOEXTEND ON NEXT 64M MAXSIZE UNLIMITED;
SQL> CREATE USER ogg_admin IDENTIFIED BY "123456" DEFAULT TABLESPACE PDB1_OGG TEMPORARY TABLESPACE PDB1_TEMP_GP;
4.源数据库用户 ogg_admin 授权 (单向时)
[oracle@xag130 ~]$ sql sys/123456@xag130:1521/pdb1 as sysdba
SQL> GRANT CREATE SESSION TO ogg_admin WITH ADMIN OPTION;
SQL> GRANT RESOURCE TO ogg_admin;
SQL> GRANT ALTER SYSTEM TO ogg_admin;
#授予捕获和应用双权限 (双向时配置)
--SQL> dbms_goldengate_auth.grant_admin_privilege(‘ogg_admin‘)
or
#授予捕获权限 (源端配置)
SQL> exec dbms_goldengate_auth.grant_admin_privilege(‘ogg_admin‘,‘capture‘);
SQL> commit;
SQL> grant dba to ogg_admin;
5.目标数据库用户 ogg_admin 授权 (单向时)
[oracle@xag131 ~]$ sql sys/123456@xag131:1521/pdb1 as sysdba
SQL> GRANT CREATE SESSION TO ogg_admin WITH ADMIN OPTION;
SQL> GRANT RESOURCE TO ogg_admin;
SQL> GRANT ALTER SYSTEM TO ogg_admin;
#授予捕获和应用双权限 (双向时配置)
--SQL> dbms_goldengate_auth.grant_admin_privilege(‘ogg_admin‘)
or
#授予应用权限 (目标端配置)
SQL> exec dbms_goldengate_auth.grant_admin_privilege(‘ogg_admin‘,‘apply‘);
SQL> commit;
SQL> grant select any table,insert any table,update any table,delete any table,drop any table to ogg_admin;
SQL> grant create table,create sequence to ogg_admin;
SQL> grant dba to ogg_admin;
6.启用架构(用户)级别的补充日志记录(source端:xag130)
[oracle@xag130 ~]$ ggsci
GGSCI (xag130) 1> DBLOGIN USERID ogg_admin@xag130:1521/pdb1, PASSWORD 123456
GGSCI (xag130 as ogg_admin@cdb1/PDB1) 2> ADD SCHEMATRANDATA xag ALLCOLS
or
GGSCI (xag130 as ogg_admin@cdb1/PDB1) 2> ADD SCHEMATRANDATA xag NOSCHEDULINGCOLS
#若要仅为特定表启用日志记录,请使用ADD TRANDATA
GGSCI (xag130 as ogg_admin@cdb1/PDB1) 2> ADD TRANDATA xag.my_healt_check
7.Create Subdirectories (xag130,xag131)
#这将在$OGG_HOMEr目录中生成子目录。然而,OGG12.x不需要这一步骤。 OUI负责为您创建这些目录。 如果你仍然运行这个命令,就没有什么坏处。 它将提示目录已经存在。
[oracle@xag130 ~]$ cd $OGG_HOME --(必须进入此目录)
[oracle@xag130 ogg]$ ggsci
GGSCI (xag130) 1> CREATE SUBDIRS
Creating subdirectories under current directory /u01/app/oracle/product/ogg
Parameter file /u01/app/oracle/product/ogg/dirprm: already exists.
Report file /u01/app/oracle/product/ogg/dirrpt: already exists.
Checkpoint file /u01/app/oracle/product/ogg/dirchk: already exists.
Process status files /u01/app/oracle/product/ogg/dirpcs: already exists.
SQL script files /u01/app/oracle/product/ogg/dirsql: already exists.
Database definitions files /u01/app/oracle/product/ogg/dirdef: already exists.
Extract data files /u01/app/oracle/product/ogg/dirdat: already exists.
Temporary files /u01/app/oracle/product/ogg/dirtmp: already exists.
Credential store files /u01/app/oracle/product/ogg/dircrd: already exists.
Masterkey wallet files /u01/app/oracle/product/ogg/dirwlt: already exists.
Dump files /u01/app/oracle/product/ogg/dirdmp: already exists.
8.Configure the Manager Port (xag130,xag131)
GGSCI (xag130) 2> status all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
GGSCI (xag130) 3> view PARAMS MGR
PORT 7809