Sie sind auf Seite 1von 6

Backup The Source Database

In order to copy the database to another location (e.g. as in a refresh of production data into
development) either a full backup or an online backup must be taken of the source
database. A full backup is defined as a physical copy of the database files after a normal
shutdown of the database. An online backup is defined as a physical copy of all the database
datafiles while the database is open and operational. It should be noted that there are specific
procedures that should be followed when taking an online backup (e.g. ALTER TABLESPACE
... BEGIN/END BACKUP). See the Oracle documentation on backups and recovery for further
details. Additionally, an online backup will require the source database's archived redo log
files from the point of the first datafile backup through the last datafile backup.

In addition to all database datafiles, the init.ora and an ASCII copy of the control file for the
source database will be needed. The actual control files are not needed as the ASCII copy will
be used to create a new control file to be used with the new database, and the online redo log
files are not needed as the new database will be created with the RESETLOGS command.
File permissions and ownership should be noted and this should be accounted for when
performing the backup and restore.

The following commands will create the ASCII control file (these commands should be issued
from the source database):

svrmgrl
SVRMGR> connect internal
SVRMGR> alter database backup controlfile to trace;
SVRMGR> exit

This will create a trace file in the user dump directory of the source database on the database
server. This file can now be edited in order to create the SQL script that will be necessary in
later steps. The appropriate changes needed are detailed in the section "Create Control File
Script" section.

Create The Target UNIX Environment

All database file directories will need to be created in the target environment. It should be
noted that these directories do not need to be named the same as the source database's
directories. The Oracle Server software should be equivalent (e.g. $ORACLE_HOME) to that
used for the source database.

The $ORACLE_BASE/admin directory, and its sub-directories, for the new database should
also be created to provide a destination for the dump and configuration directories (see OFA
standards).

Restore The Source Files To The Target Machine

Once the source database backup has been completed the files backed up can be restored
into the desired directories on the target machine. File ownership and permissions should be
verified after the restore. If there was an existing database that will be overwritten this
database should be shutdown and backed up. Don't forget to shut down the concurrent
manager processes also. Once backed up, the datafiles, control files, and online redo log files
associated with the database to be refreshed can be deleted. All trace files can also be
removed and if there are archive log files they should be backed up to tape and deleted.

Create Control File Script

After the source database's datafiles have been restored to their target directories, or these
directories are known, the ASCII control file that was created can be modified. The following
changes will need to be made:

1. Remove all comments from the file (the Version 7.1 Server Manager product does not
support comments).
2. Rename the online redo log files and data files' directories to their new names.
3. Replace the option REUSE DATABASE <dbname> with SET DATABASE
<new_dbname> where <dbname> is the source database name and
<new_dbname> is the new target database name.

Note: We now recommend removing the REUSE option to avoid errors when
increasing the size of the controlfile.

4. Replace NORESETLOGS with RESETLOGS. Required when the SET DATABASE


command is used.
5. Verify that the ARCHIVELOG or NOARCHIVELOG option is appropriate for the
target database.
Note: ARCHIVELOG will be required if an online backup was made.

6. Remove all further comments and commands. This includes the RECOVER
DATABASE command and the ALTER DATABASE OPEN command at the bottom of
the file.
7. Save this file as a SQL script with a name like new_control.sql. It is probably easiest
to locate this file in the $ORACLE_HOME/dbs directory of the target database.

The following is a Sample new_control.sql

STARTUP NOMOUNT;
CREATE CONTROLFILE SET DATABASE <new_dbname> RESETLOGS NOARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 512
MAXINSTANCES 16
MAXLOGHISTORY 1600
LOGFILE
GROUP 1 '/u01/oradata/<new_dbname/log01a.rdo' SIZE 20M,
GROUP 2 '/u02/oradata/<new_dbname/log02a.rdo' SIZE 20M
DATAFILE
'/u01/oradata/<new_dbname/system01.dbf',
'/u01/oradata/<new_dbname/tools01.dbf',
'/u01/oradata/<new_dbname/users01.dbf',
'/u02/oradata/<new_dbname/rbs01.dbf',
'/u03/oradata/<new_dbname/temp01.dbf'

Modify The init.ora

At this point either the old target database init.ora file or the init.ora file that was saved from
the source database can be used, depending on desired parameter settings and the changes
necessary. In either case the following items need to be verified/changed:

1. Change/verify all directory names.


2. Change/verify the "db_name =" parameter.
3. Change/verify mts parameters.
Rename The Target Database

We are now ready to start the database and rename it to the target name.

1. Create the new control file and rename the database:

Verify that the $PATH, $ORACLE_HOME, and $ORACLE_SID environment


variables are all set for the target database.

cd $ORACLE_HOME/dbs
svrmgrl
SVRMGR> connect internal
SVRMGR> @new_control.sql

2. At this point the instance is running and the database has been renamed to the new
target name. The next step varies depending on whether a full backup or an online
backup was performed.

Full Backup:

1. SVRMGR> ALTER DATABASE OPEN RESETLOGS;

Online Backup:

1. SVRMGR> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL


CANCEL;

This command will result in the database prompting for archive redo log files.
The archived redo log files that were created during the online backup should
be applied and then the command CANCEL should be issued to terminate
recovery. The following is a short example:

SVRMGR> recover database using backup controlfile until


cancel;
ORA-00279: Change 7239 generated at 05/21/99 10:26:19
needed for thread 1
ORA-00289: Suggestion : /oracle/admin/copy7/arch/arch_9
ORA-00280: Change 7239 for thread 1 is in sequence #9
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Log applied.
ORA-00279: Change 7244 generated at 05/21/99 10:39:07
needed for thread 1
ORA-00289: Suggestion : /oracle/admin/copy7/arch/arch_10
ORA-00280: Change 7244 for thread 1 is in sequence #10
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SVRMGR>
2. SVRMGR> ALTER DATABASE OPEN RESETLOGS;
2. At this point the database is now open and running. The database global name
should be changed (ALTER DATABASE RENAME GLOBAL_NAME TO
<dbname.domain_name;) and all database links should be checked for
appropriateness.
3. Perform a full or online backup of the newly restored/renamed database.

Miscellaneous Database Environment Issues

Update oratab File

The oratab file should be updated appropriately with the new database's information.

Update SQL*Net Files

1. Server Files

listener.oraThe listener.ora file must be updated to reflect the addition of the new
database.

tnsnames.oraThe tnsnames.ora file should be updated to add the connect string for the
new database. This will allow IPC connections from client tools on the server and other
databases on the server to connect through database links.
2. Client Files

tnsnames.oraThe tnsnames.ora file must be updated to add the connect string for the
new database.

Das könnte Ihnen auch gefallen