本次测试中会使用到两个CDB的环境
CDB环境1:
CDB2中的PDB$SEED文件路径如下:
+CDB1DG/CDBS/CDB21/cdb2/pdbseed_temp01.dbf => +CDB1DG/CDB2/EF61F2A3DA6D4548E043C838A8C02E9A/TEMPFILE/TEMP.267.836254857
+CDB1DG/CDBS/CDB21/cdb2/pdbseed_system01.dbf => +CDB1DG/CDB2/EF61F2A3DA6D4548E043C838A8C02E9A/DATAFILE/SYSTEM.262.836254795
+CDB1DG/CDBS/CDB21/cdb2/pdbseed_sysaux01.dbf => +CDB1DG/CDB2/EF61F2A3DA6D4548E043C838A8C02E9A/DATAFILE/SYSAUX.264.836254841
CDB环境2:
ORA12C 中的PDB$SEED文件路径如下:
+DATADG1/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/pdbseed_temp01.dbf
+DATADG1/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/sysaux.268.828826479
+DATADG1/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/system.269.828826479
测试目标:摸索manually create pdb时如何正确指定file_name_covert参数、展示dbca方式建库时oracle自动转换pdb文件路径的特性
场景一(DBCA):输入” +cdb1dg”作为创建路径,Oracle生成的创建语句如下:
CREATE PLUGGABLE DATABASE pdb21 ADMIN USER pdb21_admin IDENTIFIED BY * ROLES=(CONNECT) file_name_convert=('+CDB1DG/CDBS/CDB21/cdb2/pdbseed_system01.dbf','+CDB1DG/pdb21_system01.dbf',
'+CDB1DG/CDBS/CDB21/cdb2/pdbseed_sysaux01.dbf','+CDB1DG/pdb21_sysaux01.dbf','+CDB1DG/CDBS/CDB21/cdb2/pdbseed_temp01.dbf','+CDB1DG/pdb21_temp01.dbf')
场景一(Manual):执行命令:
---指定的源路径和目标路径一致,让oracle误以为在源路径上覆盖建立pdb,所以报错
CREATE PLUGGABLE DATABASE pdb21 ADMIN USER pdb21_admin IDENTIFIED BY * ROLES=(CONNECT) file_name_convert=('+CDB1DG','+CDB1DG');
CREATE PLUGGABLE DATABASE pdb21 ADMIN USER pdb21_admin IDENTIFIED BY * ROLES=(CONNECT) file_name_convert=('+CDB1DG','+CDB1DG')
*
ERROR at line 1:
ORA-01537: cannot add file '+CDB1DG/CDBS/CDB21/cdb2/pdbseed_system01.dbf' -
file already part of database
--将源路径具体化到datafile的上层路径后创建成功:
SQL> create pluggable database pdb21 admin user pdb21_admin identified by 773946 roles=(connect) file_name_convert=('+CDB1DG/CDBS/CDB21/cdb2/','+CDB1DG/');
Pluggable database created.
——————————查看pdb21的文件路径,发现创建在了+CDB1dg /目录下——————————
+cdb1dg/pdbseed_sysaux01.dbf => +CDB1DG/CDB2/EFC6F3C9DA61745DE043C838A8C0C436/DATAFILE/SYSAUX.270.836688623
+cdb1dg/pdbseed_system01.dbf => +CDB1DG/CDB2/EFC6F3C9DA61745DE043C838A8C0C436/DATAFILE/SYSTEM.269.836688613
+cdb1dg/pdbseed_temp01.dbf => +CDB1DG/CDB2/EFC6F3C9DA61745DE043C838A8C0C436/TEMPFILE/TEMP.271.836688637
--或者将源路径具体化到datafile的上两层路径后创建成功:
SQL> create pluggable database pdb21 admin user pdb21_admin identified by 773946 roles=(connect) file_name_convert=('+CDB1DG/CDBS/CDB21/','+CDB1DG/');
Pluggable database created.
——————————查看pdb21的文件路径,发现创建在了+CDB1dg/cdb2/目录下——————————
+CDB1dg/cdb2/pdbseed_sysaux01.dbf => +CDB1DG/CDB2/EFC6F3C9DA62745DE043C838A8C0C436/DATAFILE/SYSAUX.270.836688979
+CDB1dg/cdb2/pdbseed_system01.dbf => +CDB1DG/CDB2/EFC6F3C9DA62745DE043C838A8C0C436/DATAFILE/SYSTEM.269.836688969
+CDB1dg/cdb2/pdbseed_temp01.dbf => +CDB1DG/CDB2/EFC6F3C9DA62745DE043C838A8C0C436/TEMPFILE/TEMP.271.836688993
--再或者将源路径具体化到datafile的上三层路径后创建也能成功:
SQL> create pluggable database pdb21 admin user pdb21_admin identified by 773946 roles=(connect) file_name_convert=('+CDB1DG/CDBS/','+CDB1DG/');
*
ERROR[C1] at line 1:
ORA-00604: error occurred at recursive SQL level
ORA-19504: failed to create file "+CDB1DG/CDB21/cdb2/pdbseed_system01.dbf"
--创建出+CDB1DG/cdb21/cdb2的目录后,执行成功:
ASMCMD> cd +CDB1DG/
ASMCMD> mkdir cdb21
ASMCMD> mkdir cdb21/cdb2
ASMCMD> ls -ld +cdb1dg/cdb21/cdb2
Type Redund Striped Time Sys Name
N cdb2/
SQL> create pluggable database pdb21 admin user pdb21_admin identified by 773946 roles=(connect) file_name_convert=('+CDB1DG/CDBS/','+CDB1DG/');
Pluggable database created.
结论:DBCA方式下输入的只是目标路径,oracle能自动识别PDB$SEED的存储源路径并逐个数据文件的与目标路径下的数据文件形成一一对应关系,而手动方式创建时若源和目标路径完全一样时会引导oracle将目标pdbfile覆盖源文件,从而报错,正确的方式是指定到源数据文件的上N层路径、且当N>1时必须要保证目标DG下事先要有这个目录。
场景二(DBCA):输入” +CDB2DG/pdb21/”作为创建路径(或者”+CDB2DG/pdb21”也可),Oracle生成的创建语句如下:
CREATE PLUGGABLE DATABASE pdb21 ADMIN USER pdb21_admin IDENTIFIED BY * ROLES=(CONNECT) file_name_convert=('+CDB1DG/CDBS/CDB21/cdb2/pdbseed_system01.dbf','+CDB2DG/pdb21//pdb21_system01.dbf',
'+CDB1DG/CDBS/CDB21/cdb2/pdbseed_sysaux01.dbf','+CDB2DG/pdb21//pdb21_sysaux01.dbf','+CDB1DG/CDBS/CDB21/cdb2/pdbseed_temp01.dbf','+CDB2DG/pdb21//pdb21_temp01.dbf')
场景二(Manual):手工指定” +CDB2DG/pdb21/”作为目标路径:
CREATE PLUGGABLE DATABASE pdb21 ADMIN USER pdb21_admin IDENTIFIED BY * ROLES=(CONNECT) file_name_convert=('+CDB1DG/CDBS/CDB21/cdb2/','+CDB2DG/pdb21/[C2] ');
Pluggable database created.
结论:DBCA方式下输入的目标路径可以不带/,但手工方式下输入的目标路径必须带/。
场景三(DBCA):在ORA12C下创建名为orapdbc的pdb,指定+SYSDG作为目标路径,Oracle生成的创建语句如下:
CREATE PLUGGABLE DATABASE orapdbc ADMIN USER c_admin IDENTIFIED BY * ROLES=(CONNECT) file_name_convert=('+DATADG1/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/system.269.828826479','+SYSDG/orapdbc_system.dbf','+DATADG1/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/sysaux.268.828826479','+SYSDG/orapdbc_sysaux.dbf','+DATADG1/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/pdbseed_temp01.dbf','+SYSDG/orapdbc_temp01.dbf')
场景三(Manual):在ORA12C下手工创建名为orapdbc的pdb,指定+SYSDG作为目标路径
CREATE PLUGGABLE DATABASE orapdbc ADMIN USER c_admin IDENTIFIED BY 773946 FILE_NAME_CONVERT=('+DATADG1', '+SYSDG') STORAGE UNLIMITED;
CREATE PLUGGABLE DATABASE orapdbc ADMIN USER c_admin IDENTIFIED BY 773946 FILE_NAME_CONVERT=('+DATADG1', '+SYSDG') STORAGE UNLIMITED
*
ERROR[C3] at line 1:
ORA-01119: error in creating database file
'+SYSDG/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/pdbseed_temp01.dbf'
ORA-17502: ksfdcre:4 Failed to create file
+SYSDG/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/pdbseed_temp01.dbf
ORA-15173: entry 'DD7C48AA5A4404A2E04325AAE80A403C' does not exist in directory
'ORA12C'
---手工创建"+SYSDG/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/"目录后再次执行后成功:
SQL> CREATE PLUGGABLE DATABASE orapdbc ADMIN USER c_admin IDENTIFIED BY 773946 FILE_NAME_CONVERT=('+DATADG1', '+SYSDG/');
Pluggable database created.
————查看orapdbc的文件路径,发现temp文件被当做了一个user-generated file指向TEMPFILE目录————
+SYSDG/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/pdbseed_temp01.dbf=> +SYSDG/ora12c/EFC2E36477614330E0436438A8C0565D/TEMPFILE/TEMP.259.836672729
+sysdg/ora12c/EFC2E36477614330E0436438A8C0565D/datafile/SYSAUX.257.836672687
+sysdg/ora12c/EFC2E36477614330E0436438A8C0565D/datafile/SYSTEM.258.836672671
--或者将源路径指定到上一层的方式,也能成功:
SQL> CREATE PLUGGABLE DATABASE orapdbc ADMIN USER c_admin IDENTIFIED BY 773946 FILE_NAME_CONVERT=('+DATADG1/ORA12C/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/', '+SYSDG/');
Pluggable database created.
————查看orapdbc的文件路径,发现temp文件被当做了一个user-generated file指向TEMPFILE目录————
+SYSDG/ORA12C/EFC7FFC41D766A8BE0436438A8C0873B/DATAFILE/system.258.836693083
+SYSDG/ORA12C/EFC7FFC41D766A8BE0436438A8C0873B/DATAFILE/sysaux.257.836693099
+sysdg/pdbseed_temp01.dbf => +SYSDG/ORA12C/EFC7FFC41D766A8BE0436438A8C0873B/TEMPFILE/TEMP.259.836693141
结论:DBCA方式下只要确保目标路径存在总能成功,而手工方式下遇到system、sysaux这类System generated的文件是没有链接的,tempfile不知为何被当成了user generated的文件了,通过一个链接才指向真正的文件。使用DBCA创建完后pdb会被自动的open,Manual方式不会
[C1]此处报错是因为没有'+CDB1DG/cdb21/cdb2’目录
[C2]手工创建时,子目录后面一定要加/,否则建出来的就是连在一起的格式:+CDB2DG/pdb21pdbseed_system01.db
[C3]数据文件能自动转换至新生成的+SYSDG/ora12c/EFC2E36477614330E0436438A8C0565D/目录下,temp文件却不能
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/53956/viewspace-1312407/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/53956/viewspace-1312407/