Friday, 9 January 2009

Oracle Datapump Permissions Bug.

So im working on a tool to wrap up some datapump import / export functionality. Essentially it adds little to the core datapump tools (impdp and expdp) except for allowing better integration with my companies authentication systems, this oracopier tool can be run passwordless from a cronjob for example. Also adds in things like config files to define common export / import jobs containing random lists of objects.

Now I did come up against an oracle bug while doing this, concerning the required permissions on the oracle export directory. For example thigns probably go a little like this.

SQL> create directory expdir as '/tmp/my_export_dir/'
SQL> commit;

~> expdp directory=expdir yadda yadda yadda...

Now as we all know , as datapump is a server side process it runs with the same uid / gid as the server does.. Typically oracle:oracle .. So you'd expect these sort filesystem permissions to work on the export directory.

// this works fine

~> chmod 770 /tmp/my_export_dir; chown oracle:mygroup /tmp/my_export_dir;
~> expdp job...


// this works fine

~> chmod 770 /tmp/my_export_dir; chown myuser:oracle /tmp/my_export_dir;
~> expdp job...


// this does not, even though it should

~> groupadd oragrp
~> useradd -G oragrp oracle
~> chmod 770 /tmp/my_export_dir; chown myuser:oragrp /tmp/my_export_dir;
~> expdp job...


in this case oracle spews out abunch of errors like this:

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


So as the title of this post suggests this has been verified by oracle to be a bug affect up until at least 10.2.0.4 (SPARC and solaris x86) and 11.1.0.7 .. Oracle are working on a fix.

So for now you'll need to use permissions along the lines of these:
chmod 777 /tmp/expdir; chown anyuser:anygroup /tmp/expdir;
chmod 770 /tmp/expdir; chown oracle:anygroup /tmp/expdir;
chmod 770 /tmp/expdir; chown anyuser:oracle /tmp/expdir;

2 comments:

vishnuprasath said...
This comment has been removed by a blog administrator.
Dominic said...

I encountered this problem on a Windows system. It turned out that

create directory foo as 'c:\foo'

ended up with the error you had, but if you put a \ at the end, as in:

create directory bar as 'c:\foo\'

, then it would work OK.