How do I copy an Oracle DB from one server to another?
I want to copy an Oracle database from one server to another. I'm going to save the entire database into a CD and copy the exact database to another server.
For the same server and operating system do the following. The DB will have the same name as the original.
If you want to change the DB name or directories, you must run the
- Shut source database down with the NORMAL or IMMEDIATE option.
- Copy all datafiles. Select the name from
v$datafile;
to get their names. - Copy all online redo logs. Select the member from
v$logfile;
to get their names. - Copy all control files. Select the name from
v$controlfile;
to get their names. - Copy the parameter file. Find it in
$ORACLE_HOME/dbs
in Unix and$ORACLE_HOME/database
in Windows. The name isinitDBNAME.ora
whereDBNAME
is database name. - All of the files must be placed in directories that have same name as the source server directories. The names returned from the queries above are fully qualified with directory names.
- Create all of the directories specified in the parameter file you just copied. It will be
BDUMP, CDUMP, UDUMP
. Just recreate all of the directories you find specified in your parameter file. - Edit the parameter file you copied. Set
REMOTE_LOGIN_PASSWORDFILE to NONE
if it is set SHARED or EXCLUSIVE. - Start the database up.
- If you use a true temporary tablespace for sorting, you will have to recreate it. The database will still start, but the first sort that writes to it will bomb. Simple syntax is in the manuals.
- To use remote authentication again, run
ORAPWD
. Here's the syntax:orapwd Usage: orapwd file=
where:password= entries=
file = name of password file (mand)
password = password for SYS (mand)
entries = maximum number of distinct DBAs and OPERs (opt).
There are no spaces around the equal-to (=) character - Edit the parameter file to set
REMOTE_LOGIN_PASSWORDFILE
to SHARED or EXCLUSIVE (depending on what it was set to before). - Restart the DB for it to take affect.
If you want to change the DB name or directories, you must run the
CREATE CONTROLFILE
statement. You'll have to read the manual on that one; it is about 30 steps. Or you can do the following.- Create a database with a new name on the target server. Make it any database name you want with any directories you want.Since we will be using Export/Import, you will need to know this information:
- You must precreate the tablespaces if you are going to change directory names for your data files. Oracle looks for directory names during the IMPORT when it tries to create the TABLESPACES.
- If it can't find the directories, they will blow up.
- If you precreate them (anywhere you want), Oracle will know that the tablespaces are there and load them up with data. It won't blow up because it won't attempt to create them.
- Export the data from the source database. Set
ORACLE_SID
to source database name.exp system/manager file=full_export_dump.dmp log=full_export_log.out full=y
(We'll take defaults with everything else.) - Copy
full_export_dump.dmp
to the target server. - Import the data into the target database. Set
ORACLE_SID
to the target database name.imp system/manager file=full_dump.dmp log=full_import_log.out full=y ignore=y
You only need to useignore=y
if your tablespaces are precreated. That means the database will ignore the "already exists" error that will be returned when it finds the tablespace is already there.
No comments:
Post a Comment