I read a lot about the flexibility of Oracle commands for pluggable databases.
I haven’t seen as much about the old fashioned way to copy data files around and
manually creating a control file. So lets see if that still works. I have a
campus solutions demo instance, lets see if I can copy it and rename it.
I can see the data files are stored under /opt/oracle/db/oradata/DBNAME
where DBNAME is the name of the database. The container is CDBCS, then
there is the pluggable database at the same level. So I decided to copy all the
files but rename
the directories for the database I am going to create, but still keep the same
structure. I have a habit, when
running the create control file command by hand, of checking the files are
all correct using the following:
find /d16/MYDB -type f |whileread aline
doif grep -q $aline cont.sql
then :
elseecho$aline missing
fidone
This returns a couple of lines buy they aren’t data files, so I am happy to run
the create control file command.
Creating the New Database
First I need a pfile. The create
pfile from spfile command still works, so the init.ora can be used as a basis.
Once the spfile has been sorted out, we can create the control file.
startup nomount
CREATE CONTROLFILE SET ...
Control file created.
ORA-00279: change 208737729generatedat09/16/202014:31:19 needed for thread 1ORA-00289: suggestion : ...
ORA-00280: change 208737729for thread 1isin sequence #278
Oh dear - it seems we need recovery. I haven’t worked out why this happens when
the database seems to have been shut down cleanly, but I fix it by pointing
the recovery process at the online redo logs.
So I use the command that is seared onto my brain:
I can add in the temp files to the container and seed databases. These
commands are copied and pasted directly from the generated create controlfile SQL.
$ nid target=/ pdb=all
DBNEWID: Release 19.0.0.0.0 - Production on Wed Oct 7 14:46:57 2020
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Connected to database MYCONT (DBID=897177241)
Connected to server version 19.8.0
Control Files in database:
/path/to/control01.ctl
Change database ID of database MYCONT? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 897177241 to 3350210145
Control File /path/to/control01.ctl - modified
Datafile /path/to/system01.db - dbid changed
...
Datafile /path/to/pdbseed/temp012020-07-31_15-00-20-947-PM.db - dbid changed
Datafile /path/to/temp01.db - dbid changed
Datafile /path/to/pstemp01.db - dbid changed
Datafile /path/to/psgtt01.db - dbid changed
Control File /path/to/control01.ctl - dbid changed
Instance shut down
Database ID for database MYCONT changed to 3350210145.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
Even with the new technology of pluggable databases, we can still use the old
methods of shutting the database down, copying it, and recreating the controlfile
to create a copy. We can also rename the pluggable database to suit our needs.