背景:对生产环境的数据做备份,并在本机还原。使用的命令是oracle的expdp和impdp。
导出命令:
expdp DMS/1q2w3e.@orcl schemas=DMS dumpfile=dms201912171420.dmp log=dms201912171420.log directory=DMS_DIR;
错误信息:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit 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 536
ORA-29283: invalid file operation
按照网上提供的可能 出现的问题一一排查:
1.实际路径不存在
在备份之前需要用命令创建逻辑目录
create directory DMS_DIR as '/data/transfer'
这个命令是不会在硬盘上创建目录的,并且不管硬盘上有没有这个目录都会创建成功,但是在导出的时候会报错。
去服务器的改路径下面去查看是有这个目录的,排除是这个原因。
2.没有赋权
创建目录后需要通过dba权限的用户把这个路径的独写权限赋权给导出的用户
GRANT read,write on DIRECTORY DMS_DIR TO DMS
赋权成功,但是导出bmp仍然报错,排除这个原因
3.oracle用户对目录没有访问权限
由于linux的目录创建后对普通用户是没有权限的,可能是这个原因导致了oracle访问该目录的时候被禁止,用chmod命令把/data/dmsdir目录权限设置成全用户可读写。解决问题。