http://www.dataguru.cn/thread-171156-1-1.html
Several important processes of GoldenGate are introduced:
1. The Manager management process starts at both ends, monitors and restarts other processes; allocates data storage and reports errors and events;
2. The Extract process grabs and transmits transaction data from the log to the target side;
3. The Server Collector process accepts data at the target (accepting) end and writes it to the trail file;
4. The Replicat process reads the trail file and applies it to the target database;
5. When the trail file is the file that gg captures information by itself, it is an OS file, stored in ./dirdat/, named after X00000, N sequence 1, 2, 3... This file is automatically deleted when the configurable parameters are used up.
question:
1. The database is set to archive mode
2. Pay special attention to the relationship between the extraction process, the delivery process, and the receiving process
The extraction process definition file path is the local path of the delivery process add extract pump_so,exttrailsource ./dirdat/et/dd
The extraction process defines the remote file path as the accepting process path add replicat rep7,exttrail ./dirdat/dp1/sd
1. Environment preparation and installation of GoldenGate
1. Database preparation
1) Origin server
IP address: 192.168.14.150
Database: 10.2.0.5 64 bit
SID: orcl
OS version: Oracle 5.4 64 bit
Database: 10.2.0.5 64 bit
SID: slave
OS version: Oracle 5.4 64 bit
2. Download the OGG software and extract it to install
1) Origin server
mkdir -p /u01/app/oracle/ogg
unzip fbo_ggs_Linux_x64_ora10g_64bit.zip
tar -xvf fbo_ggs_Linux_x64_ora10g_64bit.tar -C /u01/app/oracle/ogg/
chown -R oracleinstall /u01/app/oracle/ogg
2) The target server must be configured
mkdir -p /u01/app/oracle/ogg
unzip fbo_ggs_Linux_x64_ora10g_64bit.zip
tar -xvf fbo_ggs_Linux_x64_ora10g_64bit.tar -C /u01/app/oracle/ogg/
chown -R oracle:oinstall /u01/app/oracle/ogg
3. Prepare OGG environment variables
#The source server, and the target server must be configured
$ vi /home/oracle/.bash_profile
Add the following line:
export GGATE=$ORACLE_BASE/ogg
Effective environment variable
source /home/oracle/.bash_profile
4. Configure log mode
# The source server, the target server does not need to be configured (non-bidirectional)
1) View profiles and log mode
select log_mode,supplemental_log_data_min,force_logging from v$database;
2) Configure as profile mode
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
alter system set log_archive_dest_1='location=/u01/archive' scope=both;
3) Configure log mode (enable mandatory profile and supplementary log mode)
alter database add supplemental log data;
alter database force logging;
4) View the configuration result:
SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;
LOG_MODE SUPPLEME FOR
------------ -------- ---
ARCHIVELOG YES YES
5. Create a GoldenGate user account
1) Origin server
conn / as sysdba;
create tablespace tbs_ogg datafile '/u01/app/oracle/oradata/target/tbs_ogg.dbf' size 10m autoextend on next 10m;
create user ogg identified by ogg default tablespace tbs_ogg temporary tablespace TEMP quota unlimited on tbs_ogg;
grant connect,resource to ogg;
grant create session,alter session 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;
2) target server
conn / as sysdba;
create tablespace tbs_ogg datafile '/u01/app/oracle/oradata/orcl/tbs_ogg.dbf' size 10m autoextend on next 10m;
create user ogg identified by ogg default tablespace tbs_ogg temporary tablespace TEMP quota unlimited on tbs_ogg;
grant connect,resource to ogg;
grant create session,alter session 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 delete any table to ogg;
grant update any table to ogg;
6. Install GoldenGate software
(1) Both the source server and the target server must be configured
./ggsci
GGSCI (test) 1> create subdirs
Parameter files /u01/app/oracle/ogg/dirprm: created
Report files /u01/app/oracle/ogg/dirrpt: created
Checkpoint files /u01/app/oracle/ogg/dirchk: created
Process status files /u01/app/oracle/ogg/dirpcs: created
SQL script files /u01/app/oracle/ogg/dirsql: created
Database definitions files /u01/app/oracle/ogg/dirdef: created
Extract data files /u01/app/oracle/ogg/dirdat: created
Temporary files /u01/app/oracle/ogg/dirtmp: created
Veridata files /u01/app/oracle/ogg/dirver: created
(2) The target server must be configured
./ggsci
GGSCI (slave) 1> create subdirs
Creating subdirectories under current directory /u01/app/oracle/ogg
Parameter files /u01/app/oracle/ogg/dirprm: created
Report files /u01/app/oracle/ogg/dirrpt: created
Checkpoint files /u01/app/oracle/ogg/dirchk: created
Process status files /u01/app/oracle/ogg/dirpcs: created
SQL script files /u01/app/oracle/ogg/dirsql: created
Database definitions files /u01/app/oracle/ogg/dirdef: created
Extract data files /u01/app/oracle/ogg/dirdat: created
Temporary files /u01/app/oracle/ogg/dirtmp: created
Veridata files /u01/app/oracle/ogg/dirver: created
7. Configure the source and target databases to be consistent
There are many ways to configure the consistency of source and target data, and it can be done in the way of oracle. This method adopts the imp method to achieve the consistency of the initial data table.
(1) Source test users:
create user hr identified by hr;
grant connect,resource,select_catalog_role to hr;
conn hr/hr;
create table t1 as select * from dba_objects;
alter table t1 add constraint prikey_t1 primary key(object_id);
(2) Target test user:
The target server is imported through exp/imp, and only the table structure is imported
create user hr identified by hr;
grant connect,resource,select_catalog_role to hr;
conn hr/hr;
imp hr/hr file=hr.dmp rows=n
Note: Data synchronization can also be achieved by initializing data loading through goldengate
2. GoldenGate DML synchronization source configuration
Configuration ideas:
1) First configure DML synchronization
2) Reconfigure DDL synchronization
./ggsci
1. Source MGR process and start it
1) Edit the main process group
PORT 7809
DYNAMICPORTLIST 7800-7900
AUTORESTART EXTRACT *,RETRIES 3, WAITMINUTES 5, RESETMINUTES 60
PURGEOLDEXTRACTS ./dirdat/*/*, USECHECKPOINTS, MINKEEPFILES 100
LAGREPORTMINUTES 1
LAGINFOMINUTES 1
LAGCRITICALMINUTES 1
illustrate:
port specifies the communication port of the mgr process
dynamicportlist indicates that the mgr process can specify ports for dynamic communication between source and destination
autorestart extract means to automatically restart the extract process group, try to restart all processes every 2 minutes, retry 5 times, and clear it every 5 minutes.
After configuring the parameters, restart the mgr process to take effect
2) Start the main management process
start mgr
2. Configure the Extract process group
1) Edit the configuration file
edit params eora
eora extract
dynamicresolution
SETENV (ORACLE_HOME="/u01/app/oracle/product/11.2.0/db_1")
SETENV (ORACLE_SID="source")
SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
UsERID ogg password ogg
exttrail ./dirdat/et/dd------------ This path is closely related to the pump process
ddl include all
ddloptions addtrandata, report
table hr.*;
2) Add extraction process
add extract eora, tranlog,begin now
3) Add a local trail file
ADD EXTTRAIL ./dirdat/et/dd (this path is closely related to the pump process) EXTRACT eora, MEGABYTES 5
Description: Create a local trail file, the main extract process is responsible for writing this part of the file, and pump is responsible for transferring this part of the file to the target server.
4) Start the service
start extract eora
3. Configure the Pump process group
1) Edit the configuration file
edit params pump_so
EXTRACT pump_so
PASSTHRU
DYNAMICRESOLUTION
RMTHOST 192.168.31.14 ,MGRPORT 7809
RMTTRAIL ./dirdat/dp1/sd
DISCARDFILE ./dirrpt/dp2.dsc,APPEND,MEGABYTES 5
DISCARDROLLOVER AT 6:00
REPORTROLLOVER AT 6:00
REPORTCOUNT EVERY 1 HOURS,RATE
table hr.*;
2) Add the pump process and specify the local file
add extract pump_so,exttrailsource ./dirdat/et/dd (pay special attention to the location of the extraction process file queue)
3) Add remote trail file
add RMTTRAIL ./dirdat/dp1/sd (pay special attention to the location of the parameter file rmttrail), EXTRACT PUMP_SO, MEGABYTES 5
Description: Specifies the remote trail file
4) Start the pump process
start extract pump_so
3. GoldenGate DML synchronization target configuration
1. Target MGR process
1) Edit the configuration file
edit params mgr
port 7809
dynamicportlist 7800-8000
autostart he *
autorestart extract *, waitminutes 2, resetminutes 5
lagreporthours 1
laginfominutes 3
lagcriticalminutes 5
purgeoldextracts /u01/app/oracle/ogg/dirdat/rt*, usecheckpoints, minkeepdays 3
2) Start
start mgr
2. Add a checklist
Note: When we specify the default checkpoint in the GLOBALS file, new Replicat groups will automatically use this parameter when they are created, and no other instructions are required.
1) Edit the global configuration file
edit params ./GLOBALS
Successfully logged into database.
GGSCI (slave) 2> add checkpointtable ogg.checkpoint
Successfully created checkpoint table OGG.CHECKPOINT.
Configure the target Peplicat process group
1) Edit the configuration file
edit params repl
REPLICATED rep1
SETENV (ORACLE_HOME = "/u01/app/oracle/product/11.2.0/db_1" )
SETENV (ORACLE_SID = "target")
SETENV (NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK")
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE ./dirrpt/rep1.dsc ,append ,megabytes 5
--SOURCEDEFS ./dirdef/def.def
DDL INCLUDE MAPPED , OBJTYPE 'TABLE' &
INCLUDE MAPPED OBJTYPE 'INDEX'
MAP hr.T1 ,TARGET hr.T1;
2) Add replication process
add replicat rep7,exttrail ./dirdat/dp1/sd (the path is the remote path defined by the pump process)
3) Start the process
start repl
4. You can view the checkpoint status
su - oracle
sqlplus ogg/ogg
SQL> select tname from tab;
TNAME
-------------------------------------
CHECKPOINT TABLE
CHECKPOINT_LOX TABLE
select * from checkpoint;
Note 1: ogg_11.1.1.1.2 only has one table of CHECKPOINT.
Note 2: ogg_11.2.xx1 has two tables: CHECKPOINT and CHECKPOINT_LOX.
5. DML configuration test
1) The number of records in the source view table
conn hr/hr
SQL> select count(*) from t1;
2) Submit after performing DML operation
SQL> delete from t1 where rownum < 200;
SQL> select count(*) from t1;
3) Target view
conn hr/hr
SQL> select count(*) from t1;
illustrate:
At this point, the goldengate DML one-way configuration has been configured, and it is carried out through a simple test example.
3) Install DDL objects
SQL> grant dba to ogg;
SQL> @marker_setup Description: Both specify user ogg
SQL> @ddl_setup Description: 11.1.1.2 need to manually input ogg, INITIALSETUP, yes
SQL> @role_setup
SQL> grant GGS_GGSUSER_ROLE to ogg;
SQL> @ddl_enable
SQL> @marker_status.sql
SQL> @?/rdbms/admin/dbmspool.sql
Note 1: Executing the dbmspool package will create the DBMS_SHARED_POOL package in the database, after which the ddl_pin package needs to be used
Note 2: Execute ddl_pin.sql to keep DDLReplication related objects in the shared pool through the dbms_shared_pool.keep stored procedure to ensure that these objects do not need to be RELOADed and improve performance.
SQL> @ddl_pin.sql ogg
2. Modify the params file of the extract process
# Server source configuration
# The source side modifies the params file of the extract process, adds the "ddl include all" parameter, and restarts the extract process
1) Stop the eora_t1 process
GGSCI (test) 2> stop extract eora
2) Edit the configuration file
GGSCI (test) 3> edit params eora
eora extract
dynamicresolution
setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
userid ogg,password ogg
exttrail /u01/app/oracle/ogg/dirdat/et
ddl include all
ddloptions addtrandata, report
table hr.*;
# Description: Added two lines of tranlogoption and ddl
3) Start mgr, eora process
GGSCI (test) 4> start mgr
GGSCI (test) 5> start extract eora
4) View the eora_t1 process startup status
GGSCI (test) 6> info extract eora
3. Modify the params file of the target replicat process
# target server configuration
# The target side modifies the params file of the replicat process,
Add "ddlerror default ignore retryop maxretries 3 retrydelay 5" and other parameters to restart the replicat process
1) Stop the mgr process
GGSCI (slave) 1> stop mgr
2) Stop the repl process
GGSCI (slave) 1> stop replicat repl
3) Edit the repl configuration file
GGSCI (slave) 1> edit params repl
GGSCI (slave) 2> view params repl
replicat repl
userid ogg, password ogg
assumetargetdefs
reperror default, discard
discardfile /u01/app/oracle/ogg/dirrpt/repl.dsc, append, megabytes 50
dynamicresolution
ddloptions report
ddlerror default ignore retryop maxretries 3 retrydelay 5
ddlerror default discard
ddlerror default ignore retryop
map hr.*, target hr.*;
Note: It means that the target end does not need to configure the DDL include all statement, otherwise, an error will occur.
##Error text [Error code [1031], ORA-01031: insufficient privileges
4) Start the rora_t1 process
GGSCI (slave) 5> info replicat repl
4. Test
Create a table for the hr user on the source end and check whether the target end is successfully created.
create table abc ( id integer , name char(10));
insert into abc values ( 1 , 'abc' );