expdp导出报错ORA-39002ORA-39070解决办法

Posted 河南骏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了expdp导出报错ORA-39002ORA-39070解决办法相关的知识,希望对你有一定的参考价值。

oracle@centos5 ~]$ expdp gys directory= dmp_dir dumpfile=stream.dmp schemas=stream

Export: Release 10.2.0.4.0 - Production on Wednesday, 16 October, 2013 17:51:37

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
Password:

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation
开始以为是dmp_dir 权限问题引起的,重新创建directory数据库对象测试下。
SQL> col OWNER format a6
SQL> col DIRECTORY_NAME for a20
SQL> col DIRECTORY_PATH for a30
SQL> select * from dba_directories;

OWNER  DIRECTORY_NAME       DIRECTORY_PATH
------ -------------------- ------------------------------
SYS    DATA_PUMP_DIR        /u01/oracle/db_1/rdbms/log/
SYS    STREAM               /u01/testdata/dump
SYS    ORACLE_OCM_CONFIG_DI /u01/oracle/db_1/ccr/state
                                                                       R
SYS    DMP_DIR              /u01/testdata/dump

SQL> drop directory dmp_dir;

Directory dropped.

SQL>  select * from dba_directories;

OWNER  DIRECTORY_NAME       DIRECTORY_PATH
------ -------------------- ------------------------------
SYS    DATA_PUMP_DIR        /u01/oracle/db_1/rdbms/log/
SYS    STREAM               /u01/testdata/dump
SYS    ORACLE_OCM_CONFIG_DI /u01/oracle/db_1/ccr/state
       R
已经删除dmp_dir

重新创建
SQL> create directory dmp_dir as '/u01/testdata/dump';

Directory created.
SQL> grant read,write on directory dmp_dir to stream;

Grant succeeded.
SQL> !
[oracle@centos5 ~]$ expdp stream directory= dmp_dir dumpfile=stream.dmp schemas=stream

Export: Release 10.2.0.4.0 - Production on Wednesday, 16 October, 2013 17:51:37

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation

报错依旧!!!
想到,创建了DUMP的目录,是不是linux下oracle用户对这个目录没有权限,导致系统不能对该目录写入数据。
GO!!!
[oracle@centos5 u01]$ ls -lrt
total 28
drwxr-xr-x 3 oracle oinstall 4096 Aug 29 12:41 oracle
drwxrwx--- 6 oracle oinstall 4096 Aug 29 13:01 oraInventory
drwxr-x--- 2 oracle oinstall 4096 Oct 12 09:26 flash_recovery_area
drwxr-x--- 3 oracle oinstall 4096 Oct 16 12:47 oradata
drwxr-x--- 3 oracle oinstall 4096 Oct 16 12:47 admin
drwxr-xr-x 2 oracle oinstall 4096 Oct 16 14:47 orabak
drwxrwxrwx 3 oracle oinstall 4096 Oct 16 17:15 testdata
[oracle@centos5 u01]$ cd /u01/testdata
[oracle@centos5 testdata]$ ls -lrt
total 4
drwxr-xr-x 2 root root 4096 Oct 16 17:15 dump
发现问题,dump的用户权限是root oracle对该目录没有权限
[oracle@centos5 ~]$ su - root
Password:
[root@centos5 ~]# cd /u01/testdata
[root@centos5 testdata]# chown -R oracle:oinstall *
[root@centos5 testdata]# ls -lrt
total 4
drwxr-xr-x 2 oracle oinstall 4096 Oct 16 17:15 dump
修改该目录所有者。
[root@centos5 testdata]# su - oracle
[oracle@centos5 ~]$ expdp stream directory= dmp_dir dumpfile=stream.dmp schemas=stream

Export: Release 10.2.0.4.0 - Production on Wednesday, 16 October, 2013 17:58:05

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "GYS"."SYS_EXPORT_SCHEMA_01":  gys/******** directory= dmp_dir dumpfile=gys/********.dmp schemas=gys/********
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 1.489 GB
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
. . exported "STREAM"."TABWSALE"                         1.109 GB 11853316 rows
. . exported "STREAM"."TABSHIFTFLOW"                     33.49 MB  365378 rows
. . exported "STREAM"."TABSHIFTREPORT"                   32.32 MB  406880 rows
. . exported "STREAM"."TABSWEIGHT"                       8.763 MB  148977 rows
. . exported "STREAM"."TABVTIMEOUT"                      7.701 MB  239696 rows
. . exported "STREAM"."TABLOG"                           5.226 MB   92782 rows
. . exported "STREAM"."TABFINDAYREPORT"                  3.901 MB   35089 rows
. . exported "STREAM"."TABSALEDAYREPORT"                 3.278 MB   29743 rows
. . exported "STREAM"."TABPASSPORTREPORT"                1.773 MB   48059 rows
. . exported "STREAM"."TABRISKVRECORD"                   2.119 MB   23010 rows
. . exported "STREAM"."TABDESTROY"                       1.494 MB   34739 rows
. . exported "STREAM"."TABFINDAYREPORT_OLD"              1.028 MB    9218 rows
. . exported "STREAM"."TABPSTOCK"                        1.476 MB   34951 rows
. . exported "STREAM"."TABVECLIB"                        789.4 KB   18425 rows
. . exported "STREAM"."TABQUARTERS"                      788.2 KB   17181 rows
. . exported "STREAM"."TABTICKETDESTROY"                 9.031 KB       2 rows
. . exported "STREAM"."TABBHBW"                          113.3 KB    2762 rows
. . exported "STREAM"."TABPRINTPLAN"                     143.7 KB    1830 rows
. . exported "STREAM"."TABBHB"                           94.88 KB    2670 rows
. . exported "STREAM"."TABBHBS"                          109.7 KB    2762 rows
. . exported "STREAM"."TABCHECKUSER"                     8.406 KB      41 rows
. . exported "STREAM"."TABCLASSORDER"                    5.664 KB       9 rows
. . exported "STREAM"."TABCLIENTINFO"                    8.398 KB      13 rows
. . exported "STREAM"."TABLANE"                          7.703 KB       6 rows
. . exported "STREAM"."TABQUERYHAND"                     74.53 KB    1366 rows
. . exported "STREAM"."TABUSER"                          8.992 KB      37 rows
. . exported "STREAM"."TABWTOLLRATE"                     10.86 KB      30 rows
. . exported "STREAM"."TABCONFIG"                        7.507 KB     104 rows
. . exported "STREAM"."TABCONTRACT"                      17.36 KB     101 rows
. . exported "STREAM"."TABDEP"                           6.265 KB       6 rows
. . exported "STREAM"."TABDESTROYSERIAL"                 11.07 KB     178 rows
. . exported "STREAM"."TABEMPLOYEE"                      17.85 KB      49 rows
. . exported "STREAM"."TABFUNC"                          10.20 KB      57 rows
. . exported "STREAM"."TABINSTORE"                       7.039 KB      46 rows
. . exported "STREAM"."TABMONTHTOLL"                     15.20 KB     131 rows
. . exported "STREAM"."TABPOWERASSIGN"                   17.80 KB     612 rows
. . exported "STREAM"."TABRISKCONFIG"                    12.03 KB     152 rows
. . exported "STREAM"."TABRYZNB"                         5.273 KB       3 rows
. . exported "STREAM"."TABSHIPERMAN"                     11.71 KB     127 rows
. . exported "STREAM"."TABSHIPPROPERTY"                  9.898 KB      10 rows
. . exported "STREAM"."TABSPECIALVRECORD"                16.92 KB     133 rows
. . exported "STREAM"."TABSTATION"                       9.031 KB       2 rows
. . exported "STREAM"."TABSYNCCHECK"                     5.351 KB       5 rows
. . exported "STREAM"."TABTIMEFLAG"                      5.578 KB       3 rows
. . exported "STREAM"."TABUSE"                           9.578 KB     110 rows
. . exported "STREAM"."TABVERIFYRECORD"                  15.48 KB     386 rows
. . exported "STREAM"."PLAN_TABLE"                           0 KB       0 rows
. . exported "STREAM"."TABEMPTYSHIP"                         0 KB       0 rows
. . exported "STREAM"."TABTICKETREPEATSCAN"                  0 KB       0 rows
. . exported "STREAM"."TABWEIGHTVFLOW"                       0 KB       0 rows
Master table "GYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for GYS.SYS_EXPORT_SCHEMA_01 is:
  /u01/testdata/dump/stream.dmp

Job "GYS"."SYS_EXPORT_SCHEMA_01" successfully completed at 18:05:16


==========================================================================================

oracle11g用exp导出数据库的时候,空表是导不出来的,所以必须用数据泵导入导出oracle数据库。

一、导出数据用expdp

1、创建目录

语法:SQL> create directory 目录名(如:dmpbx) as 存储地址(如:'/root/usr/……');
例如:SQL> create  directory  dmpbx  as 'D:\\backup\\';
2、给目录赋权限
语法:SQL> grant read,write on directory 目录名 to public;
例如:SQL> grant read,write on directorydmpbx to public;
    SQL> exit

3、执行导出语句

语法:[Oracle@data ~]$expdp 用户名1/密码@实例 dumpfile=备份文件名(ecology.dmp) directory= 目录名(dmpbx) 

例如:[oracle@data ~]$ expdpuser1/pass1 dumpfile=data20140805.dmp directory=dmpbx 
 
二、导入用impdp

1、创建目录

语法:SQL> create directory 目录名(如:dmpbx) as 存储地址(如:'/root/usr/……');
例如:SQL> create  directory  dmpbx  as 'D:\\Oracle\\';
2、给目录赋权限
语法:SQL> grant read,write on directory 目录名 to public;
例如:SQL> grant read,write on directory dmpbx to public;
    SQL> exit

3、执行导入语句

语法:impdp 用户名2/密码@实例 directory=目录名 dumpfile=备份文件名.dmp logfile=日志名.log REMAP_SCHEMA=用户名1:用户名2
例如:impdp user2/pass2 directory= dmpbx dumpfile= data20140805 .dmp logfile= 20140805.log REMAP_SCHEMA= user1: user2

注:1、目录创建只需创建一次就行了

2、如果导入和导出是在同一台机器上操作的,则导出前的创建目录和赋权的步骤都可以省略。


以上是关于expdp导出报错ORA-39002ORA-39070解决办法的主要内容,如果未能解决你的问题,请参考以下文章

导出数据报ORA-39002: 操作无效 ORA-39070: 无法打开日志文件。 ORA-39087: 目录名 DUMP_DIR 无效

ORA-39002: 操作无效 ORA-39070: 无法打开日志文件

ORA-39002: 操作无效 ORA-39070: 无法打开日志文件

ORA-39002: 操作无效 ORA-39070: 无法打开日志文件

用expdp导出报错求教ORA-39126,ORA-01555

ORACLE10G expdp 导出数据报错,大神看下