expdp/impdp数据初始化
使用数据expdp(基于原端某scn号的一致性导出)和目标端impdp的方式进行目标数据库的重构
其中的关键注意点说明如下:
在取原端数据库scn号之前,确保源端ogg的extract已经启动;在获取scn之前要确认源端当前没有开始时间在extract启动的时间之前的活动事务。
获取当前系统事务开始的时间:
select start_time from gv$transaction;
先完成以下:
源库和目标库安装ogg,源端配置ext和pump进程,目标值配置好rep的参数
源库打开库最小附件日志,打开复制表的附加日志
(1)源库启动ext和pump进程
(2)原端取scn号语句:
Select current_scn from v$database;
如:获取的scn号为:928672344
(3)原端开始expdp
expdp XPADB/XPADB DIRECTORY=oggd DUMPFILE=xpadb.`date '+%Y%m%d_%H%M'`.dmp.%U LOGFILE=xpadb.`date '+%Y%m%d_%H%M'`.log parallel=4 FLASHBACK_SCN=928672344
(4)目标impdp:
在导入前,如果系统有job,先把目标库的:job_queue_processes设置成0
impdp XPADRPT/xpadrpt DIRECTORY=oggd DUMPFILE=xpadb.20130620_1525.dmp.%U LOGFILE=impdp.xpadb.20130620_1525.log parallel=4 REMAP_SCHEMA=xpadb:xpadrpt REMAP_TABLESPACE=xpaddat:xpaddata
(5)目标库disable相关对象
目标数据库重构并open后,需要diable trigger/job/cascade reference;
对应的disable脚本如下:
set echo off
set verify off
set feedback off
set pagesize 10000
set heading off
set linesize 200
set trim on
spool disable_ref.txt
select 'alter table '||owner||'.'||table_name||' disable constraint '||constraint_name||';'
from dba_constraints
where constraint_type in ('R') and owner = 'XPADRPT' and delete_rule='CASCADE' and status ='ENABLED';
spool off
spool disable_trigger.txt
select 'alter trigger '||owner||'.'||trigger_name||' disable;'
from dba_triggers where owner = 'XPADRPT' and STATUS='ENABLED';
spool off
spool disable_job.txt
select 'execute DBMS_IJOB.BROKEN('||job||',TRUE); commit;'
from dba_jobs
where schema_user = 'XPADRPT' and BROKEN='N';
spool off
(6)目标配置replicat进程并追加增量数据(在目标库完成重构后)
cd $GG_HOME
./ggsci
GGSCI> add replicat ggsrep, exttrail ./dirdat/tt, nodbcheckpoint
下面12643566035515就是恢复目标库所到的scn号:
GGSCI> start replicat ggsrep , aftercsn 928672344
如果提示trail文件找不到,可以先执行:
GGSCI> alter replicat ggsrep, extseqno **, extrba 0
**-需要从目标的dirdat目录下找从源端传输过来可用的最小序号的trail文件的序号(前面无效的0不要,000000就用0)