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