XTTS数据迁移方案

  • 前置条件检查

XTTS使用限制较多,V3版本按照本节逐项检查

    1. 目标库操作系统不能是windows

源库:redhut 7.9

目标库:redhut 7.9

    1. 检查数据库时区(两边都需要)

|--------------------------------------------------------------------------------------------------------------------------------------|
| SQL> select dbtimezone from dual; |

检查结果两边都一致

    1. 检查数据库时间

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') from dual; |

检查结果两边都一致

    1. 检查数据库字符集

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> set linesize 120 SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET%'; |

检查结果两边都一致

    1. 检查目标端补丁情况

|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| select 'opatch',comments from dba_registry_history; |

目标库需要比源库补丁高

    1. 检查两边组件安装

|---------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> Select comp_name from dba_registry; |

如果两边安装了不一样的组件,请注意。

    1. 检查是否使用了 Key Compression 的索引组织表

|----------------------------------------------------------------------------|
| Select index_name,table_name from dba_indexes where compression='ENABLED'; |

    1. 检查sys和system用户在业务表空间上是否创建对象

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> select table_name, owner, tablespace_name from dba_tables where tablespace_name not in('SYSTEM','SYSAUX') and owner in ('SYS','SYSTEM'); |

如果数据库用户 SYS、SYSTEM 在业务表空间上创建有对象,则这些对象不能通过 XTTS 迁移,需要在目标库手工创建。

    1. 检查sys和system用户在业务表空间上是否创建对象

|------------------------------------------------------------------------------------------------------------------------------------|
| SQL> show parameter compatible; |

如果目标端数据库版本是 19.0.0 或更低。那么需要在目标端装 19.0.0以上版本 并创建实例,然后用来进行备份集转换。如果 19.0.0以上版本 中转实例使用 ASM。那么 ASM 版本也必须是 19.0.0以上版本,否则报错 ORA-15295

    1. 确认生产库的recycle in功能是关闭,并手工清空回收站

|------------------------------------------------------------------------------------------------------------------------------------|
| SQL> show parameter recyclebin; |

如果数据库这个功能没有关闭,我们需要去关闭一些

|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> alter system set recyclebin='off' scope=spfile; |

    1. 数据文件状态检查

|-------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> Select distinct status from v$datafile; |

正常返回应为:ONLINE、SYSTEM

    1. 查看v$transportable_platform检查平台信息

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> col PLATFORM_NAME format a50 SQL> select * from v$transportable_platform; |

    1. 测试数据构建

可以查看《oracle数据库验证数据构造方案》

  • 数据迁移
    1. 创建源端和目标端用于存放备份数据文件夹

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| pwd mkdir xtts ls cd xtts/ ll mkdir source_back mkdir source_incr_back mkdir target_data mkdir target_back mkdir target_incr_back |

    1. 下载并解压rman_xttconvert_v3工具

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| unzip rman_xttconvert_v3.zip [oracle@source xtts]$ ls su chmod -R 775 xtts/ ll |

    1. 编辑和配置xtt.properties文件

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| tablespaces=MYTBS # 表示需要迁移的表空间 platformid=13 # 表示源OS平台ID #srclink=TTSLINK #表示从目标库指向源库的db_link,由于这里采用的是rman方式,所以不需要db_link dfcopydir=/u01/app/oracle/xtts/source_back #表示源库备份文件存放目录 backupformat=/u01/app/oracle/xtts/source_incr_back #表示源库增备文件存放目录 stageondest=/u01/app/oracle/xtts/target_back #表示目标库备份文件存放目录 storageondest=/u01/app/oracle/xtts/target_data #表示目标库正式文件存放目录 backupondest=/u01/app/oracle/xtts/target_incr_back #表示目标库增备文件存放目录 parallel=3 #表示备份转化并行度 rollparallel=2 #表示增备的并行度 getfileparallel=4 #表示使用 dbms_file_transfer 方式的并行度 |

    1. 将源端xtts目录拷贝到目标端

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| scp -rp /u01/app/oracle/xtts/ root@192.168.238.21:/u01/app/oracle/xtts |

    1. 设置源端和目标端的TMPDIR环境变量

|--------------------------------------------------------------------------------------|
| su - oracle vi .bash_profile export TMPDIR=/u01/app/oracle/xtts source .bash_profile |

    1. 源端和目标端开启归档模式并且换日志

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> archive log list 目标端修改为归档模式 SQL> alter system switch logfile; SQL> archive log list |

    1. 源端执行如下命令开始初始备份

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| cd /u01/app/oracle/xtts/ $ORACLE_HOME/perl/bin/perl /u01/app/oracle/xtts/xttdriver.pl -p |

    1. 源端查看备份文件,并将备份文件传到目标端

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [oracle@oramig source_back]$ scp -p /u01/app/oracle/xtts/source_back/* root@192.168.238.21:/u01/app/oracle/xtts/target_back 目标端给权限 |

    1. 将源端生成的rmanconvert.cmd文件传到目标端,并执行文件转换命令

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| scp -p rmanconvert.cmd root@192.168.238.21:/u01/app/oracle/xtts/ |

    1. 目标端执行如下命令

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $ORACLE_HOME/perl/bin/perl /u01/app/oracle/xtts/xttdriver.pl -c 转换成功之后会生成 xttnewdatafiles.txt文件。 |

    1. 开始增量同步

|-------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> alter tablespace MYTBS read only; |

    1. 将最后的增备文件传到目标端

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Pwd $ORACLE_HOME/perl/bin/perl /u01/app/oracle/xtts/xttdriver.pl -i cd source_incr_back/ Ls scp -p 0f2ntcso_1_1 root@192.168.238.21:/u01/app/oracle/xtts/target_back |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| cd .. scp -p xttplan.txt tsbkupmap.txt root@192.168.238.21:/u01/app/oracle/xtts 目标端修改权限 |

    1. 目标端应用增备

|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $ORACLE_HOME/perl/bin/perl /u01/app/oracle/xtts/xttdriver.pl -r |

    1. 源端导出元数据

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| mkdir -p /u01/app/oracle/data SQL> create directory source_dbdata as '/u01/app/oracle/data'; SQL> grant read,write on directory source_dbdata to system; SQL> select * from dba_directories; |

    1. 源端检查表空间的自包含性

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('MYTBS', TRUE); SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS; |

    1. 源端导出元数据

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| cd //u01/app/oracle/data expdp system/123456 directory=source_dbdata dumpfile=MYTBS.dmp transport_tablespaces=MYTBS transport_full_check=y ls |

    1. 将导出的数据拷贝到目标端

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| scp -p /u01/app/oracle/data/MYTBS.dmp root@192.168.238.21:/u01/app/oracle/data |

    1. 目标端导入元数据

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 创建zgc用户,但是不要创建表空间 SQL> create user zgc identified by 123456; SQL> grant dba to zgc; SQL> create directory t_dbdata as '/u01/app/oracle/data'; SQL> grant read,write on directory t_dbdata to zgc; SQL> grant exp_full_database,imp_full_database to zgc; |
| 目标端导入元数据 pwd impdp zgc/123456 DUMPFILE=MYTBS.dmp DIRECTORY=t_dbdata TRANSPORT_DATAFILES=/u01/app/oracle/xtts/target_data/MYTBS_8.dbf ,/u01/app/oracle/xtts/target_data/MYTBS_9.dbf 、 |

    1. 目标端更改zgc默认表空间

|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| SQL> alter user zgc default tablespace MYTBS; |
| 更改表空间zgc状态为读写 SQL> ALTER TABLESPACE MYTBS read write; |

    1. 源端目标端数据比较

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 源端 目标端 |

  • 问题分析
    1. 问题一

|------------------------|
| system 用户没设置密码 设置一下就行了 |

    1. 问题二

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 目标端创建zgc用户时 SELECT DEFAULT_TABLESPACE FROM USER_TABLESPACES WHERE USERNAME = 'zgc'; 说无效的用户名 解决方法: ALTER SESSION SET "_oracle_script"=true; |

相关推荐
HC182580858329 分钟前
“倒时差”用英语怎么说?生活英语口语学习柯桥外语培训
学习·生活
学习路上_write14 分钟前
FPGA/Verilog,Quartus环境下if-else语句和case语句RT视图对比/学习记录
单片机·嵌入式硬件·qt·学习·fpga开发·github·硬件工程
喵叔哟15 分钟前
重构代码之移动字段
java·数据库·重构
念白44319 分钟前
智能病历xml提取
数据库·sql·oracle
非概念20 分钟前
stm32学习笔记----51单片机和stm32单片机的区别
笔记·stm32·单片机·学习·51单片机
qingy_204623 分钟前
【JavaWeb】JavaWeb入门之XML详解
数据库·oracle
大数据面试宝典27 分钟前
用AI来写SQL:让ChatGPT成为你的数据库助手
数据库·人工智能·chatgpt
努力的小雨32 分钟前
快速上手 KSQL:轻松与数据库交互的利器
数据库·经验分享
Gentle58634 分钟前
labview中连接sql server数据库查询语句
数据库·labview
Gentle58635 分钟前
labview用sql server数据库存取数据到一个单元格
数据库·labview