数据库
首页 > 数据库> > oracle ogg 单实例双向-新增表,修改表结构(oracle-oracle

oracle ogg 单实例双向-新增表,修改表结构(oracle-oracle

作者:互联网

--新增inset测试
--dept 表结构orcl,ogg都存在,数据相同(但是rep1配置文件没有添加)

SCOTT@ orcl >insert into dept values(1,'hongquan','BBA');

1 row created.

SCOTT@ orcl >commit;

Commit complete.

SCOTT@ orcl >select * from dept;

    DEPTNO DNAME      LOC
---------- -------------- -------------
    10 ACCOUNTING      NEW YORK
    20 RESEARCH      DALLAS
    30 SALES      CHICAGO
    40 OPERATIONS      BOSTON
     1 hongquan      BBA

ogg端
由于rep1参数文件没有配置dept的map所以ogg不会有数据

2019-06-20 15:55:51  INFO    OGG-03035  Operating system character set identified as UTF-8. Locale: en_US, LC_ALL:.
REPLICAT rep1
SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
Set environment variable (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
USERID ogg, PASSWORD ***
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE ./dirrpt/rep1.dsc, PURGE
MAP scott.emp_ogg, TARGET scott.emp_ogg;
MAP scott.dept_ogg, TARGET scott.dept_ogg;

更新rep1参数文件,添加

MAP scott.dept, TARGET scott.dept;
GGSCI (ogg) 37> stop rep1
GGSCI (ogg) 38> edit param rep1
GGSCI (ogg) 41> delete rep1
GGSCI (ogg) 44> add REPLICAT rep1,exttrail ./dirdat/t1,checkpointtable ogg.ggschkpt
GGSCI (ogg) 45> start rep1
ogg端发现新插入的数据
SCOTT@ ogg >/

    DEPTNO DNAME      LOC
---------- -------------- -------------
    10 ACCOUNTING      NEW YORK
    20 RESEARCH      DALLAS
    30 SALES      CHICAGO
    40 OPERATIONS      BOSTON
     1 hongquan      BBA

5 rows selected.
修改orcl端配置
GGSCI (DSI) 17> stop rep1
GGSCI (DSI) 18> edit param rep1
GGSCI (DSI) 19> start rep1
ogg端插入测试
SCOTT@ ogg >insert into dept values(2,'hongquan','ogg');

1 row created.

SCOTT@ ogg >commit;

Commit complete.

SCOTT@ ogg >select * from dept;

    DEPTNO DNAME      LOC
---------- -------------- -------------
    10 ACCOUNTING      NEW YORK
    20 RESEARCH      DALLAS
    30 SALES      CHICAGO
    40 OPERATIONS      BOSTON
     2 hongquan      ogg
     1 hongquan      BBA

6 rows selected.
已经同步
SCOTT@ orcl >select * from dept;

    DEPTNO DNAME      LOC
---------- -------------- -------------
    10 ACCOUNTING      NEW YORK
    20 RESEARCH      DALLAS
    30 SALES      CHICAGO
    40 OPERATIONS      BOSTON
     2 hongquan      ogg
     1 hongquan      BBA

6 rows selected.

2 更改表结构测试

SCOTT@ orcl >alter table emp_ogg add(ogg_t1 number);

Table altered.

SCOTT@ orcl >desc emp_ogg;
 Name                                   Null?    Type
 ----------------------------------------------------------------- -------- --------------------------------------------
 EMPNO                                   NOT NULL NUMBER(4)
 ENAME                                        VARCHAR2(10)
 JOB                                        VARCHAR2(9)
 MGR                                        NUMBER(4)
 HIREDATE                                    DATE
 SAL                                        NUMBER(7,2)
 COMM                                        NUMBER(7,2)
 DEPTNO                                     NUMBER(2)
 OGG_T1                                     NUMBER
已经同步
SCOTT@ ogg >desc emp_ogg;
 Name                                   Null?    Type
 ----------------------------------------------------------------- -------- --------------------------------------------
 EMPNO                                   NOT NULL NUMBER(4)
 ENAME                                        VARCHAR2(10)
 JOB                                        VARCHAR2(9)
 MGR                                        NUMBER(4)
 HIREDATE                                    DATE
 SAL                                        NUMBER(7,2)
 COMM                                        NUMBER(7,2)
 DEPTNO                                     NUMBER(2)
 OGG_T1                                     NUMBER

3 新增加表结构

--新增加表结构
SCOTT@ orcl >create table test_ogg(id number,name varchar2(20),create_time date default sysdate);
Table created.
SCOTT@ orcl >alter table test_ogg add constraint PK_test_ogg primary key (id);
Table altered.
--orcl
> DBLOGIN USERID ogg, PASSWORD ogg
> add trandata scott.test_ogg
> INFO TRANDATA scott.test_ogg
> stop ext1
> edit param ext1
TABLE scott.TEST_OGG;
> stop pump1
> edit param pump1
TABLE scott.TEST_OGG;
> start ext1
> start pump1
> stop repl
> edit param rep1
MAP scott.TEST_OGG, TARGET scott.TEST_OGG;
> start rep1

orcl端操作详细

GGSCI (DSI) 21> DBLOGIN USERID ogg, PASSWORD ogg
Successfully logged into database.

GGSCI (DSI) 22> add trandata scott.test_ogg

Logging of supplemental redo data enabled for table SCOTT.TEST_OGG.

GGSCI (DSI) 23> INFO TRANDATA scott.test_ogg

Logging of supplemental redo log data is enabled for table SCOTT.TEST_OGG.

Columns supplementally logged for table SCOTT.TEST_OGG: ID.

GGSCI (DSI) 24> stop ext1

Sending STOP request to EXTRACT EXT1 ...
Request processed.


GGSCI (DSI) 25> edit param ext1



GGSCI (DSI) 26> start ext1

Sending START request to MANAGER ...
EXTRACT EXT1 starting


GGSCI (DSI) 27> stop pump1

Sending STOP request to EXTRACT PUMP1 ...
Request processed.


GGSCI (DSI) 28> edit param pump1



GGSCI (DSI) 29> stop rep1

Sending STOP request to REPLICAT REP1 ...
Request processed.


GGSCI (DSI) 30> edit param rep1



GGSCI (DSI) 31> start pump1

Sending START request to MANAGER ...
EXTRACT PUMP1 starting


GGSCI (DSI) 32> start rep1

Sending START request to MANAGER ...
REPLICAT REP1 starting


GGSCI (DSI) 33> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     EXT1        00:00:00      00:00:00    
EXTRACT     RUNNING     PUMP1       00:00:00      00:00:10    
REPLICAT    RUNNING     REP1        00:00:00      00:00:09   
View Code

在ogg端添加trandata log之前,要先创建表,不然会报错

2019-06-20 17:15:04  WARNING OGG-00869  No unique key is defined for table 'TEST_OGG'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.

insert测试

SCOTT@ orcl >insert into test_ogg (id,name) values(1,'hq1');

1 row created.

SCOTT@ orcl >commit;

Commit complete.

SCOTT@ orcl >select * from test_ogg;

    ID NAME         CREATE_TI
---------- -------------------- ---------
     1 hq1            20-JUN-19

1 row selected.

ogg端

SCOTT@ ogg >select * from test_ogg;

    ID NAME         CREATE_TI
---------- -------------------- ---------
     1 hq1            20-JUN-19

1 row selected.

标签:00,GGSCI,rep1,实例,SCOTT,DSI,oracle,ogg
来源: https://www.cnblogs.com/yhq1314/p/11060073.html