<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; xtts迁移</title>
	<atom:link href="https://www.xifenfei.com/tag/xtts%e8%bf%81%e7%a7%bb/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Sat, 07 Nov 2026 15:45:44 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>XTTS实战分享</title>
		<link>https://www.xifenfei.com/2017/11/xtts.html</link>
		<comments>https://www.xifenfei.com/2017/11/xtts.html#comments</comments>
		<pubDate>Sun, 19 Nov 2017 05:38:38 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[hp linux数据迁移]]></category>
		<category><![CDATA[xtts]]></category>
		<category><![CDATA[xtts迁移]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=7241</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2017/11/xtts.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2017/11/xtts.html" target="_blank">XTTS实战分享</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p><strong>迁移目标</strong><br />
源库:hp-unix RAC 裸设备 10.2.0.5<br />
目标库：Linux RAC ASM  11.2.0.4<br />
停机时间:8小时<br />
数据量:16T<br />
<br />
<strong>迁移方法</strong><br />
使用基于rman备份的xtts实现(因为使用裸设备，无法使用dbms_file_transfer方法实现)<br />
<br />
<strong>迁移步骤</strong><br />
<em>1)迁移之前检查</em></p>
<pre class="brush: sql; title: ; notranslate">
--查询无效对象
select owner, object_name, object_type from dba_objects 
where status !='VALID' order by owner, object_type, object_name;

--检查无效index
select owner, index_name, status from dba_indexes 
where status='UNUSABLE' order by 1,2;

select i.owner, i.index_name, p.partition_name, p.status 
from dba_ind_partitions p,dba_indexes i 
where p.index_name=i.index_name and p.status='UNUSABLE'
order by 1,2,3;

select i.owner,i.index_name,s.subpartition_name,s.status from 
dba_ind_subpartitions s,dba_indexes i where 
s.index_name=i.index_name and s.status='UNUSABLE'
order by 1,2,3;

--compatible Advanced Queues检查
select owner,queue_table,recipients,compatible from dba_queue_tables
where recipients='MULTIPLE' and compatible like '%8.0%';

--基于XMLSchema的XMLType对象检查
SELECT distinct OWNER FROM DBA_XML_SCHEMAS;

select distinct p.tablespace_name
from dba_tablespaces p, dba_xml_tables x, dba_users u, all_all_tables t
where t.table_name=x.table_name and
      t.tablespace_name=p.tablespace_name and
      x.owner=u.username;

--SPATIAL空间组件对象检查
select owner,index_name from dba_indexes
where ityp_name = 'SPATIAL_INDEX';


select owner, table_name, column_name
from dba_tab_columns
where data_type = 'SDO_GEOMETRY'
and owner != 'MDSYS'
order by 1,2,3;

--外部表检查
select distinct owner from DBA_EXTERNAL_TABLES;

--IOT表检查
select distinct owner from dba_tables where IOT_TYPE is not null;

--检查临时表
SELECT owner,table_name FROM DBA_TABLES WHERE 
TEMPORARY='Y' AND OWNER IN(用户列表);

--物化视图检查
select owner,count(*) from dba_mviews group by owner;

--检查永久表空间
select t.TABLESPACE_NAME TABLESPACE_NAME,count(f.FILE_ID),
sum(f.bytes/1024/1024/1024) GB
FROM dba_tablespaces t, dba_data_files f
where t.TABLESPACE_NAME=f.TABLESPACE_NAME
	and t.tablespace_name not in (根据需求排除)
	and t.contents = 'PERMANENT'
group by t.TABLESPACE_NAME
order by 2;


--检查命令进行自包含检查
EXEC sys.dbms_tts.transport_set_check('需要迁移的表空间列表',TRUE);

select * from transport_set_violations;

--回收站检查
select count(*) from dba_recyclebin;
Purge dba_recyclebin;

--检查是否存在应用户使用TSTZ 字段
select c.owner || '.' || c.table_name || '(' || c.column_name || ') -'
    || c.data_type || ' ' col
  from dba_tab_cols c, dba_objects o
 where c.data_type like '%WITH TIME ZONE'
    and c.owner=o.owner
   and c.table_name = o.object_name
   and o.object_type = 'TABLE' 
order by col;

--检查表空间是否加密
select tablespace_name,ENCRYPTED from dba_tablespaces;

--检查是否存在加密字段
select * from DBA_ENCRYPTED_COLUMNS;

--检查Opaque Types类型字段
select distinct owner ,DATA_TYPE from dba_tab_columns where
 owner in (需要迁移用户列表);

--检查表空间和数据文件状态
select tablespace_name,status from dba_tablespaces;

select STATUS,ONLINE_STATUS,count(*) from dba_data_files 
group by STATUS,ONLINE_STATUS;

--比对新旧环境profile是否一致
select distinct(t.pro) from
(select s.profile pro, l.profile pro2
from dba_profiles@XTTS_DBLINK s, dba_profiles l
where s.profile = l.profile(+)) t where t.pro2 is null
order by t.pro;
</pre>
<p><em>2)迁移之前新库创建</em><br />
其他类似profile,不需要xtts迁移的东西，均可以创建</p>
<pre class="brush: sql; title: ; notranslate">
--在新环境中比对并创建角色
select 'create role '||role ||';' from dba_roles@XTTS_DBLINK 
minus
select 'create role '||role ||';' from dba_roles;

--在新环境中比对并创建用户 
select 'create user &quot;'||a.username ||'&quot; identified by values '''||b.password||
 ''' default tablespace USERS '|| 'temporary tablespace '||
 a.TEMPORARY_TABLESPACE||';'
from dba_users@XTTS_DBLINK a,sys.user$@XTTS_DBLINK b,
dba_users c,sys.user$   d
where a.username=b.name  and
a.username=d.name(+)
and a.username = c.username(+) and c.username is null
order by a.username;
</pre>
<p><em>3)停业务之前xtts迁移操作</em><br />
源库<br />
备注:由于源库的perl的版本不能满足需求，下载新的perl版本</p>
<pre class="brush: bash; title: ; notranslate">
--xtt.properties文件编辑
tablespaces=需要迁移表空间列表
platformid=4
dfcopydir=/backup/temp1/rmanback
backupformat=/backup/temp1/rmanback
stageondest=/temp1/rmanback
storageondest=+DATA/xifenfei/datafile
backupondest=/temp3/covntemp
parallel=16
rollparallel=16
getfileparallel=16

--xtts全备发起
cat /home/oracle/xttsscript/full_backup.sh

export TMPDIR=/home/oracle/tmpxtts
cd /home/oracle/xtts
export ORACLE_SID=xifenfei2
/home/oracle/perl/bin/perl xttdriver.pl -p -d

nohup /home/oracle/xttsscript/full_backup.sh &gt; /home/oracle/xttsscript/full_backup.log &amp;

--完成之后拷贝rmanconvert.cmd到共享目录
cp  /home/oracle/tmpxtts/rmanconvert.cmd  /backup/temp1/tempfile/
</pre>
<p>目标库</p>
<pre class="brush: bash; title: ; notranslate">
--拷贝源库的rmanconvert.cmd到目标库
cp /temp1/tempfile/rmanconvert.cmd /home/oracle/tmpxtts/

--目标库启动到mount
shutdown immediate;
startup mount

--xtts转换数据文件
cd /home/oracle/xttsscript/
cat &gt; /home/oracle/xttsscript/full_restore.sh

export TMPDIR=/home/oracle/tmpxtts
export ORACLE_SID=xifenfei2
cd /home/oracle/xtts
$ORACLE_HOME/perl/bin/perl xttdriver.pl -c -d

chmod +x /home/oracle/xttsscript/full_restore.sh
nohup /home/oracle/xttsscript/full_restore.sh &gt; /home/oracle/xttsscript/full_restore.log &amp;
</pre>
<p>源库第一次增量备份</p>
<pre class="brush: bash; title: ; notranslate">
cd /home/oracle/xttsscript
cat /home/oracle/xttsscript/incre_backup.sh

export XTTDEBUG=1
export TMPDIR=/home/oracle/tmpxtts
cd /home/oracle/xtts
export ORACLE_SID=xifenfei2
/home/oracle/perl/bin/perl xttdriver.pl -i -d

nohup /home/oracle/xttsscript/incre_backup.sh &gt; /home/oracle/xttsscript/incre_backup1.log &amp;

--拷贝文件到共享目录
cp /home/oracle/tmpxtts/xttplan.txt /backup/temp1/tempfile/
cp /home/oracle/tmpxtts/tsbkupmap.txt /backup/temp1/tempfile/
</pre>
<p>目标库第一次增量恢复</p>
<pre class="brush: bash; title: ; notranslate">
--拷贝共享目录文件
cp /temp1/tempfile/xttplan.txt /home/oracle/tmpxtts/xttplan.txt
cp /temp1/tempfile/tsbkupmap.txt /home/oracle/tmpxtts/tsbkupmap.txt

--xtts增量还原
cd /home/oracle/xttsscript
cat  /home/oracle/xttsscript/ince_restore.sh

export XTTDEBUG=1
export TMPDIR=/home/oracle/tmpxtts
export ORACLE_SID=xifenfei1
cd /home/oracle/xtts
$ORACLE_HOME/perl/bin/perl xttdriver.pl -r -d

nohup /home/oracle/xttsscript/ince_restore.sh &gt; /home/oracle/xttsscript/ince_restore1.log &amp;
</pre>
<p>源端更新scn</p>
<pre class="brush: bash; title: ; notranslate">
cd /home/oracle/xttsscript/
cat /home/oracle/xttsscript/getscn.sh

export XTTDEBUG=1
export TMPDIR=/home/oracle/tmpxtts
cd /home/oracle/xtts
export ORACLE_SID=xifenfei2
date
/home/oracle/perl/bin/perl xttdriver.pl -s -d

nohup /home/oracle/xttsscript/getscn.sh &gt;&gt; /home/oracle/xttsscript/getscn.log &amp;
</pre>
<p>在停业务之前，依次进行上面三步的增量备份,恢复,更新scn,一直持续到最后停业务，表空间只读。<br />
<em>4)正式停业务后xtts操作</em><br />
原库</p>
<pre class="brush: bash; title: ; notranslate">
--设置表空间只读
select 'alter tablespace '||t.TABLESPACE_NAME||' read only;'
FROM dba_tablespaces t, dba_data_files f
where t.TABLESPACE_NAME=f.TABLESPACE_NAME
	and t.tablespace_name not in (选择排除的表空间)
	and t.contents = 'PERMANENT'
group by t.TABLESPACE_NAME
order by count(f.FILE_ID);

--xtts增量备份
cd /home/oracle/xttsscript
nohup /home/oracle/xttsscript/incre_backup.sh &gt; /home/oracle/xttsscript/incre_backup_end.log &amp;

--拷贝文件到共享目录
cp /home/oracle/tmpxtts/xttplan.txt /backup/temp1/tempfile/
cp /home/oracle/tmpxtts/tsbkupmap.txt /backup/temp1/tempfile/
</pre>
<p>目标库</p>
<pre class="brush: bash; title: ; notranslate">
--拷贝共享目录文件
cp /temp1/tempfile/xttplan.txt /home/oracle/tmpxtts/xttplan.txt
cp /temp1/tempfile/tsbkupmap.txt /home/oracle/tmpxtts/tsbkupmap.txt

cd /home/oracle/xttsscript
nohup /home/oracle/xttsscript/ince_restore.sh &gt; /home/oracle/xttsscript/ince_restore_end.log &amp;
</pre>
<p><em>5)元数据迁移</em></p>
<pre class="brush: bash; title: ; notranslate">
--源库(导出表空间和用户元数据)
nohup expdp &quot;'/ as sysdba'&quot; parfile=/archive2/dmpdir/expdp_xtts_tbs_metadata.par &amp;

nohup expdp &quot;'/ as sysdba'&quot; parfile=/archive2/dmpdir/expdp_xtts_users_metadata.par &amp;

--目标库(导入表空间和用户元数据)
nohup impdp &quot;'/ as sysdba'&quot;  parfile=/temp3/dmpdir/impdp_xtts_tbs_metadata.par &amp;

nohup impdp &quot;'/ as sysdba'&quot; parfile=/temp3/dmpdir/impdp_xtts_users_metadata.par &amp;

</pre>
<p><em>6)后续操作</em></p>
<pre class="brush: sql; title: ; notranslate">
--设置表空间读写
select 'alter tablespace '||t.TABLESPACE_NAME||' read write;'
FROM dba_tablespaces t, dba_data_files f
where t.TABLESPACE_NAME=f.TABLESPACE_NAME
	and t.tablespace_name not in (排除表空间列表)
	and t.contents = 'PERMANENT'
group by t.TABLESPACE_NAME
order by count(f.FILE_ID);

--编译无效对象
@?/rdbms/admin/utlprp.sql 32

--对比无效对象
select r.owner, r.object_type, r.remote_cnt Source_Cnt, l.local_cnt Target_Cnt
from ( select owner, object_type, count(owner) remote_cnt
from dba_objects@XTTS_DBLINK
where owner not in
(select name
from system.logstdby$skip_support
where action=0) group by owner, object_type ) r
, ( select owner, object_type, count(owner) local_cnt
from dba_objects
where owner not in
(select name
from system.logstdby$skip_support
where action=0) group by owner, object_type ) l
where l.owner (+) = r.owner
and l.object_type (+) = r.object_type 
and nvl(l.local_cnt,-1) != r.remote_cnt
order by 1, 3 desc;

--对比sequence大小
select * from(
select a.SEQUENCE_OWNER,a.sequence_name,a.last_number prod_number, 
b.last_number dr_number,(b.last_number - a.last_number) gap_than_zero
 from dba_sequences@XTTS_DBLINK a,dba_sequences b
  where a.sequence_owner not in 
 ('SYS','SYSTEM','XDB','WMSYS','TSMSYS','SYSMAN','PRECISE1',
'ORDSYS','OUTLN','OLAPSYS','ORDPLUGINS','MDSYS','EXFSYS',
'DMSYS','DSG','DBSNMP','PRECISE2','SI_INFORMTN_SCHEMA','SPA','TSMSYS','PUBLIC','GOLDENGATE',
'ORDDATA','PRECISE4','PRECISE3','CTXSYS','SCOTT','PERFSTAT')
and a.sequence_owner=b.sequence_owner (+)
and a.sequence_name=b.sequence_name(+)
 order by 5,1,2 desc) where gap_than_zero &lt; 0 ;

--检查无效index
select owner, index_name, status from dba_indexes 
where status='UNUSABLE' order by 1,2;

select i.owner, i.index_name, p.partition_name, p.status 
from dba_ind_partitions p,dba_indexes i 
where p.index_name=i.index_name and p.status='UNUSABLE'
order by 1,2,3;

select i.owner,i.index_name,s.subpartition_name,s.status from 
dba_ind_subpartitions s,dba_indexes i where 
s.index_name=i.index_name and s.status='UNUSABLE'
order by 1,2,3;

--创建迁移之前删除的物化视图,index,临时表等
</pre>
<p>由于xtts迁移是一种物理方法结合逻辑方法的迁移,本身是一个复杂的过程,这里只是列举出来了主要的操作过程和步骤,可能涉及很多细节工作需要考虑比如public对象，统计信息，dblink，权限等所有逻辑迁移中需要注意的问题,在这里易于需要注意,另外还要关注xtts本身物理转换所带来的各种bug.<br />
特别感谢Lunar,Oracle的Gary Zhou,存储的黄长老等所有朋友的帮助和支持</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/ora-1502%e9%97%ae%e9%a2%98%e5%88%86%e6%9e%90%e8%a7%a3%e5%86%b3.html" rel="bookmark" class="crp_title">ORA-1502问题分析解决</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2010/10/oracle%e6%9f%a5%e7%9c%8bobject%e5%af%b9%e8%b1%a1%e4%bd%bf%e7%94%a8%e7%a9%ba%e9%97%b4.html" rel="bookmark" class="crp_title">oracle查看object对象使用空间</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/some-indexes-or-index-subpartitions-of-table-vas-tab_pub_calllog-have-been-marked-unusable.html" rel="bookmark" class="crp_title">Some indexes or index [sub]partitions of table VAS.TAB_PUB_CALLLOG have been marked unusable</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/%e7%9b%91%e6%8e%a7index%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9.html" rel="bookmark" class="crp_title">监控Index注意事项</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/04/shell-%e5%a4%87%e4%bb%bd%e6%96%87%e4%bb%b6.html" rel="bookmark" class="crp_title">shell 备份文件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/08/opatch-auto-unable-to-get-oracle-owner-for.html" rel="bookmark" class="crp_title">opatch auto 出现unable to get oracle owner for 错误</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2010/08/oracle%e4%b9%8bdatafile%ef%bc%8ctablespace.html" rel="bookmark" class="crp_title">oracle之datafile，tablespace</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/12/%e5%85%b3%e4%ba%8eaud%e5%af%b9%e8%b1%a1%e7%9b%b8%e5%85%b3%e5%a4%84%e7%90%86.html" rel="bookmark" class="crp_title">关于aud$对象相关处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/%e6%b8%85%e7%a9%baschema%e4%b8%ad%e6%89%80%e6%9c%89%e8%a1%a8%e7%9a%84comment%e4%bf%a1%e6%81%af.html" rel="bookmark" class="crp_title">清空schema中所有表的comment信息</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/01/shell%e4%b8%ad%e6%89%a7%e8%a1%8csql%e8%af%ad%e5%8f%a5%e6%88%96%e8%80%85sql%e8%84%9a%e6%9c%ac%e6%96%87%e4%bb%b6.html" rel="bookmark" class="crp_title">shell中执行sql语句或者sql脚本文件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/vpwfile_users%e5%92%8c%e5%af%86%e7%a0%81%e6%96%87%e4%bb%b6%e5%85%b3%e7%b3%bb%e7%bb%ad.html" rel="bookmark" class="crp_title">V$PWFILE_USERS和密码文件关系(续)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/%e9%80%9a%e8%bf%87rowid%e6%89%be%e5%9b%9e%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">通过ROWID找回坏块数据</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2017/11/xtts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
