Anda di halaman 1dari 59

ORACLE SYSTEM ADMINISTRATION TRAINING

FOR LEVEL 2 TECHNICAL SUPPORT


1

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

The three main components are:


Background

processes Memory structure Files

Background Processes

The required processes are:


SMON PMON DBWR LGWR

Other processes are CKPT, ARCH, RECO Generally, a server process is started for each user process (connection)

Memory Structure

This is known as the System Global Area or SGA


large

Pool

The three main components are:


Database

Buffer cache Shared pool/shared SQL area


Library Cache Dictionary Cache

Redo

Log buffer cache


8

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

Redo Log Files


The files contain records of transactions which modify the data in the database Each database must have at least two redo log groups and at least one member in each group Is often mirrored for safety reasons

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

nomount startup mount startup open startup force

16

Shutting Down An Instance


This is accomplished through the shutdown command The shutdown command accepts three parameters:

shutdown

normal immediate abort

17

Showing Server Processes


Once an instance is started, use the ps -ef or ps -ax command to display all the background processes for that instance Each background process name shown in the ps output includes the instance name

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

Database File Synchronization


An Oracle database cannot be opened unless all data, control and redo log files are synchronized Synchronization is based on the current redo log sequence number ? SCN numbers The exception is read-only tablespace

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

Roles & Permissions


To simplify the granting of privileges, roles are created A role can be assigned to multiple users System and object privileges can be granted to the role

26

Trace File and Alert File


If an error occurs while the Oracle instance is running, messages are sent to the alert file If an internal error is detected by a server or background process, the information is sent to a trace file The BACKGROUND_DUMP_DEST parameter in the init.ora file indicates the location of both the alert and trace files

27

Transaction and Redo Log


When data modification activities occur, the changes are first written to the redo log The changes are reflected in the data files only if the transaction has been committed A database must have at least two redo log groups Oracle writes to the redo log groups in a circular fashion

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

For automatic archiving, change the following init.ora parameters:


LOG_ARCHIVE_START

= 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

Offline (Cold) Backup

Steps required are:


Query

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

Offline (Cold) Backup


The main advantage of cold backups is ease of operation The main disadvantages are:

Database

unavailable during backup Possible loss of data

37

Online (Hot) Backup

Steps required are:


Query

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

Online (Hot) Backup

Advantages of hot backups are:


Prevent

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

Control File Backup

The command to back up the control file is:


alter

database backup controlfile to <name>; alter database backup controlfile to /db2/oracle/KENL/backup/control01.ctl

The control file can be dumped in the text format as follow:


alter

database backup controlfile to trace;

Recommended after any changes to the database structure

40

Backup of Read-Only Tablespace


Data files related to the read-only tablespace need to be backed up only once The status of these tablespaces is unimportant

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

There are three phases in the recovery process:


Identified

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

Recovery from Cold Backups

Steps required are:


Replace

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

Recovery from Hot Backups


Recovery from a hot backup can be complete or incomplete Complete recovery is a recovery of the database/tablespace/data file to the point of failure Incomplete recovery happens when the database is not recovered to the point of failure

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

Recovering Control File


If there are good copies of the control file, shutdown the instance and copy the good one over the damaged one and restart the instance Otherwise, recover the control file from the backup

51

Recreating the Control File


Required if all the control files are damaged and there is no good backup or if the database name changes Use the create control file command The trace dump of the control file can be edited and used to create a new one

alter

database backup controlfile to trace; create a trace file in udump (location specified in your init.ora) destination

52

Recovering Read-Only Tablespace


Read-only tablespaces are ignored during database recovery However, if the data files for this type of tablespace become damaged, replace them with those from the backup

53

Import and Export


Import and export are utilities used to perform logical backup and recovery of the database or individual objects The information is written to operating system files

export

file has .dmp extention by default

The export files can be used to move data between machines and versions of Oracle
even

with full exp, all the objects owned by

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

Oracle Parallel Server


The Oracle server can run in either the exclusive or shared (parallel) mode In the shared mode, one or more instances of the server access a single physical database Each instance has its own SID, SGA, parameter file, background processes and redo log files

57

Oracle Parallel Server


All instances share the same data files and control files Additional background processes, LCKn, are required to coordinate the locking of shared resources

58

Questions and Answers

59

Anda mungkin juga menyukai