想把1机器上的A库同步到2机器上的B库上,称A库位源,B位目标库:
在目标库上做如下操作:
drop public database link dblink2rmon;
create database link DBLINK2RMON connect to RISK2 identified by RISK2 using 'DB_RMON';
以用户RISK2,密码RISK2连接 czcedb_rmon(必须在$ORACLE_HOME/network/admin/tnsnames.ora中定义SID)并定义DBLINK
在源数据库上建立快照日志:
创建要同步表的快照日志
create snapshot log on _RTMON_FUND;
create snapshot log on _RTMON_HOLD_CUSTOMER;
删除可用:
drop snapshot log on _RTMON_FUND;
drop snapshot log on _RTMON_HOLD_CUSTOMER;
在目标主机上创建快照:
Create snapshot _RTMON_FUND as select * from ES_RTMON_FUND@DBLINK2RMON;
Create snapshot _RTMON_HOLD_CUSTOMER as select * from ES_RTMON_HOLD_CUSTOMER@dblink2RMON;
删除可用:
drop snapshot _RTMON_FUND;
drop snapshot _RTMON_HOLD_CUSTOMER;?
刷新快照使用:
Alter snapshot _RTMON_FUND? refresh fast Start with sysdate+1/24*60 next sysdate+2/24*60;? 按照分钟刷新 1.2分钟
Alter snapshot _RTMON_FUND? refresh complete Start with sysdate+30/24*60*60 next sysdate+30/24*60*60; 按照秒刷新 30秒
Alter snapshot _RTMON_FUND? refresh fast Start with sysdate next sysdate with primary key; 实时刷新
Alter snapshot _RTMON_FUND? refresh fast Start with sysdate next sysdate with primary key;
Alter snapshot _RTMON_FUND? refresh fast Start with sysdate next sysdate with primary key;
这里需要对目标和源主机上的账户添加快照创建使用权限:
Grant CREATE ANY SNAPSHOT to risk;
Grant ALTER ANY SNAPSHOT to risk;