在创建PDB过程中如果使用了带PATH_PREFIX的参数,意味着在创建DIRECTORY目录时需要指定相对路径,而不能指定其它绝对路径。来自博客园AskScuti
11g整库作为一个PDB迁移至阿里云12c CDB的过程中,在连接PDB,创建DIRECTORY目录的时候报错:ORA-65254: invalid path specified for the directory
目录
1. 项目过程
2. 问题
3. 原因
4. 解决方案
1. 项目过程
11g整库已经通过数据泵方式完整导出,拷贝到阿里云平台对应目录;在12c数据库中通过PDB$SEED快速创建PDB(注意:语句中带了参数path_prefix='/u01/app/oracle/oradata/cdbdb/pdb11g/'),连接PDB后,创建相应DIRECTORY时,提示错误。
create pluggable database pdb11g admin user pdb11g identified by * path_prefix='/u01/app/oracle/oradata/cdbdb/pdb11g/' file_name_convert=('/u01/app/oracle/oradata/cdbdb/pdbseed/','/u01/app/oracle/oradata/cdbdb/pdb11g/')
2. 问题
[oracle@izj6cf6xxwhjlqnfh4cmnyz:/home/oracle]$sqlplus sys/oracle@pdb11g as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Tue Jun 4 18:41:52 2019 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> show con_name CON_NAME ------------------------- PDB11G SQL> show user USER is "SYS" SQL> !ls /u01/app/oracle/ admin audit cfgtoollogs checkpoints diag oradata product pump SQL> create or replace directory pumpdir as '/u01/app/oracle/pump'; create or replace directory pumpdir as '/u01/app/oracle/pump' * ERROR at line 1: ORA-65254: invalid path specified for the directory
路径及权限无误,却依然报错。
3. 原因
SQL> !oerr ora 65254 65254, 00000, "invalid path specified for the directory" // *Cause: An absolute path was used in the CREATE DIRECTORY statement. // Since the PDB has set the PATH_PREFIX property, only relative // path is allowed for directories. // *Action: Specify a relative path and reissue the statement. //
因为在创建PDB的语句中指定了PATH_PREFIX子句,所以PATH_PREFIX指定的路径将作为前缀添加到该PDB的所有本地目录对象中,只能指定基于PATH_PREFIX的相对路径。
官方文档 Release 12.2 Database Administrator’s Guide:Example 38-5 PATH_PREFIX Clause
4. 解决方案
SQL> create or replace directory oracle_path_prefix as 'pump'; Directory created. SQL> select owner o,directory_name dn,directory_path dp,origin_con_id cid from dba_directories where directory_name='ORACLE_PATH_PREFIX'; O DN DP CID ---- ------------------ ----------------------------------------- --- SYS ORACLE_PATH_PREFIX /u01/app/oracle/oradata/cdbdb/pdb11g/pump 4
定义好DIRECTORY_NAME之后,只需要在AS关键字后面定义目录名称即可,DIRECTORY_PATH会根据PDB中的PATH_PREFIX子句,自动生成。