Course Overview
The environment The architecture An Oracle Instance An Oracle Database How to startup and shutdown the instance Database creation Database access
Course Overview
Archive and noarchivelog log mode Database Backup Database Recovery Import and export utilities Parallel server Questions and Answers
Environment Variables
ORACLE_HOME ORACLE_SID ORACLE_BASE (OPTIONAL)
Product directory
/oracle/<version>/product
/rdbms
/admin /sql scripts for data dictionary /oracle, oracle0, exp , imp, svrmgrl, sqlplus
/bin
/dbs
/init<SID_NAME>.ora, config<SID_NAME>.ora
Architecture
Background Processes
Other processes are CKPT, ARCH, RECO Generally, a server process is started for each user process (connection)
Memory Structure
Pool
Redo
Files
Parameter files (init.ora & config.ora) Controlfiles Datafiles Redo log files
Parameter Files
The init.ora file The config.ora file They contain configuration information The default location for the init.ora is in the /oracle/<version>/product/dbs directory The config.ora file contains instance specific configuration
10
Controlfiles
The control files contains information about the physical structure and status of the database It is a binary file and cannot be viewed using a text editor It is critical to the operation of the database and must be mirrored to prevent losses due to media failure
11
Data Files
Datafiles are storage area for information Can be either a flat file or a raw partition
12
13
An Oracle Instance
An instance is made up of the SGA and the background processes An instance can be started without opening a database It is a framework under which the database operates
14
Starting An Instance
Server manager is used to start an instance The command to start server manager is svrmgrl (server manager line mode) The user connects as internal before starting the instance if she was authenticated at the OS level.
15
Starting An Instance
The instance is brought up using the startup command There are three stages in the startup process:
startup
16
shutdown
17
18
Accessing An Instance
Each person is given a login to the instance System administrator usually does connect internal or connect / as sysdba System/manager is the login and password used for system maintenance activities Having a login does not mean that the user has privileges to perform any operations in the database
19
An Oracle Database
A database is composed of one or more control files, data files and redo log files Logically, a database is made up of one or more tablespaces Typical tablespaces in a database are system, user, tool, rollback, temporary A database or a tablespace can be online or offline
20
Database Creation
There is one database per instance but multiple instances can access the same physical database (Oracle Parallel Server) The database must have at least one control file, one data file and two redo log groups The init.ora file must be edited to include the name of the database, the block size and other appropriate parameters
21
Creating A Database
Create database command This command must be executed in the nomount stage A control file is created during this process and it needs to be mirrored When the database is first created, only the SYSTEM tablespace exists
22
23
Database Access
Connecting as internal or sysdba is required for structural changes Two logins (sys and system) are reserved for system maintenance activities When creating a user, a profile indicating the resource assigned to the user must be specified
24
Database Access
There are two types of privileges: system and object System privileges allow users to perform operations that affect the structure of the database Object privileges allow users to perform specific actions on specific objects
25
26
27
28
Noarchivelog Mode
During the database creation process, the default mode is noarchivelog unless the archivelog parameter is explicitly specified This means that when Oracle has filled up all the redo log groups, it will reuse them by writing over existing information
29
Archivelog Mode
In the archivelog mode, the redo log files are not reused until the ARCH process has made a copy of the content of file The archived log files will be used for recovery from media failure
30
Archivelog Mode
The archivelog mode is enabled by issuing the alter database archivelog command Archiving redo logs can be automatic or manual To start archiving the redo log manually, issue the alter system archive log start (this tell the ARCH process to begin archiving)
31
Archivelog Mode
= true LOG_ARCHIVE_FORMAT = filename and extension LOG_ARCHIVE_DEST = directory path and file prefix
32
Database Backup
When developing a Backup strategy for a database, the following items need to be considered:
the
tolerance level for loss of data the amount of time available for backups the mode of the database
33
Database Backup
In the noarchivelog mode, the database must be offline prior to taking backup (this is known as cold backups) In the archivelog mode, the database can be online during the backup (this is known as hot backups)
34
Database Backup
The scope of a backup can be full or partial An offline (cold) backup is always a full database backup An online (hot) backup can be full or partial In a partial hot backup, only selected tablespaces are backed up or anything less than a full database backup
35
the database to find out the data, control and redo log files to be backed up Shutdown the instance using shutdown normal or immediate Use operating system commands to make a copy of all the files The parameter files should also be backed up
36
Database
37
the database to find out the tablespaces to be backed up Tablespaces are put into the backup mode using the Alter tablespace <tablespace_name> begin backup; command Use operating system commands to make a copy of all the datafiles for each tablespace Take the tablespace out of the backup mode using the alter tablespace <tablespace_name>
38
loss of data Database available during backup Allow more flexible recovery options
The main disadvantage is that recovery from this type of backup may be complicated
39
40
41
Database Recovery
Recovery strategies depend on the cause of failure and the mode of the database For instance failure or crash recovery, Oracle will automatically perform instance recovery during the next startup -SMON For media failure, the affected files must be restored manually and the database needs to be recovered
42
Database Recovery
For databases in noarchivelog mode, complete database recovery is the only option For databases in archivelog mode, both complete and incomplete recoveries are permitted
43
Recovery Process
what needs to be restored File restoration Application of redo and archive logs
All transactions are applied to the database then uncommitted ones are rolled back to bring the database to a consistent state
44
Recovery Process
Oracle will prompt the user to confirm before applying each archived log file This process can be automated by setting autorecovery on before recovering the database or enter AUTO at the prompt If the archived log files are not in the default location, specify the new location and filenames when prompted
45
all existing data, control and redo log files with those from the backup Replace the parameter files if necessary Start the instance
The entire database will be brought back to the time of the backup
46
47
Complete Recovery
Tablespaces and datafiles cannot be recovered to a point in time in the past while leaving the rest of the database in the current time Tablespaces and data files must be taken offline before performing the recovery
48
Incomplete Recovery
There are four types of incomplete recovery: time based, change based, cancel based and using a backup control file In order to perform incomplete recovery, the database has to be in archivelog mode The database must be opened with the resetlogs parameter
49
Point-In-Time Recovery
This is done using the recover database command with the until clause The user can specify a particular time or a specific SCN number The database must be opened with the resetlogs option and all previous backups become invalid
50
51
alter
database backup controlfile to trace; create a trace file in udump (location specified in your init.ora) destination
52
53
export
The export files can be used to move data between machines and versions of Oracle
even
54
Export
Scope of the export can be the whole database, the tables or objects, or objects belonged to a user or schema There are three types of export: complete, incremental and cumulative
55
Import
The import utility can only import files created by the export utility There are three types of information that can be imported: table definition, table data and table constraints The order in which objects are imported is important (referential integrity)
56
57
58
59