داشتم از ویژگی کلون گیری آنلاین PDBها (Cloning a Remote PDB یا در RMAN HOTCLONE) برای انتقال PDBها از سرور قدیمی به سرور جدید که از نسخه 12.1.0.1 به بعد ارائه شده بود طبق مقاله Multitenant : Duplicate a Pluggable Database (PDB) to an existing Container Database (CDB) in Oracle Database 18c از دوست عزیزمون آقای Tim Hall استفاده میکردم که با خطای ORA-15122: ASM file name string contains an invalid file number مواجه شدم.

محیط من شامل

سیستم عامل:

Oracle Linux Server release 8.4

دیتابیس سورس:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.13.0.0 with File System

دیتابیس مقصد:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.13.0.0 with File System ASM

طبق مقاله آقای Tim Hall ابتدا اتصال امون رو با rman به سرور اصلی و کمکی برقرار میکنیم (با این تفاوت که لاگ و دیباگ رو روشن میکنیم)

(در اینجا CDB1 سرور اصلی (سورس) و CDB2 سرور کمکی (auxiliary) است - اضافه کردن UR = A در TNS فراموش نشه!!)

rman target sys/<password-sys>@CDB1 auxiliary sys/<password-sys>@CDB2 log /tmp/pdb_clone.log trace /tmp/pdb_clone.trc debug

بعد از اتصال موفق دستور زیر رو برای شروع کلون گیری در rman اجرا میکنیم.

RMAN> duplicate pluggable database TESTDB AS TESTDB TO FMSDB from active database section size 400M;

Starting Duplicate PDB at 11-APR-22
using channel ORA_AUX_DISK_1
current log archived
duplicating Online logs to Oracle Managed File (OMF) location
duplicating Datafiles to Oracle Managed File (OMF) location
current log archived

contents of Memory Script:
{
set newname for clone datafile 67 to new;
set newname for clone datafile 68 to new;
set newname for clone datafile 69 to new;
set newname for clone datafile 70 to new;
set newname for clone datafile 71 to new;
set newname for clone datafile 72 to new;
set newname for clone datafile 73 to new;
set newname for clone datafile 103 to new;
set newname for clone datafile 104 to new;
restore
from nonsparse section size
400 m clone foreign pluggable database
"TESTDB"
from service 'CDB1' ;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 11-APR-22
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service CDB1
RMAN-03009: failure of IRESTORE command on ORA_AUX_DISK_1 channel at 04/11/2022 16:32:32
ORA-19504: failed to create file "+DATA"
ORA-17502: ksfdcre:4 Failed to create file +DATA
ORA-15122: ASM file name '+DATA/FMSDB/DATAFILE/.573.1101745953' contains an invalid file number
ORA-19660: some files in the backup set could not be verified
ORA-19661: datafile 67 could not be verified
ORA-19504: failed to create file "+DATA"
ORA-17502: ksfdcre:4 Failed to create file +DATA
ORA-15122: ASM file name '+DATA/FMSDB/DATAFILE/.573.1101745953' contains an invalid file number

این احتمال رو دادم که خطای ORA-15122 ممکنه به خاطر مسیرها باشه و استفاده از db_file_name_convert در دستور duplicate ممکنه ایده خوبی باشه. با این حال همچنان خطا رو مشاهده کردم:

	
RMAN> duplicate pluggable database TESTDB AS TESTDB TO FMSDB DB_FILE_NAME_CONVERT('/data1/oracle/oradata/FMSDB/fmstestdb/','+DATA/', '/u02/oracle/oradata/FMSDB/B9DE26AFFC1E70D3E05301A4A8C08482', '+DATA/') from active database section size 400M;

Starting Duplicate PDB at 11-APR-22
using channel ORA_AUX_DISK_1
current log archived
duplicating Online logs to Oracle Managed File (OMF) location
current log archived

contents of Memory Script:
{
set newname for datafile 67 to
"+DATA/datafile/o1_mf_system_j127c41r_.dbf";
set newname for datafile 68 to
"+DATA/datafile/o1_mf_sysaux_j127c424_.dbf";
set newname for datafile 69 to
"+DATA/datafile/o1_mf_undotbs1_j127c425_.dbf";
set newname for datafile 70 to
"+DATA/datafile/o1_mf_shp_data_j127c426_.dbf";
set newname for datafile 71 to
"+DATA/datafile/o1_mf_shp_inde_j127c427_.dbf";
set newname for datafile 72 to
"+DATA/datafile/o1_mf_shp_arch_j127c428_.dbf";
set newname for datafile 73 to
"+DATA/datafile/o1_mf_users_j127c429_.dbf";
set newname for datafile 103 to
"+DATA/TESTDB_dbs1.dbf";
set newname for datafile 104 to
"+DATA/TESTDB_dbs2.dbf";
restore
from nonsparse section size
400 m clone foreign pluggable database
"TESTDB"
from service 'CDB1' ;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 11-APR-22
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service CDB1
RMAN-03009: failure of IRESTORE command on ORA_AUX_DISK_1 channel at 04/11/2022 21:14:05
ORA-19504: failed to create file "+DATA/datafile/o1_mf_system_j127c41r_.dbf"
ORA-17502: ksfdcre:4 Failed to create file +DATA/datafile/o1_mf_system_j127c41r_.dbf
ORA-15122: ASM file name '+DATA/FMSDB/DATAFILE/.573.1101762845' contains an invalid file number
ORA-19660: some files in the backup set could not be verified
ORA-19661: datafile 67 could not be verified
ORA-19504: failed to create file "+DATA/datafile/o1_mf_system_j127c41r_.dbf"
ORA-17502: ksfdcre:4 Failed to create file +DATA/datafile/o1_mf_system_j127c41r_.dbf
ORA-15122: ASM file name '+DATA/FMSDB/DATAFILE/.573.1101762845' contains an invalid file number
continuing other job steps, job failed will not be re-run
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service CDB1
RMAN-03009: failure of IRESTORE command on ORA_AUX_DISK_1 channel at 04/11/2022 21:14:05
ORA-19504: failed to create file "+DATA/datafile/o1_mf_sysaux_j127c424_.dbf"
ORA-17502: ksfdcre:4 Failed to create file +DATA/datafile/o1_mf_sysaux_j127c424_.dbf
ORA-15122: ASM file name '+DATA/FMSDB/DATAFILE/.573.1101762847' contains an invalid file number

خب اینجاست که بعد از جستجوهای زیاد به باگ زیر رسیدم

Bug 32606531 : ASM FILESYEM: RESTORE FOREIGN TABLESPACE/PDB FROM SERVICE SECTION SIZE IS FAIING BUT SUCCESSFULL WITH NON-MULTISECTION

این باگ در فایل سیستم ASM موقع ریستور کردن یک Tablespace خارجی و یا یک PDB از سرویس با وجود دستور SECTION SIZE رخ میده که همونطور که اشاره شده بدون این دستور و به صورت NON-MULTISECTION عملیات موفقیت آمیز است.

پس یکبار دیگه دستور رو بدون section size اجرا میکنم:

$ rman target sys/<password>@target auxiliary sys/<password>@auxiliary log /tmp/pdb_clone.log trace /tmp/pdb_clone.trc debug
RMAN> duplicate pluggable database TESTDB AS TESTDB TO FMSDB from active database;

و بدون مشکل عملیات کلون گیری انجام میشه.

اگه به خطای ORA-04021: timeout occurred while waiting to lock object برخورد کردید بهتره این کار رو در زمانی که کمترین سینشها در دیتابیس درگیر هستند دوباره امتحان کنید.

RMAN> duplicate pluggable database TESTDB AS TESTDB TO FMSDB from active database;
Starting Duplicate PDB at 11-APR-22
using channel ORA_AUX_DISK_1
current log archived
duplicating Online logs to Oracle Managed File (OMF) location
current log archived
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate PDB command at 04/11/2022 23:03:29
RMAN-05501: aborting duplication of target database
RMAN-06136: Oracle error from auxiliary database: ORA-17628: Oracle error 4021 returned by remote Oracle server
ORA-04021: timeout occurred while waiting to lock object

مقالات جهت کلون گیری

https://oracledbwr.com/cloning-a-remote-pluggable-database-pdb-in-oracle-database-12c-release-2

https://oracle-base.com/articles/18c/multitenant-duplicate-a-pdb-to-an-existing-cdb-18c

https://oracle-base.com/articles/12c/multitenant-hot-clone-remote-pdb-or-non-cdb-12cr2