#全篇分为4部分,1安装部分、2数据库配置部分、3ggs配置部分、4初始数据传输,启动同步部分
有问题可以留言 看到就回。
#1. Source Install GoldenGate.
#wget GoldenGate.
##use silent insall, config file:
#unzipdir/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp
[oracle@ggs_source ~]$ echo '
oracle.install.responseFileVersion=/oracle/install/rsoggmt_ogginstall_response_schema_v12_1_2
INSTALL_OPTION=ORA12c
SOFTWARE_LOCATION=/data/oracle/product/ogg_src
START_MANAGER=true
MANAGER_PORT=7809
DATABASE_LOCATION=/data/oracle/product/12.2.0/myproject
INVENTORY_LOCATION=
UNIX_GROUP_NAME=oinstall
' > /tmp/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp
[oracle@ggs_source ~]$ cd /tmp/fbo_ggs_Linux_x64_shiphome/Disk1/
[oracle@ggs_source ~]$ ./runInstaller -responseFile /tmp/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp -silent
2.Source database config
[oracle@ggs_source ~]$ sqlplus / as sysdba
SQL> show parameter name
NAME TYPE VALUE
----------------------------------------------------------------------------------------
cdb_cluster_name string ogg
cell_offloadgroup_name string
db_file_name_convert string
db_name string ogg
db_unique_name string ogg
global_names boolean FALSE
instance_name string myproject
lock_name_space string
log_file_name_convert string
pdb_file_name_convert string
processor_group_name string
service_names string ogg
SQL> exit
[oracle@ggs_source ~]$ echo '
ogg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ggs_source.ogg001.top)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ogg)
)
)
ogg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 106.42.178.23)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ogg)
)
)
' > /data/oracle/product/12.2.0/myproject/network/admin/tnsnames.ora
#创建用户并授予权限
[oracle@ggs_source ~]$ sqlplus / as sysdba
SQL> create tablespace ggs_data datafile '/data/ggsdata/ggs_data01.dbf' size 200m;
SQL> create temporary tablespace ggstemp temoggile '/data/ggsdata/ggstemp.dbf' SIZE 200M autoextend on next 10M maxsize 1000M;
SQL> create user ggs_test identified by ggs_test default tablespace ggs_data temporary tablespace ggstemp;
User created.
SQL> grant connect,resource to ggs_test;
Grant succeeded.
SQL> grant select any dictionary, select any table to ggs_test;
Grant succeeded.
SQL> grant create table to ggs_test;
Grant succeeded.
SQL> grant flashback any table to ggs_test;
Grant succeeded.
SQL> grant execute on dbms_flashback to ggs_test;
Grant succeeded.
SQL> grant execute on utl_file to ggs_test;
Grant succeeded.
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
Grant succeeded.
SQL> exec dbms_goldengate_auth.grant_admin_privilege('ggs_test');
Grant succeeded.
#Note:必须开启存档模式才能支持 Integrated Mode,否则extract进程启动时报错,内容如下
#vim /data/oracle/product/ogg_src/ggserror.log
#2018-12-01T13:14:47.336+0800 ERROR OGG-02057 Oracle GoldenGate Capture for Oracle, ext1.prm: The Oracle source database is not configured properly to support integrated capture.
#2018-12-01T13:14:47.336+0800 ERROR OGG-02055 Oracle GoldenGate Capture for Oracle, ext1.prm: ARCHIVELOG mode must be enabled on this Oracle database.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 444596224 bytes
Fixed Size 8621712 bytes
Variable Size 289407344 bytes
Database Buffers 142606336 bytes
Redo Buffers 3960832 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
#Configuring Logging Properties
#enable supplemental logging mode and in forced logging mode
SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;
SUPPLEMENTAL_LOG FORCE_LOGGING
----------------------------------------
NO NO
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL> ALTER DATABASE FORCE LOGGING;
SQL> SELECT supplemental_log_data_min, force_logging FROM v$database;
SUPPLEMENTAL_LOG FORCE_LOGGING
----------------------------------------
YES YES
#Switch the log files.
SQL> ALTER SYSTEM SWITCH LOGFILE;
#####################################################################################
SQL> alter database flashback on;
#if error should to do
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled.
解决方法:
1、通过oerr ora 38709查询,提示如下:
38709, 00000, "Recovery Area is not enabled."
// *Cause: An ALTER DATABASE FLASHBACK ON command failed because the
// Recovery Area was not enabled.
// *Action: Set DB_RECOVERY_FILE_DEST to a location and retry.
从提示很清楚的看出来,oracle是需要我们去设置DB_RECOVERY_FILE_DEST参数,这个代表FRA的存储路径
2、设置DB_RECOVERY_FILE_DEST这个参数前必须先设置DB_RECOVERY_FILE_DEST_SIZE,这个是FRA空间大小
3、设置这两个参数
SQL> alter system set db_recovery_file_dest_size=5G;
SQL> alter system set db_recovery_file_dest='/data/ggsdata/fras';
#有可能需要设置STREAMS_POOL_SIZE,空间设置计算公式如下
#Managing Server Resources
#In integrated mode, Extract interacts with an underlying logmining server in the source database and Replicat interacts with an inbound server in the target database. This section provides guidelines for managing the shared memory consumed by the these servers.
#The shared memory that is used by the servers comes from the Streams pool portion of the System Global Area (SGA) in the database. Therefore, you must set the database initialization parameter STREAMS_POOL_SIZE high enough to keep enough memory available for the number of Extract and Replicat processes that you expect to run in integrated mode. Note that Streams pool is also used by other components of the database (like Oracle Streams, Advanced Queuing, and Datapump export/import), so make certain to take them into account while sizing the Streams pool for Oracle GoldenGate.
#By default, one integrated capture Extract requests the logmining server to run with MAX_SGA_SIZE of 1GB and a PARALLELISM of 2. Thus, if you are running three Extracts in integrated capture mode in the same database instance, you need at least 3 GB of memory allocated to the Streams pool. As best practice, keep 25 percent of the Streams pool available. For example, if there are three Extracts in integrated capture mode, set STREAMS_POOL_SIZE to the following:
#3 GB + (3 GB * 0.25) = 3.75 GB
SQL> alter system set streams_pool_size=64m scope=both;
#####################################################################################
#enable Schema-level supplemental logging,此操作在创建完3.ggs_test之后#####################################################
SQL> exit
[oracle@ggs_source ~]$ cd /data/oracle/product/ogg_src/
[oracle@ggs_source ogg_src]$ ./ggsci
GGSCI (ggs_source.ogg001.top) 4> dblogin userid ggs_test,password ggs_test
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 11> ADD SCHEMATRANDATA test_schemas1 allcols
2018-12-01 15:49:26 INFO OGG-01788 SCHEMATRANDATA has been added on schema "test_schemas1".
2018-12-01 15:49:26 INFO OGG-01976 SCHEMATRANDATA for scheduling columns has been added on schema "test_schemas1".
2018-12-01 15:49:26 INFO OGG-01977 SCHEMATRANDATA for all columns has been added on schema "test_schemas1".
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 14> info schematrandata test_schemas1
2018-12-01 15:54:30 INFO OGG-06480 Schema level supplemental logging, excluding non-validated keys, is enabled on schema "test_schemas1".
2018-12-01 15:54:30 INFO OGG-01981 Schema level supplemental logging is enabled on schema "test_schemas1" for all columns.
2018-12-01 15:54:30 INFO OGG-10462 Schema "test_schemas1" have 30 prepared tables for instantiation.
#################################################################################
##############################################################################
#有时会出现数据库启动不成功,解决方法如下:
#SQL> startup
#ORA-00821: Specified value of sga_target 512M is too small, needs to be at least 700M
#SQL> create soggile from oggile;
#File created.
#SQL> startup
#ORA-00093: _shared_pool_reserved_min_alloc must be between 4000 and 0
#SQL> exit
#Disconnected
#[oracle@db ~]$ sqlplus / as sysdba
#SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 21 11:44:34 2017
#Copyright (c) 1982, 2013, Oracle. All rights reserved.
#Connected to an idle instance.
#SQL> startup
#ORACLE instance started.
#Total System Global Area 730714112 bytes
#Fixed Size 2256832 bytes
#Variable Size 629145664 bytes
#Database Buffers 92274688 bytes
#Redo Buffers 7036928 bytes
#Database mounted.
#Database opened.
######################################################################################
3.Source config ggs
[oracle@ggs_source ~]$ cd /data/oracle/product/ogg_src/
[oracle@ggs_source ogg_src]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 12.3.0.1.4 OGGCORE_12.3.0.1.0_PLATFORMS_180415.0359_FBO
Linux, x64, 64bit (optimized), Oracle 12c on Apr 16 2018 00:53:30
Operating system character set identified as US-ASCII.
Copyright (C) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
GGSCI (ggs_source.ogg001.top) 1>
##create login without password
#create credential store
GGSCI (ggs_source.ogg001.top) 2> add credentialstore
#add user to Credentialstore
GGSCI (ggs_source.ogg001.top) 3> alter credentialstore add user ggs_test password ggs_test alias ggs_test
#test whether could login by useridalias
GGSCI (ggs_source.ogg001.top) 4> dblogin useridalias ggs_test
Successfully logged into database.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 6> edit param mgr
#insert:
PORT 7809
DYNAMICPORTLIST 7810-7820
AUTOSTART ER *
AUTORESTART ER *, RETRIES 4, WAITMINUTES 4
STARTUPVALIDATIONDELAY 5
PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPHOURS 2
#:save
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 7> start mgr
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 8> edit param ext1
##insert:
EXTRACT ext1
USERIDALIAS ggs_test
SETENV (ORACLE_SID='myproject')
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
discardfile ./dirrpt/src.dsc, purge
exttrail ./dirdat/ogg/ex
DDL INCLUDE MAPPED
DDLOPTIONS REPORT
--TRANLOGOPTIONS INTEGRATEDPARAMS (MAX_SGA_SIZE 1024)
LOGALLSUPCOLS
UPDATERECORDFORMAT COMPACT
ENCRYPTTRAIL AES192
TABLE test_schemas1.*;
#save
#register extract process ext1
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 9> register extract ext1 database
2018-12-01 16:48:21 INFO OGG-02003 Extract EXT1 successfully registered with database at SCN 22597864.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 10> add extract ext1, integrated tranlog, begin now
EXTRACT (Integrated) added.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 11> ADD EXTTRAIL ./dirdat/ogg/ex, EXTRACT EXT1 megabytes 10
EXTTRAIL added.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 12> start ext1
Sending START request to MANAGER ...
EXTRACT EXT1 starting
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 13> edit param pump1
#insert:
EXTRACT pump1
useridalias ggs_test
NOPASSTHRU
RMTHOST 106.42.178.23, MGRPORT 7809, TCPBUFSIZE 1048576, TCoggLUSHBYTES 1048576
RMTTRAIL dirdat/trg/pu
DDL INCLUDE MAPPED
table test_schemas1.*;
--sequence test_schemas1.*;
REPORTCOUNT EVERY 15 MINUTES, RATE
#save
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 14> register extract pump1 database;
2018-12-01 17:00:14 INFO OGG-02003 Extract PUMP2 successfully registered with database at SCN 22621341.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 15> add extract pump1, EXTTRAILSOURCE dirdat/ogg/ex
EXTRACT added.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 16> add rmttrail dirdat/trg/pu, extract pump1, megabytes 10
RMTTRAIL added.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 17> start pump1
Sending STOP request to EXTRACT pump1 ...
Request processed.
################################################################若要删除extract 或者replicat进程
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 28> unregister extract ext1 database
2018-12-01 16:21:46 INFO OGG-01750 Successfully unregistered EXTRACT EXT1 from database.
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 30> delete extract ext1 database
Deleted EXTRACT EXT1.
##############################################################################################
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 12> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXT1 00:00:00 00:00:06
EXTRACT RUNNING PUMP1 00:00:00 00:00:07
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 13> stats ext1
Sending STATS request to EXTRACT EXT1 ...
No active extraction maps.
DDL replication statistics (for all trails):
*** Total statistics since extract started ***
Operations 0.00
Mapped operations 0.00
Unmapped operations 0.00
Other operations 0.00
Excluded operations 0.00
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 14> info extract ext1
EXTRACT EXT1 Last Started 2018-12-01 13:29 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:00 ago)
Process ID 18727
Log Read Checkpoint Oracle Integrated Redo Logs
2018-12-01 14:28:47
SCN 0.22573724 (22573724)
GGSCI (ggs_source.ogg001.top as ggs_test@myproject) 11> info extract ext1 detail
EXTRACT EXT1 Last Started 2018-12-01 13:29 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:05 ago)
Process ID 18727
Log Read Checkpoint Oracle Integrated Redo Logs
2018-12-01 14:28:16
SCN 0.22573653 (22573653)
Target Extract Trails:
Trail Name Seqno RBA Max MB Trail Type
./dirdat/ogg/ex 6 1468 10 EXTTRAIL
Integrated Extract outbound server first scn: 0.20944251 (20944251)
Integrated Extract outbound server filtering start scn: 0.20944251 (20944251)
Extract Source Begin End
Not Available 2018-11-27 15:40 2018-12-01 14:28
Not Available 2018-11-27 15:40 2018-12-01 13:10
Not Available 2018-11-27 15:40 2018-12-01 13:10
Not Available 2018-11-27 15:40 2018-12-01 13:10
Not Available 2018-11-27 15:40 2018-11-28 22:09
Not Available 2018-11-27 15:40 2018-11-28 22:09
Not Available 2018-11-27 15:40 2018-11-28 22:09
Not Available 2018-11-27 15:40 2018-11-27 17:00
Not Available 2018-11-27 15:40 2018-11-27 17:00
Not Available 2018-11-27 15:40 2018-11-27 17:00
Not Available 2018-11-27 15:40 2018-11-27 16:22
Not Available 2018-11-27 15:40 2018-11-27 16:22
Not Available 2018-11-27 15:40 2018-11-27 16:22
Not Available 2018-11-27 15:40 2018-11-27 15:48
Not Available 2018-11-27 15:40 2018-11-27 15:48
Not Available 2018-11-27 15:40 2018-11-27 15:48
Not Available 2018-11-27 15:40 2018-11-27 15:41
Not Available 2018-11-27 15:40 2018-11-27 15:41
Not Available 2018-11-27 15:40 2018-11-27 15:41
Not Available * Initialized * 2018-11-27 15:40
Not Available * Initialized * 2018-11-27 15:40
Not Available * Initialized * 2018-11-27 15:40
Current directory /data/oracle/product/ogg_src
Report file /data/oracle/product/ogg_src/dirrpt/EXT1.rpt
Parameter file /data/oracle/product/ogg_src/dirprm/ext1.prm
Checkpoint file /data/oracle/product/ogg_src/dirchk/EXT1.cpe
Process file /data/oracle/product/ogg_src/dirpcs/EXT1.pce
Error log /data/oracle/product/ogg_src/ggserr.log
#目标端目标端######################################################################################
1.Target Install GoldenGate.
#wget GoldenGate.
##use silent insall, config file:
#unzipdir/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp
[oracle@ggs_target ~]$ echo '
oracle.install.responseFileVersion=/oracle/install/rsoggmt_ogginstall_response_schema_v12_1_2
INSTALL_OPTION=ORA12c
SOFTWARE_LOCATION=/data/oracle/product/ogg_src
START_MANAGER=true
MANAGER_PORT=7809
DATABASE_LOCATION=/data/oracle/product/12.2.0/myproject
INVENTORY_LOCATION=
UNIX_GROUP_NAME=oinstall
' > /tmp/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp
[oracle@ggs_target ~]$ cd /tmp/fbo_ggs_Linux_x64_shiphome/Disk1/
[oracle@ggs_target ~]$ ./runInstaller -responseFile /tmp/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp -silent
2.Target database config
[oracle@ggs_target admin]$ echo '
ogg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ggs_target)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ogg)
)
)
ogg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 118.55.25.89)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ogg)
)
)
' > /data/oracle/product/12.2.0/myproject/network/admin/tnsnames.ora
#创建用户并授予权限
[oracle@ggs_source ~]$ sqlplus / as sysdba
SQL> create tablespace ggs_data datafile '/data/ggsdata/ggs_data01.dbf' size 200m;
SQL> create temporary tablespace ggstemp temoggile '/data/ggsdata/ggstemp.dbf' SIZE 200M autoextend on next 10M maxsize 1000M;
SQL> create user ggs_test identified by ggs_test default tablespace ggs_data temporary tablespace ggstemp;
User created.
SQL> grant connect,resource to ggs_test;
Grant succeeded.
SQL> grant select any dictionary, select any table to ggs_test;
Grant succeeded.
SQL> grant create table to ggs_test;
Grant succeeded.
SQL> grant flashback any table to ggs_test;
Grant succeeded.
SQL> grant execute on dbms_flashback to ggs_test;
Grant succeeded.
SQL> grant execute on utl_file to ggs_test;
Grant succeeded.
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
Grant succeeded.
SQL> exec dbms_goldengate_auth.grant_admin_privilege('ggs_test');
Grant succeeded.
#####################################################################################
SQL> alter database flashback on;
#if error should to do
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled.
解决方法:
1、通过oerr ora 38709查询,提示如下:
38709, 00000, "Recovery Area is not enabled."
// *Cause: An ALTER DATABASE FLASHBACK ON command failed because the
// Recovery Area was not enabled.
// *Action: Set DB_RECOVERY_FILE_DEST to a location and retry.
从提示很清楚的看出来,oracle是需要我们去设置DB_RECOVERY_FILE_DEST参数,这个代表FRA的存储路径
2、设置DB_RECOVERY_FILE_DEST这个参数前必须先设置DB_RECOVERY_FILE_DEST_SIZE,这个是FRA空间大小
3、设置这两个参数
SQL> alter system set db_recovery_file_dest_size=5G;
SQL> alter system set db_recovery_file_dest='/data/ggsdata/fras';
#有可能需要设置STREAMS_POOL_SIZE,空间设置计算公式如下
#Managing Server Resources
#In integrated mode, Extract interacts with an underlying logmining server in the source database and Replicat interacts with an inbound server in the target database. This section provides guidelines for managing the shared memory consumed by the these servers.
#The shared memory that is used by the servers comes from the Streams pool portion of the System Global Area (SGA) in the database. Therefore, you must set the database initialization parameter STREAMS_POOL_SIZE high enough to keep enough memory available for the number of Extract and Replicat processes that you expect to run in integrated mode. Note that Streams pool is also used by other components of the database (like Oracle Streams, Advanced Queuing, and Datapump export/import), so make certain to take them into account while sizing the Streams pool for Oracle GoldenGate.
#By default, one integrated capture Extract requests the logmining server to run with MAX_SGA_SIZE of 1GB and a PARALLELISM of 2. Thus, if you are running three Extracts in integrated capture mode in the same database instance, you need at least 3 GB of memory allocated to the Streams pool. As best practice, keep 25 percent of the Streams pool available. For example, if there are three Extracts in integrated capture mode, set STREAMS_POOL_SIZE to the following:
#3 GB + (3 GB * 0.25) = 3.75 GB
SQL> alter system set streams_pool_size=64m scope=both;
##############################################################################
#有时会出现数据库启动不成功,解决方法如下:
#SQL> startup
#ORA-00821: Specified value of sga_target 512M is too small, needs to be at least 700M
#SQL> create soggile from oggile;
#File created.
#SQL> startup
#ORA-00093: _shared_pool_reserved_min_alloc must be between 4000 and 0
#SQL> exit
#Disconnected
#[oracle@db ~]$ sqlplus / as sysdba
#SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 21 11:44:34 2017
#Copyright (c) 1982, 2013, Oracle. All rights reserved.
#Connected to an idle instance.
#SQL> startup
#ORACLE instance started.
#Total System Global Area 730714112 bytes
#Fixed Size 2256832 bytes
#Variable Size 629145664 bytes
#Database Buffers 92274688 bytes
#Redo Buffers 7036928 bytes
#Database mounted.
#Database opened.
######################################################################################
3.Target config ggs
[oracle@ggs_target ~]$ cd /data/oracle/product/ogg_trg/
[oracle@ggs_target ogg_trg]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 12.3.0.1.4 OGGCORE_12.3.0.1.0_PLATFORMS_180415.0359_FBO
Linux, x64, 64bit (optimized), Oracle 12c on Apr 16 2018 00:53:30
Operating system character set identified as UTF-8.
Copyright (C) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
#create login without password
#create credential store
GGSCI (ggs_target) 1> add credentialstore
#add user to Credentialstore
GGSCI (ggs_target) 2> alter credentialstore add user ggs_test password ggs_test alias ggs_test
#test whether could login by useridalias
GGSCI (ggs_target) 8> dblogin useridalias ggs_test
Successfully logged into database.
GGSCI (ggs_target as ggs_test@myproject) 11>edit param mgr
#insert
PORT 7809
ACCESSRULE, PROG *, IPADDR 172.18.29.25, ALLOW
DYNAMICPORTLIST 7810-7820
AUTOSTART ER *
AUTORESTART ER *, RETRIES 4, WAITMINUTES 4
STARTUPVALIDATIONDELAY 5
PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPHOURS 2
#save
GGSCI (ggs_target as ggs_test@myproject) 11>edit param rep1
#insert
REPLICAT rep1
USERIDALIAS ggs_test
SETENV (ORACLE_SID='myproject')
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
HANDLECOLLISIONS
DBOPTIONS SUPPRESSTRIGGERS
ASSUMETARGETDEFS
DISCARDFILE ./dirrpt/trg.dsc, purge
DDL INCLUDE MAPPED
DDLOPTIONS REPORT
DBOPTIONS INTEGRATEDPARAMS(parallelism 4)
REPORTCOUNT EVERY 30 MINUTES, RATE
--TRANLOGOPTIONS
--FETCHPARTIALLOB
MAP test_schemas1.*, TARGET test_schemas1.*;
#save
GGSCI (ggs_target as ggs_test@myproject) 11> register replicat rep1 database
2018-11-20 19:18:12 INFO OGG-02528 REPLICAT RTRG12C successfully registered with database as inbound server OGG$RTRG12C.
GGSCI (ggs_target as ggs_test@myproject) 14> add replicat rep1, integrated, exttrail ./dirdat/trg/pu
REPLICAT (Integrated) added.
#mgr rep1 not time to start until now
4初始数据传输,启动同步部分
#Source database
#[oracle@ggs_target ogg_trg]$ sqlplus / as sysdba
#SQL> col current_scn format 999999999999
#SQL> select current_scn from v$database;
#CURRENT_SCN
#-----------
# 21101825
SQL> create directory ggs_dir as '/data/ggsdata';
SQL> exit
#[oracle@ggs_source ~]$ expdp ggs_test/ggs_test directory=ggs_dir parallel=4 dumoggile=gg_src_%U.dmp \ flashback_scn=21101825 schemas=test_schemas1
[oracle@ggs_source ~]$ expdp system/oracle directory=ggs_dir dumoggile=myproject.dmp schemas=test_schemas1,test_schemas2
##############################################################################
#if error:
#UDI-31623: operation generated ORACLE error 31623
#ORA-31623: a job is not attached to this session via the specified handle
#ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
#解决方法:
#https://www.jianshu.com/p/4c238263b851
alter system set streams_pool_size=100m scope=both;
#the parameter streams_pool_size size can reference 3.5: https://docs.oracle.com/goldengate/1212/gg-winux/GIORA/setup.htm#GIORA234
##################################################################################
#ORA-31631: privileges are required
#ORA-39122: Unprivileged users may not perform REMAP_SCHEMA remappings.
#SQL> grant imp_full_database to ggs_test;
#Grant succeeded.
#SQL> grant read,write on directory gg_dir to ggs_test;
########################################################################
#Target database
[oracle@ggs_target ~]$ scp [email protected]:/data/ggsdata/myproject.dmp /data/ggsdata/
#[oracle@ggs_target ~]$ impdp ggs_test/ggs_test directory=ggs_dir parallel=4 dumoggile=gg_src_%U.dmp schemas=test_schemas1
[oracle@ggs_target ~]$ impdp system/oracle directory=ggs_dir dumoggile=myproject.dmp schemas=test_schemas1,admin
[oracle@ggs_target ~]$ cd /data/oracle/product/ogg_trg/
[oracle@ggs_target ~]$ ./ggsci
#Note:source and target initial csn number must equel
#GGSCI (ggs_target as ggs_test@myproject) 15> start replicat rep1, aftercsn 21101825
GGSCI (ggs_target as ggs_test@myproject) 15> start replicat rep1