cdc 的部署 同步模式

cdc 操作步骤
CREATE TABLESPACE cdcpub DATAFILE
  '+DATA2/oradata/billdb/cdcpub01.dbf' SIZE 100M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED
  EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
  
--创建CDCPUB用户
create user cdcpub identified by cdcpub
default tablespace cdcpub
temporary tablespace temp
quota unlimited on cdcpub;

grant execute_catalog_role to cdcpub;
grant select_catalog_role to cdcpub;
grant create table to cdcpub;
grant create session to cdcpub;
grant execute on dbms_cdc_publish to cdcpub;
GRANT CREATE JOB TO cdcpub;

create user cdcsub identified by cdcsub
default tablespace cdcpub
temporary tablespace temp
quota unlimited on cdcpub;
grant connect,resource to cdcsub;


--赋源表查询权限
grant select on scott.dept to cdcpub;
grant select on scott.emp to cdcpub;

begin
	dbms_cdc_publish.create_change_set(change_set_name =>'SCOTT_DEPT',
									description =>'change set for SCOTT_DEPT',
									change_source_name =>'SYNC_SOURCE');
end;
/

begin
	dbms_cdc_publish.create_change_table(
		owner =>'CDCPUB',
		change_table_name =>'SCOTT_DEPT_CT',
		change_set_name =>'SCOTT_DEPT',
		source_schema => 'SCOTT',
		source_table => 'DEPT',
		column_type_list => 'DEPTNO NUMBER(2),
                         DNAME  VARCHAR2(14),
                         LOC   VARCHAR2(13)',	
		capture_values => 'NEW',
		rs_id => 'y',
		row_id => 'n',
		user_id => 'n',
		timestamp => 'n',
		object_id=>'n',
		source_colmap=>'y',
		target_colmap=>'y',
		options_string=>'tablespace cdcpub',
		DDL_MARKERS       => 'N');
end;
/

grant all on CDCPUB.SCOTT_DEPT_CT to cdcsub;

conn cdcsub/cdcsub

BEGIN
DBMS_CDC_SUBSCRIBE.CREATE_SUBSCRIPTION(
change_set_name => 'SCOTT_DEPT',
description => 'Change data for SCOTT_DEPT',
subscription_name => 'SCOTT_DEPT_SUB');
END;
/

BEGIN
DBMS_CDC_SUBSCRIBE.SUBSCRIBE(
subscription_name => 'SCOTT_DEPT_SUB',
source_schema => 'SCOTT',
source_table => 'DEPT',
column_list => 'DEPTNO,
                DNAME,
                LOC',
subscriber_view => 'SCOTT_DEPT_CV');
END;
/


BEGIN
DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION(
subscription_name => 'SCOTT_DEPT_SUB');
END;
/

BEGIN
DBMS_CDC_SUBSCRIBE.EXTEND_WINDOW(
subscription_name => 'SCOTT_DEPT_SUB');
END;
/

你可能感兴趣的:(oracle,体系)