目录
一、数据泵之NETWORK_LINK
1、环境介绍
2、imp和exp
3、expdp不使用network_link
4、expdp使用network_link
4.1、目标数据库创建dblink
4.2、client端或目标数据库执行
4.3、总结
5、impdp使用network_link
5.1、目标数据库创建dblink
5.2、client或目标端执行
5.3、总结
二、迁移全库
1、目标库创建相关表空间
2、目标库创建dblink指向源库
3、目标库导入数据
4、校验数据量
5、总结
👉 背景:
近期公司有个项目,需要将一套AIX上的rac 11g,迁移到华为云上,数据量大概4T,停机时间2小时,目前最大问题是本地磁盘空间不足。起初,想到的是OGG或XTTS,XTTS没啥问题,最适合做这类迁移了。对于OGG来说,OGG初始化需要导出和导入,仍然需要临时的本地磁盘空间,当时把该方案直接pass掉了,后来回头想想,似乎可以使用network_link来解决这个问题。使用impdp+network_link导入完成后,再配置OGG实时同步,即可实现AIX到Linux的迁移。
SOURCE DB(虚拟机) | TARGET DB(虚拟机) | CLIENT(笔记本) | |
---|---|---|---|
EXP/IMP | 11.2.0.3.0 | 11.2.0.1.0 | 11.2.0.1.0 |
EXPDP/IMPDP | 11.2.0.3.0 | 11.2.0.1.0 | 11.2.0.1.0 |
HOST IP | 192.168.59.130 | 192.168.59.128 | 192.168.59.1 |
host 平台和内存 | RHEL 6.5 MemTotal: 2.6g | windows XP MemTotal: 2g | windows 8.1 MemTotal: 20g |
DB VERSION | 11.2.0.3.0 | 11.2.0.1.0 | 无 |
ORACLE_SID | orclasm | orcl | 无 |
tnsname | orclasm | orclxp |
注意:本实验所有的代码无特殊说明均在client客户端执行 图形如下:
👉 expdp属于服务端工具,而exp属于客户端工具,expdp生成的文件默认是存放在服务端的,而exp生成的文件是存放在客户端的 。
来验证exp和imp: 我们在client客户端执行:
C:\Users\Administrator>exp lhr/lhr@orclasm tables=xb_log_lhr file=e:\e1.dmp log=E:\exp_table.log buffer=41943040
Export: Release 11.2.0.1.0 - Production on 星期二 2月 10 15:55:25 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. 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
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径...
. . 正在导出表 XB_LOG_LHR导出了 56 行
成功终止导出, 没有出现警告。
C:\Users\Administrator>imp lhr/lhr@orclxp tables=xb_log_lhr file=e:\e1.dmp log=E:\exp_table.log buffer=41943040
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 15:59:42 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
经由常规路径由 EXPORT:V11.02.00 创建的导出文件
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. 正在将 LHR 的对象导入到 LHR
. 正在将 LHR 的对象导入到 LHR
. . 正在导入表 "XB_LOG_LHR"导入了 56 行
成功终止导入, 没有出现警告。
而文件也的确是在本机的:
根据expdp的语法,我们执行如下脚本:
C:\Users\Administrator>expdp lhr/lhr@orclasm directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr LOGFILE=expdp_table.log
Export: Release 11.2.0.1.0 - Production on 星期二 2月 10 16:37:40 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. 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
启动 "LHR"."SYS_EXPORT_TABLE_01": lhr/****@orclasm directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr LOGFILE=expdp_table.log
正在使用 BLOCKS 方法进行估计...
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 64 KB
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/COMMENT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/TRIGGER
处理对象类型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 导出了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
已成功加载/卸载了主表 "LHR"."SYS_EXPORT_TABLE_01"
---
LHR.SYS_EXPORT_TABLE_01 的转储文件集为:
/u01/app/oracle/admin/orclasm/dpdump/exptable.dmp
作业 "LHR"."SYS_EXPORT_TABLE_01" 已于 16:38:00 成功完成
C:\Users\Administrator>
在服务器端查看可知,文件是存放在linux服务器端的:
[oracle@rhel6_lhr dpdump]$ ll
total 156
-rw-r--r-- 1 oracle asmadmin 1391 Feb 10 16:38 expdp_table.log
-rw-r----- 1 oracle asmadmin 151552 Feb 10 16:38 exptable.dmp
[oracle@rhel6_lhr dpdump]$ pwd
/u01/app/oracle/admin/orclasm/dpdump
[oracle@rhel6_lhr dpdump]$
而在这种情况下必须将exptable.dmp 拷贝到windows XP上的相应目录下才能使用impdp来进行导入,如下利用ftp下载:
将exptable.dmp放到windows XP下的虚拟机里:
C:\Users\Administrator>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 10 16:46:37 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set line 9999
SQL> SELECT * FROM dba_directories d WHERE d.directory_name='DATA_PUMP_DIR';
OWNER DIRECTORY_NAME DIRECTORY_PATH
---
SYS DATA_PUMP_DIR F:\app\oracle\admin\orcl\dpdump\
SQL>
然后再进行导入操作:
C:\Users\Administrator>impdp lhr/lhr@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 16:50:46 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功加载/卸载了主表 "LHR"."SYS_IMPORT_FULL_01"
启动 "LHR"."SYS_IMPORT_FULL_01": lhr/****@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
. . 导入了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
处理对象类型 TABLE_EXPORT/TABLE/COMMENT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/TRIGGER
处理对象类型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作业 "LHR"."SYS_IMPORT_FULL_01" 已经完成。
C:\Users\Administrator>
日志文件路径:
这样操作非常麻烦,那么如何将生成的文件放在目标数据库而不放在源数据库呢,答案就是在expdp中使用network_link选项。
C:\Users\Administrator>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 10 16:55:43 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create public database link dblk_orclasm connect to lhr identified by lhr using 'orclasm' ;
数据库链接已创建。
SQL> SELECT count(1) FROM xb_log_lhr@dblk_orclasm;
COUNT(1)
----------
56
SQL> SELECT count(1) FROM xb_log_lhr;
SELECT count(1) FROM xb_log_lhr
*
第 1 行出现错误:
ORA-00942: 表或视图不存在
SQL>
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
C:\Users\Administrator>
注意这里的连接标识符是orclxp,即连接到windows xp系统,是target库。
C:\Users\Administrator>expdp lhr/lhr@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr network_link=dblk_orclasm LOGFILE=expdp_table.log
Export: Release 11.2.0.1.0 - Production on 星期二 2月 10 17:07:35 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
启动 "LHR"."SYS_EXPORT_TABLE_01": lhr/****@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr network_link=dblk_orclasm LOGFILE=expdp_table.log
正在使用 BLOCKS 方法进行估计...
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 64 KB
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/COMMENT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/TRIGGER
处理对象类型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 导出了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
已成功加载/卸载了主表 "LHR"."SYS_EXPORT_TABLE_01"
---
LHR.SYS_EXPORT_TABLE_01 的转储文件集为:
F:\APP\ORACLE\ADMIN\ORCL\DPDUMP\EXPTABLE.DMP
作业 "LHR"."SYS_EXPORT_TABLE_01" 已于 17:07:58 成功完成
C:\Users\Administrator>
结果:
C:\Users\Administrator>impdp lhr/lhr@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 17:13:20 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功加载/卸载了主表 "LHR"."SYS_IMPORT_FULL_01"
启动 "LHR"."SYS_IMPORT_FULL_01": lhr/****@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
. . 导入了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
处理对象类型 TABLE_EXPORT/TABLE/COMMENT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/TRIGGER
处理对象类型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作业 "LHR"."SYS_IMPORT_FULL_01" 已经完成(于 17:13:23 完成)
如果想不生成dmp文件而直接将需要的数据导入到target数据库,那么还可以直接使用impdp+network_link选项 ,这样就可以直接将源库的数据迁移到目标库中,不用生成中间的dmp文件,也不用执行expdp。是不是很爽,go go go,我们来试一把。
C:\Users\Administrator>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 10 16:55:43 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create public database link dblk_orclasm connect to lhr identified by lhr using 'orclasm' ;
数据库链接已创建。
SQL> SELECT count(1) FROM xb_log_lhr@dblk_orclasm;
COUNT(1)
----------
56
SQL> SELECT count(1) FROM xb_log_lhr;
SELECT count(1) FROM xb_log_lhr
*
第 1 行出现错误:
ORA-00942: 表或视图不存在
SQL>
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
C:\Users\Administrator>
C:\Users\Administrator>impdp lhr/lhr@orclxp network_link=dblk_orclasm directory=DATA_PUMP_DIR TABLES=xb_log_lhr PARALLEL=2
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 17:20:58 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
启动 "LHR"."SYS_IMPORT_TABLE_01": lhr/****@orclxp network_link=dblk_orclasm directory=DATA_PUMP_DIR TABLES=xb_log_lhr PARALLEL=2
正在使用 BLOCKS 方法进行估计...
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 64 KB
处理对象类型 TABLE_EXPORT/TABLE/TABLE
. . 导入了 "LHR"."XB_LOG_LHR" 56 行
处理对象类型 TABLE_EXPORT/TABLE/COMMENT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/TRIGGER
处理对象类型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作业 "LHR"."SYS_IMPORT_TABLE_01" 已经完成(于 17:21:10 完成)
C:\Users\Administrator>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 10 16:55:43 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SELECT count(1) FROM xb_log_lhr;
COUNT(1)
----------
56
可以看到,相关目录只生成了一个日志文件,而没有相关的数据的dmp文件。
不生成数据文件而直径导入的方法类似于在目标库中执行create table xxx as select * from xxx@dblink ,不过impdp+nework_link一并将数据及其索引触发器等都导入到了目标端,这样就省了很多事情了。
SOURCE | TARGET | |
---|---|---|
HOST IP | 172.17.0.10 | 172.17.0.15 |
host 平台 | CentOS 7.6 | CentOS 7.6 |
DB VERSION | 11.2.0.3.0 | 19.3.0.0.0 |
ORACLE_SID | LHR11G | lhrsdb |
tnsname | LHR11G | lhrsdb |
该实验用到的相关SQL:
-- 源库获取相关表空间的建表语句
SET LONG 9999
SELECT DBMS_METADATA.GET_DDL('TABLESPACE', NAME) DDL_SQL FROM v$tablespace
WHERE name not in ('SYSTEM','SYSAUX','UNDOTBS1','TEMP') ;
-- 目标端创建dblink
create public database link dbl_lhr11g connect to system identified by lhr
using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.0.10 )(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = LHR11G) ) )';
-- 在目标端直接导入
impdp system/lhr DIRECTORY=DATA_PUMP_DIR FULL=Y \
LOGFILE=impdp_netlink_lhr_20210416.log network_link=dbl_lhr11g EXCLUDE=STATISTICS PARALLEL=4
-- 对象个数统计
select owner, object_type, count(*)
from dba_objects
where object_name not like 'BIN%'
and owner in ('LHR','XXT')
group by owner, object_type
order by 1,2 desc;
源库获取表空间的SQL:
SYS@LHR11G> SET LONG 9999
SYS@LHR11G> SELECT DBMS_METADATA.GET_DDL('TABLESPACE', NAME) DDL_SQL FROM v$tablespace
WHERE name not in ('SYSTEM','SYSAUX','UNDOTBS1','TEMP') ;
DDL_SQL
--------------------------------------------------------------------------------
CREATE TABLESPACE "USERS" DATAFILE
'/u01/app/oracle/oradata/LHR11G/users01.dbf' SIZE 5242880
AUTOEXTEND ON NEXT 1310720 MAXSIZE 32767M
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO
CREATE TABLESPACE "EXAMPLE" DATAFILE
'/u01/app/oracle/oradata/LHR11G/example01.dbf' SIZE 104857600
AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M
NOLOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO
ALTER DATABASE DATAFILE
'/u01/app/oracle/oradata/LHR11G/example01.dbf' RESIZE 362414080
CREATE TABLESPACE "TS_LHR" DATAFILE
'/u01/app/oracle/oradata/LHR11G/ts_lhr01.dbf' SIZE 10485760
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO
CREATE TABLESPACE "TS_XXT" DATAFILE
'/u01/app/oracle/oradata/LHR11G/ts_xxt01.dbf' SIZE 31457280
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO
将表空间的建表语句中的数据文件的相关路径修改为“/opt/oracle/oradata/LHRSDB/”,然后拿到目标库执行:
[oracle@lhrora19c ~]$ sas
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Apr 16 10:03:46 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SYS@lhrsdb> CREATE TABLESPACE "EXAMPLE" DATAFILE
2 '/opt/oracle/oradata/LHRSDB/example01.dbf' SIZE 104857600
AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M
4 NOLOGGING ONLINE PERMANENT BLOCKSIZE 8192
5 EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
6 NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO;
Tablespace created.
SYS@lhrsdb>
SYS@lhrsdb>
SYS@lhrsdb> CREATE TABLESPACE "TS_LHR" DATAFILE
'/opt/oracle/oradata/LHRSDB/ts_lhr01.dbf' SIZE 10485760
3 LOGGING ONLINE PERMANENT BLOCKSIZE 8192
4 EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
5 NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO;
Tablespace created.
SYS@lhrsdb>
SYS@lhrsdb> CREATE TABLESPACE "TS_XXT" DATAFILE
2 '/opt/oracle/oradata/LHRSDB/ts_xxt01.dbf' SIZE 31457280
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
4 EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
5 NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO;
Tablespace created.
[oracle@lhrora19c ~]$ sas
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Apr 16 09:54:46 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SYS@lhrsdb> create public database link dbl_lhr11g connect to system identified by lhr
2 using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.0.10 )(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = LHR11G) ) )';
Database link created.
[oracle@lhrora19c ~]$ impdp system/lhr DIRECTORY=DATA_PUMP_DIR FULL=Y LOGFILE=impdp_netlink_lhr_20210416.log network_link=dbl_lhr11g EXCLUDE=STATISTICS PARALLEL=4
Import: Release 19.0.0.0.0 - Production on Fri Apr 16 10:18:43 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/******** DIRECTORY=DATA_PUMP_DIR FULL=Y LOGFILE=impdp_netlink_lhr_20210416.log network_link=dbl_lhr11g EXCLUDE=STATISTICS PARALLEL=4
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 369.3 MB
Processing object type DATABASE_EXPORT/TABLESPACE
ORA-31684: Object type TABLESPACE:"UNDOTBS1" already exists
........
Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 4925 error(s) at Fri Apr 16 10:31:55 2021 elapsed 0 00:13:08
报错的内容基本都是已经存在的对象,可以忽略。
源库的数据量:
SYS@LHR11G> select owner, object_type, count(*)
2 from dba_objects
where object_name not like 'BIN%'
4 and owner in ('LHR','XXT')
5 group by owner, object_type
6 order by 1,2 desc;
OWNER OBJECT_TYPE COUNT(*)
------------------------------------------------------------ -------------------------------------- ----------
LHR VIEW 1
LHR TABLE 13
LHR SYNONYM 1
LHR SEQUENCE 1
LHR PROCEDURE 2
XXT TABLE 2
迁移完成后,目标库的数据量:
SYS@lhrsdb> select owner, object_type, count(*)
2 from dba_objects
3 where object_name not like 'BIN%'
4 and owner in ('LHR','XXT')
group by owner, object_type
6 order by 1,2 desc;
OWNER OBJECT_TYPE COUNT(*)
---------- ---------------------------------------------- ----------
LHR VIEW 1
LHR TABLE 13
LHR SYNONYM 1
LHR SEQUENCE 1
LHR PROCEDURE 2
XXT TABLE 2
6 rows selected.
业务用户的数据量对应。
1、若是源库空间不足,那么可以考虑使用impdp+network_link来迁移数据。
2、若源库比较大,那么最好分批次进行迁移。例如,可以按照用户或者表空间进行迁移。
本文结束。