环境 说明
操作系统: Centos7.6
主机名 | IP | 实例名 | 角色 |
dm1 | 192.168.31.166 | dm1 | RPS |
dm2 | 192.168.31.168 | dm2 | 主 |
dm3 | 192.168.31.169 | dm3 | 从 |
填好三台/etc/hosts表
[dmdba@dm1 ini_script]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.31.166 dm1
192.168.31.168 dm2
192.168.31.169 dm3
开好归档。
disql SYSDBA/SYSDBA
alter database mount;
alter database add archivelog 'DEST=/dm/dmarch,TYPE=local,FILE_SIZE=256,space_limit=0';
alter database archivelog;
alter database open;
select arch_mode from v$database;
打开dm.ini中的mal_ini参数
[dmdba@dm1 ~]$ cat /dm/dmdbms/data/dm1/dm.ini |grep MAL_INI
MAL_INI = 1 #dmmal.ini
创建dmmal.ini
[dmdba@dm1 ~]$ cd /dm/dmdbms/samples/ini_script
[dmdba@dm1 ini_script]$ vi dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_dm1]
MAL_INST_NAME = dm1
MAL_HOST = dm1
MAL_PORT = 5241
MAL_INST_PORT = 5236
MAL_INST_HOST = dm1
[MAL_dm2]
MAL_INST_NAME = dm2
MAL_HOST = dm2
MAL_PORT = 5242
MAL_INST_PORT = 5236
MAL_INST_HOST = dm2
[MAL_dm3]
MAL_INST_NAME = dm3
MAL_HOST = dm3
MAL_PORT = 5243
MAL_INST_PORT = 5236
MAL_INST_HOST = dm3
cp dmmal.ini /dm/dmdbms/data/dm1/.
同步到另外二台主机相应的位置
重启实例
[dm1]#systemctl restart DmServicedm1.service
[dm2]#systemctl restart DmServicedm2.service
[dm3]#systemctl restart DmServicedm3.service
1)复制组表(SYSREP.RPS_GROUPS)
2)复制节点实例表(SYSREP.RPS_INSTANCES)
3)复制关系表(SYSREP.RPS_REPLICATIONS)
4)复制映射表( SYSREP.RPS_TABMAPS)
5)故障历史表(SYSREP.REP_FAULT_HISTORY)
6)冲突历史表( SYSREP.RPS_CONFLICTS)
7)复制定时器表(SYSREP.RPS_TIMERS)
初始化dm1
[dmdba@dm1 ini_script]$ disql sysdba/sysdba
Server[LOCALHOST:5236]:mode is normal, state is open
login used time: 3.174(ms)
disql V8
SQL> SP_INIT_REP_SYS(1);
DMSQL executed successfully
used time: 14.797(ms). Execute id is 991.
SQL> conn SYSREP/SYSREP
Server[LOCALHOST:5236]:mode is normal, state is open
login used time: 3.162(ms)
SQL> select table_name from user_tables;
LINEID TABLE_NAME
---------- -----------------
1 RPS_GROUPS
2 RPS_INSTANCES
3 RPS_REPLICATIONS
4 RPS_TABMAPS
5 RPS_FAULT_HISTORY
6 RPS_CONFLICTS
7 RPS_TIMERS
7 rows got
used time: 29.948(ms). Execute id is 992.
SQL>
未初始化-也可以通过图形化界面初始化
已经初始化
创建New Replication Group
call SP_RPS_ADD_GROUP('test-repg','');
创建Table Replication Map
将DM2的test用户下的test_1表同步至DM3下的test用户下的test_1
call SP_RPS_SET_BEGIN('test-repg');
call SP_RPS_ADD_REPLICATION('test-repg','test-rep','','DM2','DM3',NULL,'/dm/dmarch');
call SP_RPS_SET_APPLY();
测试,在DM2下插入3条数据,并commit;
在DM3下查看表,已经被同步过来。
由于在创建Table Replication Map时勾选了readonly,所以DM3下的表无法插入。
其它表不受影响
其它(用户复制)
call SP_RPS_SET_BEGIN('test-repg');
call SP_RPS_ADD_SCH_MAP('test-rep','test','test',1);
call SP_RPS_SET_APPLY();
测试:
支持ddl不支持dml
原的历史数据未同步。如果需要同步历史数据,需要将时间戳打上,全量由dmp传输。
SQL> begin
2 for i in 1 .. 100
3 loop
4 insert into test2 values (i, 'test');
5 commit;
6 end loop;
7 end;
8 /
DMSQL executed successfully
used time: 356.875(ms). Execute id is 82.
SQL>
SQL> select count(*) from test2;
LINEID COUNT(*)
---------- --------------------
1 300
used time: 0.857(ms). Execute id is 83.
SQL>
目标的数据,为增量数据,数据比原少200条
SQL> create table test2(id int,sdate char(20));
executed successfully
used time: 3.798(ms). Execute id is 246.
SQL> select count(*) from test2;
LINEID COUNT(*)
---------- --------------------
1 100
used time: 0.507(ms). Execute id is 447.
SQL>