[原创]rhel+oracle11g+shareplex+exp/imp模拟迁移数据(中)[原创]_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 3272 | 回复: 0   主题: [原创]rhel+oracle11g+shareplex+exp/imp模拟迁移数据(中)[原创]        下一篇 
tengfei.dong
注册用户
等级:中尉
经验:461
发帖:15
精华:0
注册:1970-1-1
状态:离线
发送短消息息给tengfei.dong 加好友    发送短消息息给tengfei.dong 发消息
发表于: IP:您无权察看 2014-12-1 16:54:05 | [全部帖] [楼主帖] 楼主

shareplex的部署安装已经在上一贴已做说明,详细请参考:[原创]rhel+oracle11g+shareplex+exp/imp部署测试(上)[原创],下面演示以exp/imp为初始化数据手段模拟shareplex不停机迁移数据,由于exp/imp是可以跨平台的,此方案可用于跨平台数据迁移,但只限于oracle数据库之间哦~~

1.源端和目标端清除配置

ora_clean system/oracle


2.源端和目标端配置shareplex

ora_setup


3.源端目标端启动shareplex

sp_cop &


4.目标端停止post队列

sp_ctrl (shareplex02:2100)> show
Process    Source                               Target       State                   PID
---------- ------------------------------------ ------------ -------------------- ------
sp_ctrl (shareplex02:2100)> stop post


5.编辑规则集

sp_ctrl (shareplex01:2100)> copy config ORA_config to ora_exp
sp_ctrl (shareplex01:2100)> list config
File   Name                                         State       Datasource
--------------------------------------------------  ----------  ---------------
ora_con                                             Inactive    o.orcl
Last Modified At: 27-Oct-14 18:49    Size: 136
ORA_config                                          Inactive    o.SOURCE_SID
Last Modified At: 27-Oct-14 17:10    Size: 151
ora_exp                                             Inactive    o.SOURCE_SID
Last Modified At: 28-Oct-14 13:07    Size: 151
sp_ctrl (shareplex01:2100)>


编辑规则集文件ora_exp:

datasource:o.orcl
#source tables      target tables           routing map
expand scott.%      scott.%             shareplex02@o.orcl
expand hr.%      hr.%             shareplex02@o.orcl


6.生效规则集:

sp_ctrl (shareplex01:2100)> activate config ora_exp
sp_ctrl (shareplex01:2100)> show
Process    Source                               Target       State                   PID
---------- ------------------------------------ ------------ -------------------- ------
Capture    o.orcl                                            Running                6736
Read       o.orcl                                            Running                6741
Export     shareplex01                          shareplex02  Running                6762
sp_ctrl (shareplex01:2100)>
sp_ctrl (shareplex02:2100)> show
Process    Source                               Target       State                   PID
---------- ------------------------------------ ------------ -------------------- ------
Import     shareplex01                          shareplex02  Running                7172
Post       o.orcl-shareplex01                   o.orcl       Stopped by user
sp_ctrl (shareplex02:2100)>


7.生产库查询当前的scn:

SQL> select current_scn from v$database;
CURRENT_SCN
-----------
1386140
SQL>


8.源端生产库基于flashback_scn exp/expdp数据:

exp system/oracle compress=n owner=scott,hr file='/oracle/app/oracle/expimp/sp.dmp' \
log='/oracle/app/oracle/expimp/sp.log'  flashback_scn=1386140


10.目标端导入数据:

imp system/oracle file='/oracle/app/oracle/expimp/sp.dmp' fromuser=scott,hr touser=scott,hr


11.目标端reconcile重复数据:

reconcile queue shareplex01 for o.orcl-o.orcl scn 1386140


queue名可以通过qstatus查询到,如果没有要删除的重复数据,则此进程处于挂起状态,是正常的,直接退出就可以了。

12.目标端disable trigger\constraints\job
先用以下脚本生成sql,然后执行:

select 'alter trigger '||owner||'.'||trigger_name||' disable;' from dba_triggers where owner in ('SCOTT','HR');
select 'alter table '||owner||'.'||table_name||' disable constraint '||constraint_name||';' from dba_constraints where  constraint_type in ('R') and owner in ('SCOTT','HR');


13.目标端启动post队列:

sp_ctrl (shareplex02:2100)> start post
sp_ctrl (shareplex02:2100)> show
Process    Source                               Target       State                   PID
---------- ------------------------------------ ------------ -------------------- ------
Import     shareplex01                          shareplex02  Running                7172
Post       o.orcl-shareplex01                   o.orcl       Running                7779


14.测试验证:
如果源端的表在目标端不存在,开启post的时候会报错。并且报错之后post进程自动停止。这时候可在目标端创建空表,然后开启post进程,但有可能
数据不会完全同步过去,需要手动repair或者copy表。




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论