使用增量XTTS传输表空间

来源:互联网 发布:下载电子琴简谱软件 编辑:程序博客网 时间:2024/04/29 04:13

1、使用增量XTTS 传输表空间的前提条件
  • In addition to the limitations and considerations for transportable tablespaces, the following conditions must be met:
    • The source system cannot be Windows.
    • The source database must have its COMPATIBLE parameter set to 10.2.0 or higher.
    • The source database's COMPATIBLE parameter must not be greater than the destination database's COMPATIBLE parameter.
    • The source database must be in ARCHIVELOG mode.
    • The destination system must be Linux, either 64-bit Oracle Linux or a certified version of RedHat Linux.
    • RMAN's default device type should be configured to DISK
    • RMAN on the source system must not have DEVICE TYPE DISK configured with COMPRESSED.
    • The set of tablespaces being moved must all be online, and contain no offline data files.  Tablespaces must be READ WRITE.  Tablespaces that are READ ONLY may be moved with the normal XTTS method.  There is no need to incorporate Cross Platform Incremental Backups to move tablespaces that are always READ ONLY.
  • All steps in this procedure are run as the oracle user that is a member of the OSDBA group. OS authentication is used to connect to both the source and destination databases.
  • If the Prepare Phase method selected is dbms_file_transfer, then the destination database must be 11.2.0.4.  See theSelecting the Prepare Phase Method section for details.
  • If the Prepare Phase method selected is RMAN backup, then staging areas are required on both the source and destination systems.  See theSelecting the Prepare Phase Method section for details.
  • If the destination database version is 11.2.0.3 or lower, then a separate database home containing 11.2.0.4 running an 11.2.0.4 instance on the destination system is required to perform the incremental backup conversion.  See theDestination Database 11.2.0.3 and Earlier Requires a Separate Incremental Convert Home and Instance section for details. If using ASM for 11.2.0.4 Convert Home, then ASM needs to be on 11.2.0.4, else error ORA-15295 (e.g. ORA-15295: ASM instance software version 11.2.0.3.0 less than client version 11.2.0.4.0) is raised.

 附加限制
1、 源端不能为windows
2、 源库的COMPATIBLE参数必须设置到10.2.0或更高
3、 源库的COMPATIBLE参数不能高于目标端的COMPATIBLE参数
4、 源端必须是archivelog模式
5、 目标端必须是64位linux
6、 RMAN的default device类型要设置为DISK, 不能设置为COMPRESSED
7、 源端的DEVICE TYPE DISK不能设有compressed
8、 所有被移动的表空间,必须online,而且不能包含offline的数据文件
9、源库和目标库字符集需要保持一致
10 、目标端db_files参数必须大于源端
11、排除系统表空间,避免冲突并检查业务表空间是否自包含





2、迁移前的准备:
1、迁移对象统计
2、数据库字符集检查
3、检查原环境是否存在空段
4、失效对象检查
5、基于XMLSchema的XMLType对象检查
6、目标端创建检查用dblink (如果用 dbms_file_transfer方式传输需要确认)
7、检查源数据库和目标库具有重复名称的表空间
8、检查是否存在应用用户建在system,sysaux,users上的情况
9、表空间自包含检查
10、比对新旧环境role
11、比对新旧环境profile
12、在新环境中比对并创建用户
13、生成恢复用户默认表空间和临时表空间的脚本
14、创建非默认的temp表空间
15、生成为应用用户赋对象权限脚本
16、软件包上传
17 源库的COMPATIBLE参数必须设置到10.2.0或更高
18  源端必须是archivelog模式
19  目标端必须是64位linux


3、增强版本xtts传输步骤:
A、将源端数据文件传输到目标系统。
B、转换数据文件为目标系统的字节序。
C、在源端创建增量备份,并传输到目标端。
D、在目标端恢复增量备份。
E、重复多次操作C和D步骤。
F、将源端数据库表空间设置为READ ONLY模式。
G、最后一次执行C和D步骤。
H、在源端导出元数据,并在目标端导入。
I、将目标端的数据库表空间设置为READ WRITE。



After performing the Initial Setup phase, moving the data is performed in the following three phases:

Prepare phase
During the Prepare phase, datafile copies of the tablespaces to be transported are transferred to the destination system and converted.  The application being migrated is fully accessible during the Prepare phase.  The Prepare phase can be performed using RMAN backups or dbms_file_transfer.  Refer to the Selecting the Prepare Phase Method section for details about choosing the Prepare phase method.

Roll Forward phase
During the Roll Forward phase, the datafile copies that were converted during the Prepare phase are rolled forward using incremental backups taken from the source database.  By performing this phase multiple times, each successive incremental backup becomes smaller and faster to apply, allowing the data at the destination system to be brought almost current with the source system.  The application being migrated is fully accessible during the Roll Forward phase.

Transport phase
During the Transport phase, the tablespaces being transported are put into READ ONLY mode, and a final incremental backup is taken from the source database and applied to the datafile copies on the destination system, making the destination datafile copies consistent with source database.  Once the datafiles are consistent, the tablespaces are TTS-exported from the source database and TTS-imported into the destination database.  Finally, the tablespaces are made READ WRITE for full access on the destination database. The application being migrated cannot receive any updates during the Transport phase.

1.准备阶段:

在准备阶段,表空间相关的数据文件将传送到目标操作系统,并且转换endian格式。在整个准备阶段,源端的表空间依然处于完全可以读写的情况。准备阶段可以通过rman backup或者dbms_file_transfer包进行。

2.前滚阶段:

在前滚阶段,通过使用源数据库一次一次的增量备份,将备份转换后应用到目标库的相应数据文件上。整个阶段,源库的相应表空间依然处于完全可以读写的情况。

3.最终传送阶段:

在整个传送阶段,源端相应表空间将被设置为readonly。相应表空间的最后一个增量备份将被应用到目标端。源端将元信息导出,并在目标端导入,目标端相应表空间设置为读写。

在该阶段,源端的相应表空间数据无法被操作,只可以被查询。





1.dbms_file_transfer Method
2. RMAN Backup Method

NOTE:  For large number of files, using dbms_file_transfer has been found to be the fastest method for transferring datafiles to destination.   



两种方法对比

   dbms_file_transfer方法
是使用dbms_file_transfer.get_file()包,在dblink上面将数据文件从源端传送到目标端,这种方法比RMAN方法好的地方是:
1、 不需要中转空间(放备份集)
2、 在传送的时候,数据文件的转换就自动完成了(不存在单独的转换步骤)


该方法需要如下必要条件:
 1)目标端数据库必须是11.2.0.4
 2)源端必须在相关数据文件存在的位置,创建成directory对象
 3)目标端一样,要将放数据文件的位置 设置成directory
 4)源端和目标端创建一个dblink


   RMAN备份的方法:
1)在源端,针对相应需要传送的数据文件,创建对应的备份文件。这些备份文件必须手动传送到目标端。在目标端通过RMAN对文件进行转换(如果endian格式不一样的话)。
将转换后的文件,放到合适的位置。在原来的版本中,这种方法是唯一的。


通过RMAN备份方法需要如下必要条件:
源端和目标端都需要中转空间用来存放数据文件的备份,这个中转空间的位置 将被xtt.properties文件中的dfcopydir 和stageondest参数使用
经过转换的文件,存入的最终位置,通过xtt.properties文件中的storageondest参数设置
当然,如果版本合适,推荐使用dbms_file_transfer
目标端如果是11.2.0.3或者更之前版本,那么需要安装单独的11.2.0.4的数据库软件(增量转换home),并创建一个11.2.0.4的实例(增量转换实例)。
如果你目标端数据库是11.2.0.4,那么你完全可以使用dbms_file_transfer。所以来说,增量转换home和实例基本都用在通过RMAN方法进行转换的。


Troubleshooting
我们可以通过运行xttdriver.pl -d 脚本,或者设置环境变量为XTTDEBUG=1,然后运行xttdriver.pl脚本 来启动debug模式,该模式将会有额外的内容输出。而且所有的执行的所有RMAN命令都是通过debug选项的。


运行整个过程的oracle 用户,要属于OSDBA组
源端可目标端已经使用OS authentication。
如果准备阶段决定使用dbms_file_transfer包。那么目标端数据库必须是11.2.0.4
如果准备阶段决定使用RMAN备份,那么源端和目标端都需要中转区
如果目标端数据库版本是11.2.0.3或更低。那么需要在目标端装11.2.0.4 并创建实例,然后用来进行备份集转换。如果11.2.0.4中转实例使用ASM。那么ASM版本也必须是11.2.0.4,否则报错ORA-15295


 xtt.properties 参数文件的解释: platformid=17    源端平台号 ,select * from v$transportable_platform order by platform_id 语句查询得到srcdir=SOURCEDIR  使用数据泵导入原数据,network_link方式dstdir=DESTDIR  使用数据泵导入原数据,network_link方式srclink=TTSLINK   perl xttdriver.pl -e命令生成impdp迁移脚本使用dfcopydir=/export/home/oracle/dfcopydir  源端rman备份目录 或者 源端datafile convert保存路径backupformat=/export/home/oracle/backup  源端增量备份保存路径stageondest=/home/oracle/backup 目标端备份文件存放路径backupondest=/home/oracle/backup 目标端增量备份集存放路径storageondest=+DATADG/orcldb11g  目标端恢复到数据库的数据文件保存位置,如果是diskgroup则需要注意还需要对应的数据库名,只在RMAN backup中使用cnvinst_home=/u01/oracle/app/11.2.4/db 新环境$ORACLE_HOMEcnvinst_sid=orcldb11g   新环境ORACLE_SID asm_home=/home/grid/app/11.2.0/grid   目标端asm home目录,如果是直接恢复到diskgroup,则需要指定对应的grid_home和ASM实例asm_sid=+ASM 目标端asm实例名,如果是直接恢复到diskgroup,则需要指定对应的grid_home和ASM实例parallel=3 设置并行,建议设置为6或者8,根据CPU情况设置rollparallel=2 roll forward 并行,如果数据库大的话建议设置为 8getfileparallel=4 getfile 并行度,建议设置为6或者8,根据CPU情况设置desttmpdir=/home/oracle/xtts 设置目标端tempdir目录,建议指向xtts目录) srcdir,dstdir,srclink 是用于通过dbms_file_transfer传输的参数



迁移步骤:



1、如果目标端数据库版本低于11.2.0.4,需要安装软件,起到nomount阶段,并且只能用使RMAN方式传输文件
 export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/xtt_home
[oracle@dest]$ export ORACLE_SID=xtt
[oracle@dest]$ cat << EOF > $ORACLE_HOME/dbs/init$ORACLE_SID.ora
db_name=xtt
compatible=11.2.0.4.0
EOF


[oracle@dest]$ sqlplus / as sysdba
SQL> startup nomount


1、目标端数据库版本必须是11.2.0.4版本才能用增量传输xtts,如果目标端不是11.2.0.4,
   那么需要在目标端安装11.2.0.4的软件,然后添加参数文件,启动到nomount,进行恢复
2、确定目标端数据库中有传输表空间中表的schema


         dbms_file_transfer方法
1.Using dbms_file_transfer (DFT) transfer (using xttdriver.pl -S and -G options)  【前期准备】SQL@source> create directory sourcedir as '+DATA/prod/datafile';SQL@dest> create directory destdir as '+DATA/prod/datafile';SQL@dest> create public database link ttslink connect to system identified by <password> using '<tns_to_source>';SQL@dest> select * from dual@ttslink; 解压缩软件 unzip rman-xttconvert_2.0.zip修改参数文件 xtt.properties 内容 创建参数文件中需要的文件夹[oracle@source]$ scp -r /home/oracle/xtt dest:/home/oracle/xtt[oracle@source]$ export TMPDIR=/home/oracle/xtt[oracle@dest]$ export TMPDIR=/home/oracle/xtt   【源端准备】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -S  [oracle@dest]$ scp oracle@source:/home/oracle/xtt/xttnewdatafiles.txt /home/oracle/xtt[oracle@dest]$ scp oracle@source:/home/oracle/xtt/getfile.sql /home/oracle/xtt   【传输数据文件到目标端】# MUST set environment to destination database[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G   【传输表空间的增量备份】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i    注意生成文件tsbkupmap.txt  incrbackups.txt,并传输到目标端[oracle@source]$ scp `cat incrbackups.txt` oracle@dest:/stage_dest[oracle@dest]$ scp oracle@source:/home/oracle/xtt/xttplan.txt /home/oracle/xtt[oracle@dest]$ scp oracle@source:/home/oracle/xtt/tsbkupmap.txt /home/oracle/xtt   【目标端增量备份应用到数据文件】[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r 【源端scn的推进】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s  【最后一次增量备份前,置表空间read only】system@source/prod SQL> alter tablespace TS1 read only;【源端最后一次增量备份】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i[oracle@source]$ scp `cat incrbackups.txt` oracle@dest:/stage_dest[oracle@source]$ scp xttplan.txt oracle@dest:/home/oracle/xtt[oracle@source]$ scp tsbkupmap.txt oracle@dest:/home/oracle/xtt  【目标端最后一次恢复】[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r【元数据的恢复】[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -ecat  xttplugin.txtoracle@dest]$ impdp directory=DATA_PUMP_DIR logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=TS1,TS2 transport_datafiles='+DATA/prod/datafile/ts1.285.771686721', '+DATA/prod/datafile/ts2.286.771686723', '+DATA/prod/datafile/ts2.287.771686743'    system@dest/prod SQL> alter tablespace TS1 read write;    【传输数据的验证】  RMAN> validate tablespace TS1, TS2 check logical;

RMAN备份的方法:
2.Using Recovery Manager (RMAN) RMAN backup (using xttdriver.pl -p and -c options)   【解压缩软件】 unzip rman-xttconvert_2.0.zip 修改参数文件 xtt.properties 内容   创建参数文件中需要的文件夹  【源端准备】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -p该操作将在dfcopydir路径下生成需要传输的数据文件的副本,和在 TMPDIR目标下面产生xttplan.txt、rmanconvert.cmd两个文件需要注意。  其中xttplan.txt记录了当前数据库的SCN,如果后面再次运行脚本进行增量操作(perl  xttdriver.pl  -s)时,会产生新的文件xttplan.txt.new 来记录增量备份scn。  rmanconvert.cmd文件则是rman convert脚本,用来转换数据文件的字节序,该脚本需要传输到目标端使用。需要注意的是,在2.0版本工具中,对convert操作增加了并行参数parallelism,一般设置为6或者8,根据CPU或者IO压力负载而定。[oracle@dest]$ scp oracle@source:/home/oracle/xtt/rmanconvert.cmd /home/oracle/xtt  将dfcopydir路径下生成的数据文件副本和这两个文件 rmanconvert.cmd  、xttplan.txt 传输到目标主机上。 【目标端转换文件copy到对应数据文件目录】[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -c这个步骤将按照rmanconvert.cmd里面记录的信息对数据文件进行转换,以满足目标主机的字节序格式。同时会将这些文件存放到storageondest参数指定的目录,转换完成后,到相应的目录检查数据文件是否存在。【传输表空间的增量备份】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i    注意生成文件tsbkupmap.txt  incrbackups.txt,xttplan.txt.new并传输到目标端    需要注意的是,如果此处报错,那么会在rmanxtts的路径下产生一个FAIL*文件,再次运行前需要删除这个文件,否则无法运行。[oracle@source]$ scp `cat incrbackups.txt` oracle@dest:/stage_dest[oracle@dest]$ scp oracle@source:/home/oracle/xtt/xttplan.txt.new  /home/oracle/xtt[oracle@dest]$ scp oracle@source:/home/oracle/xtt/tsbkupmap.txt /home/oracle/xtt注意:这里传递增量数据信息的时候,还需要将源端xtts目录下的xttplan.txt.new, incrbackups.txt 以及tsbkupmap.txt文件都传输到目标端。每当你进行一次增量的备份操作,这2个文件的内容都会发现变化。每一次增量操作之后,都需要将这2个文件传到目标端数据库的xtts目录中。对于一个比较大量的系统来讲,上述的增量操作,我们可以进行多次。假设我们进行了多次操作之后,在停机时间的时候,再将源端数据库中需要传输的表空间设置为只读模式,如下:   【目标端增量备份应用到数据文件】[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r 【源端scn的推进】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s该命令将修改from_scn,用于确定下一次增量备份的起点,建议在目标端每次做完一次recover后,源端就执行一次该命令,避免遗忘  【最后一次增量备份前,置表空间read only】system@source/prod SQL> alter tablespace TS1 read only;【源端最后一次增量备份】[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i[oracle@source]$ scp `cat incrbackups.txt` oracle@dest:/stage_dest[oracle@source]$ scp xttplan.txt oracle@dest:/home/oracle/xtt[oracle@source]$ scp tsbkupmap.txt oracle@dest:/home/oracle/xtt   【目标端最后一次恢复】[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r 在执行恢复操作后,脚本会自动将目标端数据库重启,不需要认为干预,如果出现到mount状态的异常,可以根据情况手工执行后续命令或者执行此命令,在起一个实例到nomount状态下,进行执行   【元数据的恢复】[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -e  cat  xttplugin.txt #因为之前没有设置dstdir,srclink参数,所以此处产生的导入脚本需要手动加上dblink和directory的名称  create  directory destdir as '/backup';     create public database link tts connect to scott identified by  tiger using '';[oracle@dest]$ impdp directory=DATA_PUMP_DIR logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=TS1,TS2 transport_datafiles='+DATA/prod/datafile/ts1.285.771686721', '+DATA/prod/datafile/ts2.286.771686723', '+DATA/prod/datafile/ts2.287.771686743'     注意在导出时,transport_tablespaces 参数需要的表空间要写全,不能遗漏     在目标端进行impdp时候,transport_datafiles 需要将所有的数据文件都添加进去     如果数据文件很多的时候,认为添加比较容易出错误,一般时候用perl xttdriver.pl -e生成system@dest/prod SQL> alter tablespace TS1 read write; system@source/prod SQL> alter tablespace TS1 read write;       到此迁移步骤完成 【传输数据的验证】RMAN> validate tablespace TS1, TS2 check logical;



增量备份提速方法:alter  database enable block chenage tracking using file '/oradata/oracle_chane.trc';select status ,filename from v$block_change_tracking;增量备份的目的是备份哪些自上次备份以来发生过改变的block。然后即使有一些不法发生变化,incremental backup 也要读取完整的数据文件。 block change tracking file 文件中,记录所有的数据库中变的物理位置。启动block change tracking功能后,level 0 级别的增量备份依然要扫描整个数据文件,因为 change tracking file 还没有映射到block的状态,对于后续级别的incremental backups,rman 使用change tracking data 决定 哪些需要读取。通过消除对整个数据文件的read,提升性能。RMAN> configure device type disk  parallelism 8;每个 表空间对应8个分片排序分组发送第一次导入(索引、约束、对象信息)impdp directory=destdir  logfile=tts.log network_link=ttslink transport_fill_check=yes transport_tablsepaces=test transport_datafiles='test.dbf' exclude=statistics第二次导入(统计信息)impdp directory=destdir  logfile=tts.log network_link=ttslink schemas=test  content=metadata_only exclude=index,table,constraint parallel =8将过程,视图,包,触发器,统计信息导入,开启并行


0 0
原创粉丝点击