Introduction
Multitenant brings new possibilities regarding Oracle databases, and one of them is to move a database from a container to another quite easily. When containers are on the same server, it’s very easy, but when the containers are on different servers, you will need to use a database link or an RMAN restore. But there is also another solution if you don’t want to use the previous ones: using a NFS volume.
Test lab
All these tests were done between 2 ODAs: one X8-2M and one X7-2M, both running the same patch version (19.12). This is important to run the same DB home version as moving PDB between different container versions will need to patch the database if the destination container is newer, and I’m not sure you can downgrade the PDB if its new container runs an older version.
My 2 containers are both using ASM, and as you may know, ODA is nothing else than an x86_64 server running Linux 7, so this should be the same on any other Linux boxes.
Requirements for the shared NFS volume
As you will temporarily move the PDB to this shared NFS volume, you will need special mount options when mounting your volume. Here is an example:
echo "192.168.61.50:/nfsoracle /u01/nfsdir/ nfs rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0,vers=3,timeo=600" >> /etc/fstab
mount -a
1st step, move the PDB to the NFS volume
The goal being to move the PDB to another server, let’s do a clean shutdown of the PDB on the source server:
. oraenv <<< POCCDB
sqlplus / as sysdba
show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 POCPDB READ WRITE NO
4 GOTAFO READ WRITE NO
alter pluggable database GOTAFO close immediate;
show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 POCPDB READ WRITE NO
4 GOTAFO MOUNTED
exit
Now let’s move this PDB to the NFS share:
rman target /
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
backup as copy pluggable database GOTAFO format '/u01/nfsdir/DUMPS/move_pdb/%U';
}
Switch pluggable database GOTAFO to copy;
exit;
Now my PDB datafiles are located on the NFS share, and my files on ASM are flagged as backup copies of my datafiles.
Let’s unplug this PDB, XML file being also put in this NFS share:
sqlplus / as sysdba
alter pluggable database GOTAFO unplug into '/u01/nfsdir/DUMPS/move_pdb/GOTAFO.xml';
drop pluggable database GOTAFO keep datafiles ;
show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
4 POCPDB. READ WRITE NO
exit
PDB doesn’t belong anymore to this container.
2nd step, plug the PDB to the new container
On the target server having the same NFS share mounted, let’s plug this PDB:
. oraenv <<< POCCDB
sqlplus / as sysdba
create pluggable database GOTAFO using '/u01/nfsdir/DUMPS/move_pdb/GOTAFO.xml';
exit;
Datafiles now need to move from NFS to ASM, let’s do that with RMAN:
rman target /
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
backup as copy pluggable database GOTAFO format '+DATA';
}
Switch pluggable database GOTAFO to copy;
exit;
Now database is located in ASM, and files on the share are identified as backup copies of my datafiles.
3rd step, open the PDB and check if everything is OK
Let’s open the PDB and check if datafiles are in ASM as expected:
sqlplus / as sysdba
alter pluggable database GOTAFO open;
alter pluggable database GOTAFO save state ;
alter session set container=GOTAFO ;
select file_name from dba_data_files;
FILE_NAME
----------------------------------------------------------------------------------
+DATA/POCCDB_DRP/D046C4A6F65A7268E0534401C80AC247/DATAFILE/system.908.1090162863
+DATA/POCCDB_DRP/D046C4A6F65A7268E0534401C80AC247/DATAFILE/sysaux.909.1090162863
+DATA/POCCDB_DRP/D046C4A6F65A7268E0534401C80AC247/DATAFILE/undotbs1.906.1090162863
+DATA/POCCDB_DRP/D046C4A6F65A7268E0534401C80AC247/DATAFILE/users.603.1090162863
+DATA/POCCDB_DRP/D046C4A6F65A7268E0534401C80AC247/DATAFILE/test.907.1090162863
Everything is OK, and PDB is running fine.
Conclusion
If you don’t want to use database links between your databases, or if you don’t want to restore a container on your target server, this method works and it may help.