oracle 数据泵方式同步
源端:
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
1250236
--创建目录对象dir,数据文件存放的路径为d:/expdpdi
create
directory dir
as
'd:/expdpdir'
;
--给用户授予目录对象的读写权限
grant
read
,write
on
directory dir
to
student ;
drop directory dir --删除目录 dir
源端根据 scn 备份用户下表结构以及表数据。
[oracle@bogon ~]$ expdp songhongjun/bagayalu directory=shj_dir dumpfile=t.bmp dumpfile=songhongjun flashback_scn=1250236;
Export: Release 11.2.0.1.0 - Production on Mon Jan 18 10:37:15 2021
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SONGHONGJUN"."SYS_EXPORT_SCHEMA_01": songhongjun/******** directory=shj_dir dumpfile=t.bmp dumpfile=songhongjun flashback_scn=1250236
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SONGHONGJUN"."K" 5.460 KB 4 rows
. . exported "SONGHONGJUN"."T" 5.101 KB 12 rows
Master table "SONGHONGJUN"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SONGHONGJUN.SYS_EXPORT_SCHEMA_01 is:
/data/oracle/expdpdir/t.bmp
Job "SONGHONGJUN"."SYS_EXPORT_SCHEMA_01" successfully completed at 10:37:54
拷贝到指定服务器目录
[root@bogon expdpdir]# scp shj.dmp 192.168.214.139:/data/oracle/shjdir
root@192.168.214.139's password:
目标端导入源端传过来的 dmp文件
[oracle@bogon shj_dir]$ impdp songhongjun/bagayalu directory=shj_dir dumpfile=shj.dmp;
Import: Release 11.2.0.1.0 - Production on Mon Jan 18 14:33:38 2021
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
UDI-01045: operation generated ORACLE error 1045
ORA-01045: user SONGHONGJUN lacks CREATE SESSION privilege; logon denied
Username: songhongjun
Password:
UDI-01045: operation generated ORACLE error 1045
ORA-01045: user SONGHONGJUN lacks CREATE SESSION privilege; logon denied
Username: ^CUDI-00001: user requested cancel of current operation
[oracle@bogon shj_dir]$ impdp songhongjun/bagayalu directory=shj_dir dumpfile=shj.dmp
Import: Release 11.2.0.1.0 - Production on Mon Jan 18 14:34:10 2021
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SONGHONGJUN"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SONGHONGJUN"."SYS_IMPORT_FULL_01": songhongjun/******** directory=shj_dir dumpfile=shj.dmp
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"SONGHONGJUN" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SONGHONGJUN"."K" 5.460 KB 4 rows
. . imported "SONGHONGJUN"."T" 5.101 KB 12 rows
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SONGHONGJUN"."SYS_IMPORT_FULL_01" completed with 1 error(s) at 14:34:14
ORA-39001:
ORA-39000:
ORA-31640:
ORA-27041:
需要对dmp文件赋权限 chmod 755 *.dmp
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 百万级群聊的设计实践
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期