expdp/impdp 参数network_link使用测试

简介:

   下面是network_link常用的三个环境测试

   1,服务器端的数据导出到指定的客户端

   2,不同数据库间迁移数据。

   3,同一个数据库中不同用户之间迁移数据。

   一:服务器端的数据导出到指定的客户端

 
  1. 1,修改客户端的TNSNAMES文件 
  2. POWER1 = 
  3.   (DESCRIPTION = 
  4.     (ADDRESS_LIST = 
  5.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.111.13)(PORT = 1521)) 
  6.     ) 
  7.     (CONNECT_DATA = 
  8.       (SERVER = DEDICATED) 
  9.       (SERVICE_NAME = power1) 
  10.     ) 
  11.   ) 
  12. 2,创建dblink 
  13. SQL> CREATE PUBLIC DATABASE LINK "POWER1" 
  14.   2  CONNECT TO scott 
  15.   3  IDENTIFIED BY "oracle" 
  16.   4  USING 'POWER1'
  17.  
  18. Database link created. 
  19.  
  20. SQL> select * from dual@power1; 
  21.  
  22. 3,directory目录 
  23. SQL> set lines 170 
  24. SQL> col owner for a15 
  25. SQL> col directory_name for a60 
  26. SQL>  col directory_name for a30 
  27. SQL> col DIRECTORY_PATH for a70 
  28. SQL> select * from dba_directories; 
  29.  
  30. OWNER           DIRECTORY_NAME                 DIRECTORY_PATH 
  31. --------------- ------------------------------ ---------------------------------------------------------------------- 
  32. SYS             DUMP                           /tmp 
  33. SYS             TOAD_BDUMP_DIR                 /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace 
  34. SYS             XMLDIR                         /u01/app/oracle/product/11.2/db_1/rdbms/xml 
  35. SYS             DATA_PUMP_DIR                  /u01/app/oracle/admin/orcl11g/dpdump/ 
  36. SYS             ORACLE_OCM_CONFIG_DIR          /u01/app/oracle/product/11.2/db_1/ccr/state 
  37. 如果不存在使用create directory创建再用grant授予用户权限 
  38. 4,导数据 
  39. [oracle11g@rhel4 admin]$ expdp system/oracle directory=dump dumpfile=scott_test.dmp logfile=scott_log.dmp  network_link='power1' schemas=scott 
  40.  
  41. Export: Release 11.2.0.3.0 - Production on Tue Mar 26 18:22:28 2013 
  42.  
  43. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  44.  
  45. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  46. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  47. ORA-31631: privileges are required 
  48. ORA-39149: cannot link privileged user to non-privileged user 
  49.  
  50.  
  51. grant这个命令要在源端数据库上面执行 
  52. SQL> GRANT exp_full_database TO scott;  
  53.  
  54. Grant succeeded. 
  55. 回到客户端上面 
  56. [oracle11g@rhel4 admin]$ expdp system/oracle directory=dump dumpfile=scott_test.dmp logfile=scott_log.dmp  network_link='power1' schemas=scott 
  57.  
  58. Export: Release 11.2.0.3.0 - Production on Tue Mar 26 19:40:03 2013 
  59.  
  60. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  61.  
  62. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  63. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  64. ORA-39001: invalid argument value 
  65. ORA-39000: bad dump file specification 
  66. ORA-31641: unable to create dump file "/tmp/scott_test.dmp" 
  67. ORA-27038: created file already exists 
  68. Additional information: 1 
  69.  
  70.  
  71. [oracle11g@rhel4 admin]$ expdp system/oracle directory=dump dumpfile=scott_test.dmp logfile=scott_log.dmp  network_link='power1' schemas=scott REUSE_DUMPFILES=Y 
  72.  
  73. Export: Release 11.2.0.3.0 - Production on Tue Mar 26 19:42:29 2013 
  74.  
  75. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  76.  
  77. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  78. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  79. Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":  system/******** directory=dump dumpfile=scott_test.dmp logfile=scott_log.dmp network_link=power1 schemas=scott REUSE_DUMPFILES=Y  
  80. Estimate in progress using BLOCKS method... 
  81. Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA 
  82. Total estimation using BLOCKS method: 2.129 GB 
  83. Processing object type SCHEMA_EXPORT/USER 
  84. Processing object type SCHEMA_EXPORT/SYSTEM_GRANT 
  85. Processing object type SCHEMA_EXPORT/ROLE_GRANT 
  86. Processing object type SCHEMA_EXPORT/DEFAULT_ROLE 
  87. Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA 
  88. Processing object type SCHEMA_EXPORT/TABLE/TABLE 
  89. Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE 
  90. Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE 
  91. Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX 
  92. Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT 
  93. Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS 
  94. Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT 
  95. Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS 
  96. . . exported "SCOTT"."TEST"                              1.800 GB 19096576 rows 
  97. . . exported "SCOTT"."DEPT"                              5.929 KB       4 rows 
  98. . . exported "SCOTT"."EMP"                               8.562 KB      14 rows 
  99. . . exported "SCOTT"."SALGRADE"                          5.859 KB       5 rows 
  100. . . exported "SCOTT"."BONUS"                                 0 KB       0 rows 
  101. Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded 
  102. ****************************************************************************** 
  103. Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is
  104.   /tmp/scott_test.dmp 
  105. Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 19:46:1  
  106. 已经成功导出到客户端指定的位置 
  107.    

 

二,不同数据库间迁移数据

    环境接着上面的,这里把源端SCOTT用户的数据迁移到客户端上面的HTZ用户下面

 
  1. [oracle11g@rhel4 admin]$ sqlplus / as sysdba 
  2.  
  3. SQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 26 20:15:14 2013 
  4.  
  5. Copyright (c) 1982, 2011, Oracle.  All rights reserved. 
  6.  
  7.  
  8. Connected to
  9. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  10. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  11.  
  12. SQL> drop user htz cascade
  13.  
  14. User dropped. 
  15.  
  16.  
  17. [oracle11g@rhel4 tmp]$ impdp system/oracle directory=dump  logfile=scott_impdp.log  remap_schema=scott:htz network_link=power1 
  18.  
  19. Import: Release 11.2.0.3.0 - Production on Tue Mar 26 20:16:27 2013 
  20.  
  21. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  22.  
  23. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  24. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  25. Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** directory=dump logfile=scott_impdp.log remap_schema=scott:htz network_link=power1  
  26. Estimate in progress using BLOCKS method... 
  27. Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA 
  28. Total estimation using BLOCKS method: 2.129 GB 
  29. Processing object type SCHEMA_EXPORT/USER 
  30. Processing object type SCHEMA_EXPORT/SYSTEM_GRANT 
  31. Processing object type SCHEMA_EXPORT/ROLE_GRANT 
  32. Processing object type SCHEMA_EXPORT/DEFAULT_ROLE 
  33. Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA 
  34. Processing object type SCHEMA_EXPORT/TABLE/TABLE 
  35. . . imported "HTZ"."TEST"                               19096576 rows 
  36. . . imported "HTZ"."DEPT"                                     4 rows 
  37. . . imported "HTZ"."EMP"                                     14 rows 
  38. . . imported "HTZ"."SALGRADE"                                 5 rows 
  39. . . imported "HTZ"."BONUS"                                    0 rows 
  40. Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE 
  41. Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE 
  42. ORA-39082: Object type ALTER_PROCEDURE:"HTZ"."BBW_INSERT" created with compilation warnings 
  43. Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX 
  44. Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT 
  45. Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS 
  46. Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT 
  47. Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS 
  48. Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 1 error(s) at 20:19:28 

三:同一个数据库中不同用户之间迁移数据

    环境接着上面,这里把HTZ的数据库迁移到同一个数据库的SCOTT用户下面

 
  1. 1,删除SCOTT用户
  2. [oracle11g@rhel4 admin]$ sqlplus / as sysdba 
  3.  
  4. SQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 26 20:30:28 2013 
  5.  
  6. Copyright (c) 1982, 2011, Oracle.  All rights reserved. 
  7.  
  8.  
  9. Connected to
  10. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  11. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  12.  
  13. SQL> drop user scott cascade
  14.  
  15. User dropped. 
  16.  
  17. SQL> Drop public database link "orcl11g"
  18.  
  19. Database link dropped. 
  20.  
  21. SQL>  
  22. SQL> create public database link "orcl11g" 
  23.   2  connect to htz 
  24.   3  identified by "oracle" 
  25.   4  using 'ORCL11G'
  26.  
  27. Database link created. 
  28.  
  29. SQL> grant exp_full_database TO  htz; 
  30.  
  31. Grant succeeded.
  32. 2,导数据
  33. [oracle11g@rhel4 admin]$ impdp system/oracle directory=dump  logfile=scott_impdp.log  remap_schema=htz:scott network_link=orcl11g 
  34.  
  35. Import: Release 11.2.0.3.0 - Production on Tue Mar 26 20:34:25 2013 
  36.  
  37. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  38.  
  39. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  40. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  41. Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** directory=dump logfile=scott_impdp.log remap_schema=htz:scott network_link=orcl11g  
  42. Estimate in progress using BLOCKS method... 
  43. Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA 
  44. Total estimation using BLOCKS method: 2.115 GB 
  45. Processing object type SCHEMA_EXPORT/USER 
  46. Processing object type SCHEMA_EXPORT/SYSTEM_GRANT 
  47. Processing object type SCHEMA_EXPORT/ROLE_GRANT 
  48. Processing object type SCHEMA_EXPORT/DEFAULT_ROLE 
  49. Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA 
  50. Processing object type SCHEMA_EXPORT/TABLE/TABLE 
  51. . . imported "SCOTT"."TEST"                             19096576 rows 
  52. . . imported "SCOTT"."DEPT"                                   4 rows 
  53. . . imported "SCOTT"."EMP"                                   14 rows 
  54. . . imported "SCOTT"."SALGRADE"                               5 rows 
  55. . . imported "SCOTT"."BONUS"                                  0 rows 
  56. Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE 
  57. Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE 
  58. ORA-39082: Object type ALTER_PROCEDURE:"SCOTT"."BBW_INSERT" created with compilation warnings 
  59. Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX 
  60. Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT 
  61. Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS 
  62. Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT 
  63. Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS 
  64. Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 1 error(s) at 20:35:49 

  三种常用的方式已经测试成功





     本文转自7343696 51CTO博客,原文链接:http://blog.51cto.com/luoping/1163551,如需转载请自行联系原作者


相关实践学习
数据库实验室挑战任务-初级任务
本场景介绍如何开通属于你的免费云数据库,在RDS-MySQL中完成对学生成绩的详情查询,执行指定类型SQL。
阿里云云原生数据仓库AnalyticDB MySQL版 使用教程
云原生数据仓库AnalyticDB MySQL版是一种支持高并发低延时查询的新一代云原生数据仓库,高度兼容MySQL协议以及SQL:92、SQL:99、SQL:2003标准,可以对海量数据进行即时的多维分析透视和业务探索,快速构建企业云上数据仓库。 了解产品 https://www.aliyun.com/product/ApsaraDB/ads
相关文章
|
5月前
|
JavaScript 前端开发 测试技术
Postman 加密接口测试 | 使用Rsa、Aes对参数加密
Postman 加密接口测试 | 使用Rsa、Aes对参数加密
246 0
|
5月前
|
Web App开发 Java Linux
Nexus【部署 02】最新版本 nexus-3.35.0-02-unix.tar.gz 安装配置启动及测试(JDK版本+虚拟机参数配置说明)
Nexus【部署 02】最新版本 nexus-3.35.0-02-unix.tar.gz 安装配置启动及测试(JDK版本+虚拟机参数配置说明)
141 0
|
3月前
|
Java 测试技术 Maven
单元测试添加运行参数的maven插件
单元测试添加运行参数的maven插件
22 0
|
3月前
|
存储 测试技术 Python
带有参数依赖的接口该如何测试?
带有参数依赖的接口该如何测试?
|
4月前
|
测试技术
软件测试/测试开发全日制|Pytest测试框架fixture作为参数使用
软件测试/测试开发全日制|Pytest测试框架fixture作为参数使用
25 0
|
5月前
|
SQL Java 数据库连接
【Java调试】通过SqlSessionFactory类对象获取mapper文件内的动态SQL在执行时的完整SQL及参数(2种使用方法+测试Demo及结果)
【Java调试】通过SqlSessionFactory类对象获取mapper文件内的动态SQL在执行时的完整SQL及参数(2种使用方法+测试Demo及结果)
57 0
|
5月前
|
JavaScript 测试技术
Vue配置生产环境和测试环境的参数,.env.production、.env.development怎么用?
Vue配置生产环境和测试环境的参数,.env.production、.env.development怎么用?
|
5月前
|
Java 测试技术
在SpringBoot单元测试中添加参数
在SpringBoot单元测试中添加参数
50 0
|
7月前
|
测试技术 Python
软件测试|Python函数参数之必传参数、默认参数、可变参数、关键字参数的详细使用
软件测试|Python函数参数之必传参数、默认参数、可变参数、关键字参数的详细使用
60 0
|
8月前
|
JSON 数据格式
wrk post lua脚本取excel参数压力测试,判断接口性能
wrk post lua脚本取excel参数压力测试,判断接口性能
153 0

热门文章

最新文章