【TTS】传输表空间 Linux和AIX 之间传输数据

0    161    1

Tags:

👉 本文共约114163个字,系统预计阅读时间或需430分钟。

【TTS】传输表空间Linux asm -> AIX asm

实验部分

实验环境介绍

项目source dbtarget db
db 类型单实例单实例
db version11.2.0.311.2.0.4
db 存储ASMASM
ORACLE_SIDorclasmora2lhr
db_nameorclasmora2lhr
主机IP地址:192.168.59.3022.188.194.66
OS版本及kernel版本RHEL6.5 64位,2.6.32-504.16.2.el6.x86_64AIX 64位 7.1.0.0
OS hostnamerhel6_lhrZFXDESKDB2
platform_nameLinux x86 64-bitAIX-Based Systems (64-bit)
db time zone1414
字符集ZHS16GBKZHS16GBK
compatible11.2.0.0.011.2.0.4.0
归档模式Archive ModeArchive Mode

实验目标

要实现将自定义的应用程序表空间app1tbs,app2tbs,idxtbs从源平台传递到目标平台,而在实际的工作过程中,需要将AIX上的数据库迁移到Linux,或者将Linux上的数据库迁移到AIX上,除了exp/imp和expdp/impdp外,最常用的就是传输表空间了,若是整个库迁移的话,我们需要做的就是把业务用户和业务表空间的数据迁移过来就行,Undo、temp、system等等的就不用迁移了,整个处理过程和本文档的处理过程大同小异,需要关注的是业务对象的个数、大小、状态等。

【TTS】传输表空间 Linux和AIX 之间传输数据

实验过程

source端环境准备

【TTS】传输表空间 Linux和AIX 之间传输数据

在源库上创建3个用户应用的表空间

[oracle@rhel6_lhr ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on 星期日 1月 31 23:34:27 2016

Copyright (c) 1982, 2011, Oracle. All rights reserved.

连接到:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

23:34:27 SQL> create tablespace app1tbs datafile '+DATA' size 10m;

表空间已创建。

已用时间: 00: 00: 07.60

23:34:42 SQL> create tablespace app2tbs datafile '+DATA' size 10m;

表空间已创建。

已用时间: 00: 00: 27.25

23:35:53 SQL> create tablespace idxtbs datafile '+DATA' size 10m;

表空间已创建。

已用时间: 00: 00: 09.45

23:36:09 SQL> set line 9999 pagesize 9999

23:36:12 SQL> SELECT a.NAME, b.NAME FROM v$tablespace a , v$datafile b WHERE a.TS#=b.TS# ;

NAME NAME

----------------------- -------------------------------------------------------------------------------

SYSTEM +DATA/orclasm/datafile/system.256.850260145

SYSAUX +DATA/orclasm/datafile/sysaux.257.850260145

UNDOTBS1 +DATA/orclasm/datafile/undotbs1.258.851526539

USERS +DATA/orclasm/datafile/users.259.850260147

EXAMPLE +DATA/orclasm/datafile/example.265.850260295

APP1TBS +DATA/orclasm/datafile/app1tbs.268.902619275

APP2TBS +DATA/orclasm/datafile/app2tbs.280.902619327

TS_LHR +DATA/orclasm/datafile/ts_lhr.269.852632495

ENCRYPTED_TS +DATA/orclasm/datafile/encrypted_ts.272.854650889

GOLDENGATE +DATA/orclasm/datafile/goldengate.273.862829891

IDXTBS +DATA/orclasm/datafile/idxtbs.281.902619361

TS_LHR +DATA/orclasm/datafile/ts_lhr.284.869738273

USERS +FRA/orclasm/datafile/users.449.880121199

SYSTEM +FRA/orclasm/datafile/system.349.880121287

已选择14行。

已用时间: 00: 00: 00.80

23:36:21 SQL>

在相应的表空间创建表和索引

23:36:21 SQL> create user user_app1 identified by user_app1 default tablespace app1tbs;

用户已创建。

已用时间: 00: 00: 00.14

23:40:13 SQL> create user user_app2 identified by user_app2 default tablespace app1tbs;

用户已创建。

已用时间: 00: 00: 00.35

23:43:51 SQL> create user user_app2 identified by user_app2 default tablespace app2tbs;

用户已创建。

已用时间: 00: 00: 02.72

23:43:56 SQL> grant connect,resource to user_app1;

授权成功。

已用时间: 00: 00: 00.06

23:44:50 SQL> grant connect,resource to user_app2;

授权成功。

已用时间: 00: 00: 00.00

23:44:52 SQL> create table user_app1.app1_tab tablespace app1tbs as select * from scott.emp;

表已创建。

已用时间: 00: 00: 01.02

23:45:09 SQL> create table user_app2.app2_tab tablespace app2tbs as select * from scott.dept;

表已创建。

已用时间: 00: 00: 00.23

23:45:27 SQL> create index user_app1.idx_emp_ename on user_app1.app1_tab(ename) tablespace idxtbs;

索引已创建。

已用时间: 00: 00: 00.25

23:45:51 SQL> create index user_app2.idx_dept_dname on user_app2.app2_tab(dname) tablespace idxtbs;

索引已创建。

已用时间: 00: 00: 00.01

23:46:13 SQL>

判断平台支持并确定字节序

如果传输表空间集到不同的平台,则要确定对于源和目标平台这种跨平台表空间被支持,也要确定每个平台的字节序,如果平台具有相同的字节序,则不需要进行转化,否则必须做一个表空间集转化,在源端或目标端。

在源平台查询

23:46:13 SQL> col platform_name for a40

23:48:55 SQL> select d.platform_name,tp.endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name;

PLATFORM_NAME ENDIAN_FORMAT

---------------------------------------- --------------

Linux x86 64-bit Little

已用时间: 00: 00: 00.19

23:49:13 SQL>

结论:当前的系统平台支持跨平台表空间传输(因为上面的查询有记录返回)

在目标平台查询

ZFXDESKDB2:oracle:/oracle>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 1 13:47:14 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

SYS@ora2lhr> col platform_name for a40

SYS@ora2lhr> select d.platform_name,tp.endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name;

PLATFORM_NAME ENDIAN_FORMAT

---------------------------------------- ----------------------------

AIX-Based Systems (64-bit) Big

结论: 当前的AIX平台支持跨平台的表空间传输

源平台和目标平台的Endian_format 不同,source端为Little,target端为Big,所以需要进行表空间集转换,前边说过在源端或目标端都可以进行转换,这里我们选择在目标端来进行转换。

选择自包含的表空间集

进行检查

Indicates whether a full or partial dependency check is required. If TRUE, treats all IN and OUT pointers(dependencies) and captures them as violations if they are not self-contained in the transportable set.

先试试要传输app1tbs和idxtbs这2个表空间:

SQL> execute dbms_tts.transport_set_check('app1tbs,idxtbs',true);

PL/SQL procedure successfully completed.

查看检查结果

SQL> col violations for a70

23:50:53 SQL> select * from transport_set_violations;

VIOLATIONS

-------------------------------------------------------------------------------------------------------------------------------------------

ORA-39907: 索引 USER_APP2.IDX_DEPT_DNAME (在表空间 IDXTBS 中) 指向表 USER_APP2.APP2_TAB (在表空间 APP2TBS 中)。

已用时间: 00: 00: 00.18

23:51:14 SQL>

结论: 在idxtbs表空间中IDX_DEPT_DNAME索引指向了表空间集外的USER_APP2.APP2_TAB表,所以这里选择app1tabs,app2tabs,idxtbs作为新的表空间集再次进行检查

23:51:14 SQL> execute dbms_tts.transport_set_check('app1tbs,app2tbs,idxtbs',true);

PL/SQL 过程已成功完成。

已用时间: 00: 00: 07.24

23:52:14 SQL> select * from transport_set_violations;

未选定行

已用时间: 00: 00: 00.00

23:52:54 SQL>

结论: 此时这个表空间集已经不再违背自包含的条件,可以确定为一个可传输表空间集。在实际生产环境中也是如此检查的,若是全库迁移,得把需要迁移的表空间修改为自包含的。

产生可传输表空间集

使自包含的表空间集中的所有表空间变为只读状态

23:52:54 SQL> alter tablespace app1tbs read only;

表空间已更改。

已用时间: 00: 00: 00.36

23:54:31 SQL> alter tablespace app2tbs read only;

表空间已更改。

已用时间: 00: 00: 00.15

23:54:42 SQL> alter tablespace idxtbs read only;

表空间已更改。

已用时间: 00: 00: 00.14

23:54:48 SQL>

使用数据泵导出工具,导出要传输的各个表空间的元数据

确定导出目录

23:55:51 SQL> set line 9999

23:56:07 SQL> col directory_name for a28

23:56:07 SQL> col directory_path for a100

23:56:07 SQL> select directory_name,directory_path from dba_directories;

DIRECTORY_NAME DIRECTORY_PATH

---------------------------- ----------------------------------------------------------------------------------------------------

OSDESC /home/oracle/

ASMSRC +DATA/orclasm/datafile/

DIR_ALERT /u01/app/oracle/diag/rdbms/orclasm/orclasm/trace

SCHEDULER$_WALLET_DIR /u01/app/oracle/product/11.2.0/dbhome_1/scheduler/wallet

TMP_HF_DIR +DATA/orclasm/datafile/

FY_DATA_DIR /tmp

REPDIR /oradata06/repdir

DIR_ALERT_CHECKHELTH_LHR_1 /u01/app/oracle/diag/rdbms/orclasm/orclasm/trace

SUBDIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/order_entry//2002/Sep

SS_OE_XMLDIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/order_entry/

LOG_FILE_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/log/

MEDIA_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/product_media/

XMLDIR /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/xml

DATA_FILE_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/sales_history/

DATA_PUMP_DIR /u01/app/oracle/admin/orclasm/dpdump/

ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/11.2.0/dbhome_1/ccr/state

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!
【TTS】传输表空间 Linux和AIX 之间传输数据后续精彩内容已被小麦苗无情隐藏,请输入验证码解锁本站所有文章!
验证码:
请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“DB宝”或者“www_xmmup_com”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦。
  • 18509239930
  • 个人微信

  • DB宝
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部