How to Create Transportable Tablespaces Where the Source and Destination are ASM-Based (Doc ID 394798.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.1.0.2 to 11.2.0.3 [Release 10.1 to 11.2]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
***Checked for relevance on 28-May-2010***

GOAL

The purpose of this note is to describe the method to create transportable tablespaces(TTS) where the source and destination databases are ASM-based. This method uses standard utilities such as; DataPump and the database package dbms_file_transfer. The dbms_file_transfer package will be used to transfer the Datapump metadata and datafiles to the remote database server.

本说明的目的是描述在源数据库和目标数据库均基于ASM的情况下创建可传输表空间(TTS)的方法。此方法使用标准实用程序,例如;DataPump 和数据库包 dbms_file_transfer。dbms_file_transfer 软件包将用于将Datapump元数据和数据文件传输到远程数据库服务器。

This note will illustrate a working example of creating and plugging in transportable tablespaces. In the example two servers, host1 and host2 are in different locations, with each one on an independent Hitachi storage array. Server host1 is the source database  and will house database named db1. The server host2, which is deemed the target server and will subscribe to the transportable tables, will house the database called db2.

本文将说明创建和插入传输表空间的工作示例。在示例中,两台服务器host1和host2位于不同的位置,每台服务器都位于一个独立的 Hitachi 存储阵列上。服务器host1是源数据库,并将包含名为db1的数据库。服务器host2被视为目标服务器,并将订阅可移动表,该服务器将容纳名为db2的数据库。

SOLUTION

If the platform of the source and target nodes are different with different endianess, then refer to Note 371556.1

如果源节点和目标节点的平台具有不同的字节序,则请参见Note 371556.1

This note will illustrate a working example of creating and plugging in transportable tablespaces. In the example two servers, host1 and host2 are in different locations, with each one on an independent Hitachi storage array. Server host1 is the source database and will house database named db1. The server host2, which is deemed the target server and will subscribe to the transportable tables, will house the database called db2.

本文将说明创建和插入传输表空间的工作示例。在示例中,两台服务器host1和host2位于不同的位置,每台服务器都位于一个独立的 Hitachi 存储阵列上。服务器host1是源数据库,并将包含名为db1的数据库。服务器host2被视为目标服务器,并将订阅可移动表,该服务器将容纳名为db2的数据库。

TTS Implementation illustration  TTS实施说明

Preliminary effort to setup TTS  初步设置TTS

1. Create or use two existing tablespaces on the source database. Although having two tablespaces is not necessary, it was merely shown here to exercise object dependency. Note that OMF is being employed in this illustration, thus please set the init.ora parameter DB_CREATE_FILE_DEST to the appropriate disk group name.

在源数据库上创建或使用两个现有表空间。尽管没有必要具有两个表空间,但此处仅显示了行使对象依赖性。注意,在此示例中使用了OMF,因此,请将init.ora参数DB_CREATE_FILE_DEST设置为适当的磁盘组名称。

SQL> show parameter db_create_file_dest

NAME                   TYPE        VALUE
---------------------- ----------- ------------------------------
db_create_file_dest string +DATA SQL> create tablespace tts_1; SQL> create tablespace tts_2;

2. Create a table in TTS_1 and an index in TTS_2 to ensure the tablespaces have object dependencies:
在TTS_1中创建一个表,并在TTS_2中创建一个索引,以确保表空间具有对象依赖性

SQL> connect scott/tiger
Connected.
SQL> create table emp_copy tablespace tts_1 as select * from emp; Select count(*) from emp_copy;
10 rows returned SQL> create index emp_copy_i on emp_copy (empno)
2 tablespace tts_2;

3. Check to make sure that you have a self contained transportable set. Oracle provides a PLSQL package that aids in this check.
检查并确保您拥有一个独立的可运输套件。Oracle提供了一个PLSQL软件包来帮助进行此检查

SQL> EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK(tts_1,tts_2, TRUE);

Then query the TRANSPORT_SET_VIOLATIONS view, to see if any dependency violations exist.
然后查询TRANSPORT_SET_VIOLATIONS视图,以查看是否存在任何依赖关系违规。

SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS;
No rows returned

4. Create a new Service names entry, which will point to the destination database where the tablespaces will be transported. For example, add the following lines to tnsnames.ora:
创建一个新的 Service names 条目,该条目指向将在其中传输表空间的目标数据库。例如,将以下行添加到tnsnames.ora:

DB2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = host2.us.oracle.com)
(INSTANCE_NAME = db2)
)
)

5. As SYSTEM, create a database link between the two databases. This is needed because we will be using the DBMS_FILE_TRANSFER package to move metadata between the two databases.
作为SYSTEM,在两个数据库之间创建 database link。这是必需的,因为我们将使用 DBMS_FILE_TRANSFER 包在两个数据库之间移动元数据

SQL> create database link db2 connect to system identified by manager1 using 'db2';

5. Create a directory object in the source database db1, to hold the dumpfile. Since we are using ASM, this needs to be an ASM object:
在源数据库db1中创建一个目录对象,以保存dump文件。由于我们使用的是ASM,因此它必须是一个ASM对象
make sure the directory path ends with an '  '  确保目录路径以''

SQL> create directory tts_dump as '+DATA';

6. Create another directory object in the source database, which points to an operating system path, for the log file:
在源数据库中为日志文件创建另一个指向操作系统路径的目录对象:

SQL> create directory tts_dump_log as '/export/home/tts_log';

7. Create a directory object in the source database that points to the datafiles.
在源数据库中创建一个指向数据文件的目录对象。

SQL> create directory tts_datafile as '+DATA/db1/datafile';

8. Grant read/write access to the user you will perform the export as (only needed if using a non-privileged user):
授予对您将要执行导出的用户的读/写访问权限(仅在使用非特权用户时才需要)

SQL> grant read, write on directory tts_dump to system;
SQL> grant read, write on directory tts_dump_log to system;
SQL> grant read, write on directory tts_dump_datafile to system;

9. Repeat the last four steps (5-8) on the target database db2, as well.
.同样,对目标数据库db2重复最后四个步骤(5-8)
10. Make all tablespaces in the transportable set, to read-only.
将可移动集中的所有表空间设置为只读。

SQL> ALTER TABLESPACE tts_1 READ ONLY;
SQL> ALTER TABLESPACE tts_2 READ ONLY;

11. Check the status of the tablespaces on the source database
检查源数据库上表空间的状态

SQL> select tablespace_name, status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS ONLINE
UNDOTBS2 ONLINE
TTS_1 READ ONLY
TTS_2 READ ONLY

Export metadata  导出元数据
12. Export the metadata for the two tablespaces  导出两个表空间的元数据

[ora10g@host1]$ expdp system/manager1 directory=tts_dump dumpfile=tts1_db1.dmp logfile=tts_dump_log:tts.log
transport_tablespaces=tts_1,tts_2 transport_full_check=y Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_02": system/******** directory=tts_datafile dumpfile=tts1.dmp logfile=tts_dump_log:tts.log transport
_tablespaces=tts_1,tts_2 transport_full_check=y
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_02" successfully loaded/unloaded
***********************************************************************Dump file set for SYSTEM.SYS_EXPORT_TRANSPORTABLE_02 is:
+DATA/tts1.dmp
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_02" successfully completed at 14:00:34

Movement of data and Enabling TTS  数据移动并启用TTS

--After the metadata export, we can revert back the table in read write mode 元数据导出后,我们可以以读写模式还原表

13. Use DBMS_FILE_TRANSFER to send the dump file across to the target
使用 DBMS_FILE_TRANSFER 将转储文件发送到目标

[ora10g@host1]$ sqlplus system/manger1
SQL> begin
2 dbms_file_transfer.put_file
3 (source_directory_object => 'tts_dump',
4 source_file_name => 'tts1_db1.dmp',
5 destination_directory_object => 'tts_dump',
6 destination_file_name => 'tts1_db1.dmp',
7 destination_database => 'db2');
8 end;
9 /

14. Check the file names on the source database for the two tablespaces being transported.
检查源数据库上正在传输的两个表空间的文件名

SQL> SELECT file_name FROM dba_data_files
2 WHERE tablespace_name LIKE 'TTS%'; FILE_NAME
-------------------------------------------------
+DATA/db2/datafile/tts_1.294.590721319
+DATA/db2/datafile/tts_2.295.586721335

15. Transfer the two datafiles to the target database using DBMS_FILE_TRANSFER.
使用DBMS_FILE_TRANSFER将两个数据文件传输到目标数据库。
TTS1 datafile

SQL> begin
2 dbms_file_transfer.put_file
3 (source_directory_object => 'tts_datafile',
4 source_file_name => 'tts_1.294.570721319',
5 destination_directory_object => ' tts_datafile',
6 destination_file_name => 'tts1_db1.dbf',
7 destination_database => 'db2');
8 end;
9 /

TTS2 datafile

SQL> begin
2 dbms_file_transfer.put_file
3 (source_directory_object => 'tts_datafile',
4 source_file_name => 'tts_2.295.586721335',
5 destination_directory_object => 'tts_datafile',
6 destination_file_name => 'tts2_db1.dbf',
7 destination_database => 'db2');
8 end;
9 /

16. On the host2 (target server) import the datafile metadata using DataPump.
在host2(目标服务器)上,使用DataPump导入数据文件元数据
imp.par has the following contents:  imp.par具有以下内容

directory=tts_dump
dumpfile=tts1_db1.dmp
logfile=tts_dump_log:tts1.log
TRANSPORT_DATAFILES='+DATA1/tts1_db1.dbf','+DATA1/tts2_db1.dbf'
keep_master=y

Note, for the TRANSPORT_DATAFILES parameter, you can either use the alias names (files names in the dbms_file_transfer), or use the systems generated names generated by DBMS_FILE_TRANSFER (these start with the name 'File_Transfer.xxxx.xxxxxx'). To determine the name system generated names, use the asmcmd line tool by simply doing a 'cd +DATA/db2/datafile', followed by the 'ls -l' command.
注意,对于 TRANSPORT_DATAFILES 参数,可以使用别名(dbms_file_transfer 中的文件名),也可以使用由 DBMS_FILE_TRANSFER 生成的系统生成的名称(这些名称以'File_Transfer.xxxx.xxxxxx'开头)。 要确定系统生成的名称,请使用asmcmd行工具,只需执行'cd +DATA/db2/datafile',然后执行'ls -l'命令即可。

[ora10g@host2]$ impdp system/oracle parfile=imp.par

Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03": system/******** parfile=impdp.par
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03" successfully completed at 15:05:00

17. Switch the tablespaces back to read-write mode.  将表空间切换回读写模式

SQL> ALTER TABLESPACE tts_1 READ WRITE;
SQL> ALTER TABLESPACE tts_2 READ WRITE;

18. Verify that the datafiles are successfully plugged in.  验证是否成功插入

SQL> select name from v$datafile;

NAME
--------------------------------------------------
+DATA/db2/datafile/system.271.599658207
+DATA/db2/datafile/undotbs1.268.599658207
+DATA/db2/datafile/sysaux.270.599658207
+DATA/db2/datafile/users.267.599658209
+DATA/db2/datafile/example.262.599658459
+DATA/db2/datafile/tts2_db1.dbf
+DATA/db2/datafile/tts1_db1.dbf

19. Validate the data got there by selecting the required tables.
通过选择所需的表来验证那里的数据

SQL> create table emp_copy tablespace tts_1 as select * from emp;
SQL> Select count(*) from emp_copy;
10 rows returned

-----

NOTE: Similar procedure is applicable for filesystem to ASM and viceversa 
注意:类似的过程适用于ASM到文件系统,反之亦然


REFERENCES

NOTE:371556.1 - How to Migrate to different Endian Platform Using Transportable Tablespaces With RMAN

How to Create Transportable Tablespaces Where the Source and Destination are ASM-Based (Doc ID 394798.1)的更多相关文章

  1. XTTS Creates Alias on Destination when Source and Destination use ASM (Doc ID 2351123.1)

    XTTS Creates Alias on Destination when Source and Destination use ASM (Doc ID 2351123.1) APPLIES TO: ...

  2. 10g+: Transportable Tablespaces Across Different Platforms (Doc ID 243304.1)

    10g+: Transportable Tablespaces Across Different Platforms (Doc ID 243304.1) APPLIES TO: Oracle Data ...

  3. Master Note for Transportable Tablespaces (TTS) -- Common Questions and Issues (Doc ID 1166564.1)

    APPLIES TO: Oracle Database Cloud Exadata Service - Version N/A and laterOracle Database Cloud Servi ...

  4. V4 Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 2471245.1)

    V4 Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 2471245. ...

  5. Updated: EBS 12.1 + Transportable Tablespaces with Incremental Backup Option

    Database migration across platforms of different "endian" (byte ordering) formats using th ...

  6. 如何使用 TRANSPORTABLE = ALWAYS 将PDB移回Non-CDB (Doc ID 2027352.1)

    How to Move a PDB Back to a Non-CDB Using TRANSPORTABLE=ALWAYS (Doc ID 2027352.1) APPLIES TO: Oracle ...

  7. Transportable tablespace on standby (Doc ID 788176.1)

    APPLIES TO: Oracle Database - Enterprise Edition - Version 10.2.0.1 to 10.2.0.4 [Release 10.2]Oracle ...

  8. ODA: After Apply ODA 12.2.1.2.0 Patch, Unable to Create TableSpace Due to [ORA-15001: diskgroup "DATA" does not exist or is not mounted | ORA-15040: diskgroup is incomplete] (Doc ID 2375553.1)

    ODA: After Apply ODA 12.2.1.2.0 Patch, Unable to Create TableSpace Due to [ORA-15001: diskgroup &quo ...

  9. R12: How to add Microsoft Excel as Type to the Create Template List of Values in BI Publisher (Doc ID 1343225.1)

    Modified: 27-Oct-2013 Type: HOWTO In this Document Goal Solution References APPLIES TO: BI Publisher ...

随机推荐

  1. NIM游戏,NIM游戏变形,威佐夫博弈以及巴什博奕总结

    NIM游戏,NIM游戏变形,威佐夫博弈以及巴什博奕总结 经典NIM游戏: 一共有N堆石子,编号1..n,第i堆中有个a[i]个石子. 每一次操作Alice和Bob可以从任意一堆石子中取出任意数量的石子 ...

  2. CoderForces-913D

    You are preparing for an exam on scheduling theory. The exam will last for exactly Tmilliseconds and ...

  3. 如何打造个人km知识管理系统

    经常有朋友会遇到这样一种情况,在网络中看到一篇很好的文章,但后来因为关键字想不起来,结果怎么都搜索不到.还有些朋友虽然平时也会做一些记录,把有用的资料进行保存,但他们往往将保存的资料分散在不同的地方, ...

  4. tensorflow word2vec详解

    maybe_download 下载text8.zip.可以手工下载下来.然后指定text8.zip的路径. read_data 解压text8.zip,把数据读入到data中. data是一个长数组, ...

  5. unity3d 柏林噪声 PerlinNoise 规律 算法

    测试 每个小数值取100次 print(0.1); LaTest3(0.1f, 0.1f); print("Max:" + La.Max() + "|Min:" ...

  6. 浅析Java堆,栈,方法区

    栈(Stack) 1.栈是线程私有的,其生命周期和线程相同. 2.每个方法在执行的时候都会开辟一个栈区,同时创建一个栈帧(Stack Frame). 3.栈帧用于存储局部变量表,操作数栈,动态链接和方 ...

  7. Mybatis需要注意的细节

    mybatis第二篇 1.${}和#{}的区别 1.#在传参的时候,会自动拼接单引号:$不能拼接单引号; 2.$传参时,一般不支持jdbcType指定类型的写法;#则可以;如: ​ #{name,jd ...

  8. Docker swarm实战总结

    一.简介 Swarm 是 Docker 官方提供的一款集群管理工具,其主要作用是把若干台 Docker 主机抽象为一个整体,并且通过一个入口统一管理这些 Docker 主机上的各种 Docker 资源 ...

  9. Springboot静态页面放在static路径下还是访问不到

    一种最常见的问题,静态资源放在默认的目录,如:resources/static或resources/templates 访问静态资源的时候,路径不应带上默认目录,因为springboot默认从这些目录 ...

  10. Django forms组件与钩子函数

    目录 一.多对多的三种创建方式 1. 全自动 2. 纯手撸(了解) 3. 半自动(强烈推荐) 二.forms组件 1. 如何使用forms组件 2. 使用forms组件校验数据 3. 使用forms组 ...