+ All Categories
Home > Documents > INTRODUCTION TO ORACLE Lynnwood Brown President System Managers LLC Data Loading & Backup And...

INTRODUCTION TO ORACLE Lynnwood Brown President System Managers LLC Data Loading & Backup And...

Date post: 22-Dec-2015
Category:
Upload: gerald-blankenship
View: 215 times
Download: 1 times
Share this document with a friend
24
INTRODUCTION TO ORACLE Lynnwood Brown President System Managers LLC Data Loading & Backup And Recovery Lecture 5 Copyright System Managers LLC 2003 all rights reserved.
Transcript

INTRODUCTION TO ORACLE

Lynnwood BrownPresident System Managers LLC

Data Loading & Backup And Recovery Lecture 5

Copyright System Managers LLC 2003 all rights reserved.

DATA LOADING

Use the EXPORT/IMPORT utilities to move bulk data from one Oracle database into another Oracle database.

• Logical backup – Saves the data and the DDL used to create the database objects

• Migration Tool

• Online documentation - C:\> exp{imp} help=y

Data can also be loaded using SQL*PLUS “INSERT” commands or the Oracle utility SQL*LOADER.

DATA LOADING

Types Of Exports.

• Full Export– EXP system/manager file = exp.dat full = y log =

exp.log

• User Level Export– EXP system/manager file = exp.dat owner = scott log =

exp.log

• Table Level Export– EXP scott/tiger file = exp.dat TABLES=(emp,dept) log

= exp.log

DATA LOADING

Types Of Imports.

• Full Import– IMP system/manager file = exp.dat full = y log =

imp.log commit = y

• User Level Import– IMP system/manager file = exp.dat fromuser=scott

touser=scott log = imp.log commit = y

• Table Level Import– IMP scott/tiger file = exp.dat TABLES=(emp.dept) log

= imp.log commit = y

DATA LOADING cont.

SQL*LOADER - Oracle utility used to load external file data into Oracle database tables

• Used when large amounts of data must be loaded.

• Loads data contained in a data file into one or more tables

• Requires a SQL*LOADER control file

Copyright System Managers LLC 2003 all rights reserved.

DATA LOADING cont.

SQL*LOADER Syntax:

C:\> sqlldr scott/tiger control=my_control_file.ctl log=my_load.log

Data File Contents – file name = ubs.dat

930|1058|Edward S.Eng|ibm 931|2157|John Ford|hp932|1457|Melanie Goldman|msft933|1657|Jane Williams|dell

Copyright System Managers LLC 2003 all rights reserved.

DATA LOADING cont.

SQL*LOADER Control File – Tells the loader how to how to interpret the data file:

LOAD DATAINFILE 'ubs.dat'BADFILE 'ubs2.bad'DISCARDFILE 'ubs2.dsc'APPENDINTO TABLE ubs.table_customerFIELDS TERMINATED BY '|'OPTIONALLY ENCLOSED BY '"'TRAILING NULLCOLS(CUST_NO, SITE_NO, CUST_NAME ,SITE_ ABBREV)

DATA LOADING cont.

SQL*LOADER Control File – Tells the loader how to load the data:

• INFILE – File containing the data to be loaded

• BADFILE – Records that are rejected go into this file

• DISCARDFILE – Records that do not meet a loading criteria

Data can be appended onto existing data, inserted or replaced - APPEND/INSERT/REPLACE

DATABASE BACKUP

Used if the database needs to be recovered due to a hardware or end user created failure. Types of database backups include:

Logical Backup – Uses IMPort/EXPort. Often used to recover dropped tables. Saves the data.

Physical Backup – Used to recover the database from hardware failures. Saves the databases data files. Either COLD or HOT.

Copyright System Managers LLC 2003 all rights reserved.

DATABASE MODES

• Database is running in ARCHIVELOG mode

• When the active log file becomes filled a log switch is signaled

• LGWR process switches to writing to the next log file

• The ARCH process saves the active log file to offline storage

SGA

ARCHLGWR

DataRedo LogFiles

Data

ArchivedRedo Log

Files

OnlineStorage

OfflineStorage

Copyright System Managers LLC 2003 all rights reserved.

DATABASE BACKUP

Cold physical backup - Backup that is taken when the database is shutdown.

• Save data files, log files and control files.

• How to find the location of the files:

SQL > select member from v$logfile;SQL > select file_name from sys.dba_data_files;SQL > select name from v$control_files;

DATABASE BACKUP cont.

Hot backup - Backup taken while the database is up (end users can also access the database during the backup).

• Requires that the database be run in ARCHIVELOG mode – Check v$database

• Redo log files are moved to offline storage when they fill up.

• Redo log files are moved to offline storage by the ARCH process.

DATABASE BACKUP

• DBA needs to monitor the offline storage to make sure that it does not fill up.

• Save “archived log files” using OS copy command.

• Delete archived log files from the archive directory.

Copyright System Managers LLC 2003 all rights reserved.

DATABASE BACKUP

• Save tablespace data files using “ALTER TABLESPACE BEGIN/END BACKUP” AND OS copy command.

• Save database control file by using the ‘ALTER DATABASE BACKUP CONTROLFILE “ command.

Copyright System Managers LLC 2003 all rights reserved.

DATABASE BACKUP

• Save The data files:SQL > alter tablespace system begin backup;

SQL > HOST copy c:\oracle\system01.dbf C:backup

SQL > alter tablespace system end backup;

SQL > alter database backup controlfile to ‘c:\backup\control_backup.ctl';

SQL > alter system switch logfile;

SQL > quit

• Save ARCHIVELOG files

Copyright System Managers LLC 2003 all rights reserved.

DATABASE RECOVERY

• Recovery using a cold backup. Restore data files, log files and the control files to their original location.

• Startup the database.

• System is recovered to the last cold backup.

Copyright System Managers LLC 2003 all rights reserved.

DATABASE RECOVERY cont.

• Recovery using a hot backup. Recovers the database to the point in time of failure.

• Requires access to both online and offline log files.

• After issuing either RECOVER DATABASE, RECOVER TABLESPACE or RECOVER DATAFILE the Oracle recovery management will prompt for the locations of the archivelog files.

Copyright System Managers LLC 2003 all rights reserved.

DATABASE RECOVERY cont.

• Oracle recovery process uses the contents of the control file to determine which ARCHIVELOG files are required for the recovery

• The SMON process will:

– Perform roll forward recovery using the data in the log files.

– Perform rollback recovery by applying the data from the rollback segments to UNDO uncommitted changes

DATABASE BACKUP

• Recovery Manager (RMAN) is an Oracle utility introduced in Oracle8

• RMAN types of physical database backups: 

– Block level backup and recovery– Hot and cold backups– Full and incremental backups

• Optional recovery catalog

DATABASE BACKUP – Recovery Manager

Ethernet

Production Server

Database Files

Data FilesLog FilesControl FilesArchived Log Files

Tape Drive

RMAN Catalog Server(optional)

RMAN Catalog

DATABASE BACKUP

RMAN can be used with or without a recovery catalog. If no recovery catalog is used then all information required for recovery is obtained from the databases control files.

Connecting to RMAN with a recovery catalog:

rman target sys/manager123 rcvcat rman/rman@cat_alias

Connecting to RMAN without a recovery catalog:

rman target sys/manager123 nocatalog

Copyright System Managers LLC 2003 all rights reserved.

DATABASE BACKUP

• RMAN Backup Script:

run { allocate channel dev1 type disk; backup incremental level 0 tag = 'full backup' database include current controlfile format = 'c:\rbackup\db_t%t_s%s_p%p'; sql "alter system switch logfile"; backup format = 'c:\rbackup\ar_t%t_s%s_p%p' archivelog all; release channel dev1; } exit

Copyright System Managers LLC 2003 all rights reserved.

DATABASE RECOVERY

• RMAN Recovery Script:

run {

allocate channel dev1 type disk;

alter database mount;

restore database;

recover database;

sql "ALTER DATABASE OPEN RESETLOGS";

}

 

exit

Copyright System Managers LLC 2003 all rights reserved.

DATABASE BACKUP/RECOVERY

To run an RMAN script from the command prompt:

c:\> rman target sys/not4u cmdfile c:\scripts\backup\hot_rman_bkup_lvl0.rcv msglog c:\rbackup\current_rman_lvl0.log nocatalog

TARGET – Use the current setting for ORACLE_SID as the database to be backed up.

 CMDFILE – RMAN script that is used to backup the database MSGLOG – File where messages that are written during the time of backup are

written NOCATALOG – Tells RMAN that this backup is being performed without a

recovery catalog


Recommended