Tag站长知识库:分享、传递知识使我们更快乐,更幸福,更和谐!

最近更新热门图文热门文章全站推荐Tag标签网站地图
您现在的位置:首页 > 数据库 > Mysql数据库>>Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化

Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化

2019-06-17 17:21作者:佚名来源:CSDN浏览:43 评论:43

1.环境介绍

类别源端目标端数据库类型单实例单实例数据库版本11.2.0.411.2.0.4Oracle_SIDcndbacndbaDB_NAMEcndbacndba主机IP地址192.168.1.85192.168.1.86OS版本RedHat 6.7RedHat 6.7OGG版本11.2.1.0.1 64位11.2.1.0.1 64位主机名cndbacndba

2.安装前的准备工作

2.1.源端创建GoldenGate用户表空间

create tablespace ogg_data datafile '/u01/app/oracle/oradata/cndba/ogg01.dbf' size 100m autoextend off;

2.2.源端创建GoldenGate用户

create user ogg identified by ogg default tablespace ogg_data;grant connect,resource,dba,create table,create sequence to ogg;

2.3.目标端创建GoldenGate用户表空间

create tablespace ogg_data datafile '/u01/app/oracle/oradata/cndba/ogg01.dbf' size 100m autoextend off;

2.4.目标端创建GoldenGate用户表空间

create user ogg identified by ogg default tablespace ogg_data;grant connect,resource,dba,create table,create sequence to ogg;

2.5.源端创建测试用户及测试数据

SQL> create user test identified by test;User created.SQL> grant connect,resource to test;Grant succeeded.SQL> conn test/test                   Connected.SQL> create table test (id number(10) primary key ,name varchar(8));Table created.SQL> insert into test values(1,'zhangsan');1 row created.SQL> insert into test values(2,'lisi');1 row created.SQL> commit;

2.6.目标端创建测试用户及测试数据

SQL> create user test identified by test;User created.SQL> grant connect,resource to test;Grant succeeded.SQL> conn test/test                   Connected.SQL> create table test (id number(10) primary key ,name varchar(8));Table created.目标端不需要插入数据

2.7.源端开启归档模式、强制日志、附加日志

2.7.1.查看是否开启归档模式、强制日志、附加日志

SQL> select LOG_MODE, SUPPLEMENTAL_LOG_DATA_MIN,FORCE_LOGGING from v$database;LOG_MODE     SUPPLEME FOR------------ -------- ---NOARCHIVELOG NO       NO

2.7.2.开启归档

[root@www.cndba.cn cndba]# mkdir -p /u01/archive[root@www.cndba.cn cndba]# chown -R oracle:oinstall /u01/archive/SQL> archive log listDatabase log mode       No Archive ModeAutomatic archival       DisabledArchive destination       /u01/app/oracle/product/11.2.0/db_1/dbs/archOldest online log sequence     5Current log sequence       7SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startup mountORACLE instance started.Total System Global Area 1060585472 bytesFixed Size    2260000 bytesVariable Size  905970656 bytesDatabase Buffers  146800640 bytesRedo Buffers    5554176 bytesDatabase mounted.SQL> alter database archivelog;Database altered.SQL> alter database open;Database altered.SQL> alter system set log_archive_dest_1='location=/u01/archive';System altered.SQL> archive log lisetSP2-0718: illegal ARCHIVE LOG optionSQL> archive log listDatabase log mode       Archive ModeAutomatic archival       EnabledArchive destination       /u01/archiveOldest online log sequence     5Next log sequence to archive   7Current log sequence       7

2.7.3.开启强制日志

SQL> alter database force logging; Database altered.

2.7.4.开启附加日志

SQL> alter database add supplemental log data; Database altered.

2.7.5.查看是否开启归档模式、强制日志、附加日志

SQL> select LOG_MODE, SUPPLEMENTAL_LOG_DATA_MIN,FORCE_LOGGING from v$database;LOG_MODE     SUPPLEME FOR------------        --------    ---ARCHIVELOG     YES      YES

2.7.6.查看回收站是否关闭

SQL> show parameter recycleNAME     TYPE VALUE------------------------------------ ----------- ------------------------------buffer_pool_recycle     stringdb_recycle_cache_size     big integer 0recyclebin     string onSQL> alter system set recyclebin=off scope=spfile; System altered.--重启数据库查看SQL> show parameter recycleNAME     TYPE VALUE------------------------------------ ----------- ------------------------------buffer_pool_recycle     stringdb_recycle_cache_size     big integer 0recyclebin     string OFF

3.GoldenGate安装

3.1.源端安装OGG

3.1.1.创建软件安装目录并赋权

[root@www.cndba.cn software]# mkdir -p /u01/app/oracle/ogg[root@www.cndba.cn software]# chown -R oracle:oinstall /u01/app/oracle/ogg

3.1.2.配置oracle用户环境变量

[oracle@www.cndba.cn ~]$ vi .bash_profile设置Library 路径假设OGG的安装目录是/u01/app/oracle/ogg,那么在/home/oracle/.bash_profile文件里添加如下内容:export OGG_HOME=$ORACLE_BASE/oggexport PATH=$ORACLE_HOME/bin:$PATH:$OGG_HOMEexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:$OGG_HOME:/lib:/usr/lib--source 使修改生效:[oracle@www.cndba.cn ~]$ source .bash_profile

3.1.3.解压ogg文件

[root@www.cndba.cn software]# cd /software/[root@www.cndba.cn software]# unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip[root@www.cndba.cn software]# tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar -C /u01/app/oracle/ogg[root@www.cndba.cn ogg]# chown -R oracle:oinstall /u01/app/oracle/ogg注意:/u01/app/oracle/ogg 是$OGG_HOME

3.1.4.运行ogg并创建目录

[oracle@www.cndba.cn ~]$ cd $OGG_HOME[oracle@www.cndba.cn ogg]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBOLinux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (cndba) 1> create subdirsCreating subdirectories under current directory /u01/app/oracle/oggParameter files                /u01/app/oracle/ogg/dirprm: already existsReport files                   /u01/app/oracle/ogg/dirrpt: createdCheckpoint files               /u01/app/oracle/ogg/dirchk: createdProcess status files           /u01/app/oracle/ogg/dirpcs: createdSQL script files               /u01/app/oracle/ogg/dirsql: createdDatabase definitions files     /u01/app/oracle/ogg/dirdef: createdExtract data files             /u01/app/oracle/ogg/dirdat: createdTemporary files                /u01/app/oracle/ogg/dirtmp: createdStdout files                   /u01/app/oracle/ogg/dirout: created

3.2.目标端安装OGG

3.2.1.创建软件安装目录并赋权

[root@www.cndba.cn software]# mkdir -p /u01/app/oracle/ogg[root@www.cndba.cn software]# chown -R oracle:oinstall /u01/app/oracle/ogg

3.2.2.配置oracle用户环境变量

[oracle@www.cndba.cn ~]$ vi .bash_profile设置Library 路径假设OGG的安装目录是/u01/app/oracle/ogg,那么在/home/oracle/.bash_profile文件里添加如下内容:export OGG_HOME=$ORACLE_BASE/oggexport PATH=$ORACLE_HOME/bin:$PATH:$OGG_HOMEexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:$OGG_HOME:/lib:/usr/lib--source 使修改生效:[oracle@www.cndba.cn ~]$ source .bash_profile

3.2.3.解压ogg文件

[root@www.cndba.cn software]# cd /software/[root@www.cndba.cn software]# unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip[root@www.cndba.cn software]# tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar -C /u01/app/oracle/ogg[root@www.cndba.cn ogg]# chown -R oracle:oinstall /u01/app/oracle/ogg注意:/u01/app/oracle/ogg 是$OGG_HOME

3.2.4.运行ogg并创建目录

[oracle@www.cndba.cn ~]$ cd $OGG_HOME[oracle@www.cndba.cn ogg]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBOLinux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (cndba) 1> create subdirsCreating subdirectories under current directory /u01/app/oracle/oggParameter files                /u01/app/oracle/ogg/dirprm: already existsReport files                   /u01/app/oracle/ogg/dirrpt: createdCheckpoint files               /u01/app/oracle/ogg/dirchk: createdProcess status files           /u01/app/oracle/ogg/dirpcs: createdSQL script files               /u01/app/oracle/ogg/dirsql: createdDatabase definitions files     /u01/app/oracle/ogg/dirdef: createdExtract data files             /u01/app/oracle/ogg/dirdat: createdTemporary files                /u01/app/oracle/ogg/dirtmp: createdStdout files                   /u01/app/oracle/ogg/dirout: created

4.GoldenGate配置

4.1.OGG源端配置

4.1.1.配置mgr进程

GGSCI (cndba) 3> edit params mgrGGSCI (cndba) 4> view params mgrport 7809GGSCI (cndba) 5> start mgrManager started.GGSCI (cndba) 6> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           GGSCI (cndba) 7> sh netstat -ntpl |grep 7809  --查看7809端口是否启用(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)tcp        0      0 :::7809                     :::*                        LISTEN      14176/./mgr         GGSCI (cndba) 8>  sh ps -ef|grep mgr  --查看mgr进程是否存在root        14     2  0 13:24 ?        00:00:00 [async/mgr]postfix   1867  1860  0 13:26 ?        00:00:00 qmgr -l -t fifo -uoracle   14176 14114  0 15:43 ?        00:00:00 ./mgr PARAMFILE /u01/app/oracle/ogg/dirprm/mgr.poracle   14185 14114  0 15:44 pts/0    00:00:00 sh -c ps -ef|grep mgroracle   14187 14185  0 15:44 pts/0    00:00:00 grep mgr

4.1.2.添加表级transdata

GGSCI (cndba) 10> dblogin userid ogg,password oggSuccessfully logged into database.查看是否开启GGSCI (cndba) 11>  info trandata test.testGGSCI (cndba) 11>  add trandata test.*Logging of supplemental redo data enabled for table TEST.TEST.注意:为了方便这里直接添加整个用户下表级transdata,如果只是同步部分表的,请批量执行add trandata test.tablename

4.1.3.配置extract抽取进程

GGSCI (cndba) 13>  dblogin userid ogg,password oggSuccessfully logged into database.GGSCI (cndba) 14> add extract ext1, tranlog, begin now, threads 1EXTRACT added.GGSCI (cndba) 15> add exttrail ./dirdat/et, extract ext1EXTTRAIL added.GGSCI (cndba) 16>  edit params ext1GGSCI (cndba) 17> view params ext1EXTRACT ext1SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK") --此处数据库字符集设为一致--SETENV (ORACLE_SID = "cndba")SETENV (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)USERID ogg, PASSWORD oggTHREADOPTIONS MAXCOMMITPROPAGATIONDELAY 20000EXTTRAIL ./dirdat/etDYNAMICRESOLUTION--DDL INCLUDE ALLTABLE test.*;

4.1.4.配置pump传输进程

GGSCI (cndba) 18> add extract pump1,exttrailsource ./dirdat/et,begin nowEXTRACT added.GGSCI (cndba) 19> add rmttrail ./dirdat/et,extract pump1RMTTRAIL added.GGSCI (cndba) 20> edit params pump1GGSCI (cndba) 21> view params pump1EXTRACT pump1RMTHOST 192.168.1.86, MGRPORT 7809RMTTRAIL ./dirdat/etPASSTHRUDYNAMICRESOLUTIONTABLE test.*;GGSCI (cndba) 22> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           EXTRACT     STOPPED     EXT1        00:00:00      00:18:00    EXTRACT     STOPPED     PUMP1       00:00:00      00:04:07

4.2.OGG目标端配置

4.2.1.配置mgr进程

GGSCI (cndba) 3> edit params mgrGGSCI (cndba) 4> view params mgrport 7809GGSCI (cndba) 5> start mgrManager started.GGSCI (cndba) 6> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           GGSCI (cndba) 7> sh netstat -ntpl |grep 7809  --查看7809端口是否启用(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)tcp        0      0 :::7809                     :::*                        LISTEN      14176/./mgr         GGSCI (cndba) 8>  sh ps -ef|grep mgr  --查看mgr进程是否存在root        14     2  0 13:24 ?        00:00:00 [async/mgr]postfix   1867  1860  0 13:26 ?        00:00:00 qmgr -l -t fifo -uoracle   14176 14114  0 15:43 ?        00:00:00 ./mgr PARAMFILE /u01/app/oracle/ogg/dirprm/mgr.poracle   14185 14114  0 15:44 pts/0    00:00:00 sh -c ps -ef|grep mgroracle   14187 14185  0 15:44 pts/0    00:00:00 grep mgr

5.初始化数据-RMAN

5.1.启动生产端和容灾端的管理进程

--源端[oracle@www.cndba.cn ogg]$ cd /u01/app/oracle/ogg[oracle@www.cndba.cn ogg]$ ./ggsciGGSCI (cndba) 1> start mgrManager started.GGSCI (cndba) 1> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           EXTRACT     STOPPED     EXT1        00:00:00      00:40:35    EXTRACT     STOPPED     PUMP1       00:00:00      00:26:42--目标端[oracle@host1 ~]$ cd /u01/app/oracle/ogg[oracle@host1 ogg]$ ./ggsciGGSCI (host1) 1> start mgrManager started.GGSCI (cndba) 14> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING

5.2.启动源端的EXTRACT进程

GGSCI (cndba) 2> start ext1Sending START request to MANAGER ...EXTRACT EXT1 startingGGSCI (cndba) 4> start pump1Sending START request to MANAGER ...EXTRACT PUMP1 startingGGSCI (cndba) 5> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           EXTRACT     RUNNING     EXT1        00:00:00      00:00:03    EXTRACT     RUNNING     PUMP1       00:00:00      00:28:57

5.3.查看数据库中所有事务的开始时间

查看数据库中所有事务的开始时间,直到其大于抽取进程的启动时间再开始备份数据库,因为GoldenGate 的只获取在Extract 启动以后的交易变化,在Extract 启动之前开始而在Extract 启动以后才完成的交易GoldenGate 将会忽略这些交易,这些被忽略的交易数据就会丢失。所以需要等数据库中所以的交易都在Extract 启动之后开始的才能开始备份数据库。通过v$transaction 视图来查看数据库中的交易:select min(start_time) from  v$transaction;这里是测试环境没有事物,可以进行后面的备份了。

5.4.RMAN 备份源端数据库

当所有在Extract 启动之前的开始的交易都完成后,我们就可以使用RMAN 备份生产
端的数据库了。备份数据库的过程中一定要密切监控Extract 进程的状态,保证其一
直正常运行:

 

5.4.1.源端使用RMAN备份全库

注意:备份过程保证抽取进程状态一直正常。--备份归档和控制文件如果有三个日志文件组,可以按照以下方式进行切换,如果更多,则对应增加切换的次数即可)--备份数据库run {allocate channel ch00 type disk maxpiecesize 10g;allocate channel ch01 type disk maxpiecesize 10g;sql 'alter system switch logfile';sql 'alter system switch logfile';sql 'alter system switch logfile';sql 'alter system switch logfile';crosscheck backupset;delete noprompt expired backupset;backup database format '/u01/backup/bk_%s_%p_%t';sql 'alter system archive log current';BACKUP ARCHIVELOG ALL FORMAT '/u01/backup/ARCH_%U';BACKUP CURRENT CONTROLFILE FORMAT '/u01/backup/bk_controlfile';release channel ch00;release channel ch01;}--将备份文件拷贝到目标主机上。cd /u01/backup/[root@www.cndba.cn backup]# scp * 192.168.1.86:/u01/backup/--在目标端给备份文件授权[root@www.cndba.cn backup]# chown -R oracle:oinstall /u01/backup/5.5.恢复目标端数据库5.5.1.讲数据库启动到nomountSQL> startup nomountORACLE instance started.Total System Global Area 1060585472 bytesFixed Size   2260000 bytesVariable Size 905970656 bytesDatabase Buffers 146800640 bytesRedo Buffers   5554176 bytes

5.5.2.恢复控制文件

RMAN> restore controlfile from '/u01/backup/bk_controlfile';Starting restore at 07-JUN-18using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=18 device type=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/u01/app/oracle/oradata/cndba/control01.ctloutput file name=/u01/app/oracle/oradata/cndba/control02.ctlFinished restore at 07-JUN-18

5.5.3.将数据库启动到mount

SQL> alter database mount;Database altered.

5.5.4.注册备份集

RMAN> catalog start with '/u01/backup/';using target database control file instead of recovery catalogsearching for all files that match the pattern /u01/backup/List of Files Unknown to the Database=====================================File Name: /u01/backup/bk_controlfileDo you really want to catalog the above files (enter YES or NO)? yescataloging files...cataloging doneList of Cataloged Files=======================File Name: /u01/backup/bk_controlfile

5.5.5.恢复数据库

RMAN> RESTORE DATABASE;Starting restore at 07-JUN-18allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/cndba/system01.dbfchannel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/cndba/users01.dbfchannel ORA_DISK_1: reading from backup piece /u01/backup/bk_31_1_978141141channel ORA_DISK_1: piece handle=/u01/backup/bk_31_1_978141141 tag=TAG20180607T015220channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:55channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/cndba/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/cndba/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/cndba/ogg01.dbfchannel ORA_DISK_1: reading from backup piece /u01/backup/bk_32_1_978141141channel ORA_DISK_1: piece handle=/u01/backup/bk_32_1_978141141 tag=TAG20180607T015220channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:45Finished restore at 07-JUN-18RMAN> RECOVER DATABASE;executing command: SET until clauseStarting recover at 07-JUN-18using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 07-JUN-18

5.5.6.使用以下SQL语句查找目标端数据库的SCN号:(得到该SCN号之后,启动复制进程时,使用该SCN号)

SQL> SELECT CHECKPOINT_CHANGE#,CHECKPOINT_TIME FROM V$DATAFILE_HEADER;CHECKPOINT_CHANGE# CHECKPOINT_T------------------ ------------  1066024 07-JUN-18  1066024 07-JUN-18  1066024 07-JUN-18  1066024 07-JUN-18  1066024 07-JUN-18a)  如果目标端数据库在“5.4.1”操作之后,又额外追加了源数据库rman备份后的归档日志,导致目标端数据库的SCN号大于“5.4.1”中SCN号。所以必须以目标端数据库当前的SCN为主,从而避免数据重复。b)  如果目标端数据库在“5.4.1”操作之后,没有额外追加源数据库rman备份后的归档日志,则“5.5.6”中得到的SCN号应该与“5.4.1”中的SCN号相等;--以resetlogs方式打开数据库SQL> alter database open resetlogs;Database altered.

5.5.7.添加GLOBALS参数文件,创新检查点表

GGSCI (cndba) 7> edit params ./GLOBALSGGSCI (cndba) 8> view params ./GLOBALS--添加以下内容:GGSCHEMA oggcheckpointtable ogg.checkpointGGSCI (cndba) 9> dblogin userid ogg,password oggSuccessfully logged into database.GGSCI (cndba) 10> add checkpointtable ogg.checkpoint   Successfully created checkpoint table ogg.checkpoint.

5.5.8.配置replicat复制进程

GGSCI (cndba) 11> add replicat rep1, exttrail ./dirdat/et, checkpointtable ogg.checkpointREPLICAT added.GGSCI (cndba) 12> edit params rep1GGSCI (cndba) 13> view params rep1REPLICAT rep1setenv (ORACLE_SID=cndba)SETENV (ORACLE_HOME = "/u01/app/oracle/product/11.2.0/db_1")USERID ogg,PASSWORD oggASSUMETARGETDEFSHANDLECOLLISIONSREPERROR (DEFAULT, DISCARD)DDLERROR DEFAULT DISCARDDDLOPTIONS REPORTDISCARDFILE ./dirrpt/repr1.dsc,append,megabytes 100MAP test.*, TARGET test.*;

5.5.9.用SCN 启动Replicat

[oracle@www.cndba.cn ogg]$ cd $OGG_HOME[oracle@www.cndba.cn ogg]$ ./ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBOLinux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.GGSCI (cndba) 15> start rep1, aftercsn 1066024Sending START request to MANAGER ...REPLICAT REP1 startingGGSCI (cndba) 33> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           REPLICAT    RUNNING     REP1        00:00:00      00:00:07

6.检查同步是否正常

6.1.DML测试

--检查目标端数据是否正常GGSCI (cndba) 4> info allProgram     Status      Group       Lag at Chkpt  Time Since ChkptMANAGER     RUNNING                                           REPLICAT    RUNNING     REP1        00:00:00      00:00:06SQL> select * from test;ID NAME---------- --------1 zhangsan2 lisi--源端表中添加数据SQL> insert into test values(3,'wanger');1 row created.SQL> commit;Commit complete.SQL> select * from test;ID NAME---------- --------1 zhangsan2 lisi3 wanger--目标端查看SQL> select * from test;ID NAME---------- --------1 zhangsan2 lisi3 wanger可以看到可以同步过来的。

7.开启DDL

7.1.添加参数

GGSCI (cndba) 8> edit params ./GLOBALSGGSCI (cndba) 9> view params ./GLOBALSGGSCHEMA ogg

7.2.在源端执行与DDL同步相关的SQL脚本

切记@marker_setup.sql 一定要在cd $OGG_HOME目录下执行否则会卡主。执行脚本时要输入ogg管理用户,本实例是ogg。cd /u01/app/oracle/oggsqlplus / as sysdbagrant execute on utl_file to ogg;@marker_setup.sql@ddl_setup.sql@role_setup.sqlgrant GGS_GGSUSER_ROLE to ogg;@ddl_enable.sql@ddl_pin ogg@marker_status

7.3.源端extract 配置

GGSCI (cndba) 12> edit params ext1GGSCI (cndba) 16> view params ext1EXTRACT ext1SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK") --此处数据库字符集设为一致--SETENV (ORACLE_SID = "cndba")SETENV (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)USERID ogg, PASSWORD oggTHREADOPTIONS MAXCOMMITPROPAGATIONDELAY 20000EXTTRAIL ./dirdat/etDYNAMICRESOLUTIONDDL INCLUDE ALLTABLE test.*;重启extract进程GGSCI (cndba) 13> stop ext1 Sending STOP request to EXTRACT EXT1 ...Request processed.GGSCI (cndba) 14> start ext1Sending START request to MANAGER ...EXTRACT EXT1 starting

7.4.目标端replicat 配置

GGSCI (cndba) 8> edit params rep1GGSCI (cndba) 9> view params rep1REPLICAT rep1setenv (ORACLE_SID=cndba)SETENV (ORACLE_HOME = "/u01/app/oracle/product/11.2.0/db_1")USERID ogg,PASSWORD oggASSUMETARGETDEFSHANDLECOLLISIONSREPERROR (DEFAULT, DISCARD)DDLERROR DEFAULT DISCARDDDLOPTIONS REPORTDISCARDFILE ./dirrpt/repr1.dsc,append,megabytes 100MAP test.*, TARGET test.*;ddl include all ddlerror default ignore retryop maxretries 3 retrydelay 5重启replicat进程GGSCI (cndba) 10> stop rep1Sending STOP request to REPLICAT REP1 ...Request processed.GGSCI (cndba) 11> start rep1Sending START request to MANAGER ...RSQL> insert into test1 values(1,'zhangsan');1 row created.SQL> commit;EPLICAT REP1 starting

7.5.DDL测试

--源端:SQL> create table test1 (id number(10) primary key ,name varchar(8));Table created.Commit complete.--目标端:SQL> desc test1 Name  Null?    Type ----------------------------------------- -------- ---------------------------- ID  NOT NULL NUMBER(10) NAME   VARCHAR2(8)SQL> select * from test1;ID NAME---------- --------1 zhangsan

更多Oracle相关信息见Oracle 专题页面 https://www.linuxidc.com/topicnews.aspx?tid=12 

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址:https://www.linuxidc.com/Linux/2019-08/160124.htm

Tags: 责任编辑:Tag站长知识库
顶一下(43)
87.08%

精彩信息

     

精彩信息

     

精彩信息